Skip to content

Commit

Permalink
Fix startup for python11
Browse files Browse the repository at this point in the history
  • Loading branch information
pnhofmann committed Dec 28, 2023
1 parent 5778310 commit 77b0980
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 303 deletions.
9 changes: 9 additions & 0 deletions jarviscli/PluginManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ def patched_load_source(*args):
return sys
pluginmanager.module_manager.load_source = patched_load_source

_handle_class_instance = self._backend.plugin_manager._handle_class_instance
def patched_handle_class_instance(*args):
try:
_handle_class_instance(*args)
except:
pass
self._backend.plugin_manager._handle_class_instance = patched_handle_class_instance

self._plugin_dependency = PluginDependency()

self._cache = None
Expand All @@ -42,6 +50,7 @@ def __ends_with_py(s):
self._backend.set_file_filters(__ends_with_py)
self._backend.add_blacklisted_directories("jarviscli/packages/aiml")
self._backend.add_blacklisted_directories("jarviscli/packages/memory")
self._backend.add_blacklisted_directories("env")

def add_directory(self, path):
"""Add directory to search path for plugins"""
Expand Down
297 changes: 0 additions & 297 deletions jarviscli/plugins/calculator.py

This file was deleted.

20 changes: 14 additions & 6 deletions jarviscli/utilities/voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@
import os
import subprocess
from gtts import gTTS
from pydub import AudioSegment, playback

try:
from pydub import AudioSegment, playback

# patch pydup - hide std output
FNULL = open(os.devnull, 'w')
_subprocess_call = playback.subprocess.call
playback.subprocess.call = lambda cmd: _subprocess_call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)


PYDUB_AVAILABLE = True
except ImportError:
PYDUB_AVAILABLE = False


# patch pydup - hide std output
FNULL = open(os.devnull, 'w')
_subprocess_call = playback.subprocess.call
playback.subprocess.call = lambda cmd: _subprocess_call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)


if IS_MACOS:
Expand All @@ -24,7 +32,7 @@ def create_voice(self, gtts_status, rate=180):
:param rate: Speech rate for the engine (if supported by the OS)
"""

if gtts_status is True:
if PYDUB_AVAILABLE and gtts_status is True:
return VoiceGTTS()
else:
if IS_MACOS:
Expand Down

0 comments on commit 77b0980

Please sign in to comment.