Skip to content

Commit 899e21b

Browse files
committed
Remove support for legacy macOS machines
Add global validations for crontab executions
1 parent c11ccd3 commit 899e21b

14 files changed

+72
-110
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ jarvis start
113113
> Use `jarvis --help` for usage instructions.
114114
115115
## Prerequisites
116-
- **MacOS** <br> _Tested on **macOS High Sierra, Mojave, Catalina, Big Sur, Monterey and Ventura**_
116+
- **MacOS** <br> _Tested on **Mojave, Catalina, Big Sur, Monterey and Ventura**_
117117
- `System Preferences``Security & Privacy``Privacy`
118118
- Click `+` sign and add the preferred `IDE` and `Terminal` in the following sections in left pane.
119119
- `Microphone` - **Required** to listen and respond.

docs/README.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ <h1>Kick off<a class="headerlink" href="#kick-off" title="Permalink to this head
132132
<section id="prerequisites">
133133
<h1>Prerequisites<a class="headerlink" href="#prerequisites" title="Permalink to this heading"></a></h1>
134134
<ul class="simple">
135-
<li><p><strong>MacOS</strong> <br> <em>Tested on <strong>macOS High Sierra, Mojave, Catalina, Big Sur, Monterey and Ventura</strong></em></p>
135+
<li><p><strong>MacOS</strong> <br> <em>Tested on <strong>Mojave, Catalina, Big Sur, Monterey and Ventura</strong></em></p>
136136
<ul>
137137
<li><p><code class="docutils literal notranslate"><span class="pre">System</span> <span class="pre">Preferences</span></code><code class="docutils literal notranslate"><span class="pre">Security</span> <span class="pre">&amp;</span> <span class="pre">Privacy</span></code><code class="docutils literal notranslate"><span class="pre">Privacy</span></code></p></li>
138138
<li><p>Click <code class="docutils literal notranslate"><span class="pre">+</span></code> sign and add the preferred <code class="docutils literal notranslate"><span class="pre">IDE</span></code> and <code class="docutils literal notranslate"><span class="pre">Terminal</span></code> in the following sections in left pane.</p>

docs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ jarvis start
113113
> Use `jarvis --help` for usage instructions.
114114
115115
## Prerequisites
116-
- **MacOS** <br> _Tested on **macOS High Sierra, Mojave, Catalina, Big Sur, Monterey and Ventura**_
116+
- **MacOS** <br> _Tested on **Mojave, Catalina, Big Sur, Monterey and Ventura**_
117117
- `System Preferences``Security & Privacy``Privacy`
118118
- Click `+` sign and add the preferred `IDE` and `Terminal` in the following sections in left pane.
119119
- `Microphone` - **Required** to listen and respond.

docs/_sources/README.md.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ jarvis start
113113
> Use `jarvis --help` for usage instructions.
114114

115115
## Prerequisites
116-
- **MacOS** <br> _Tested on **macOS High Sierra, Mojave, Catalina, Big Sur, Monterey and Ventura**_
116+
- **MacOS** <br> _Tested on **Mojave, Catalina, Big Sur, Monterey and Ventura**_
117117
- `System Preferences` → `Security & Privacy` → `Privacy`
118118
- Click `+` sign and add the preferred `IDE` and `Terminal` in the following sections in left pane.
119119
- `Microphone` - **Required** to listen and respond.

docs/genindex.html

+7-5
Original file line numberDiff line numberDiff line change
@@ -2030,8 +2030,6 @@ <h2 id="L">L</h2>
20302030
</li>
20312031
</ul></li>
20322032
<li><a href="index.html#jarvis.modules.facenet.face.FaceNet.LEARNING_RATE">LEARNING_RATE (jarvis.modules.facenet.face.FaceNet attribute)</a>
2033-
</li>
2034-
<li><a href="index.html#jarvis.modules.models.classes.Settings.legacy">legacy (jarvis.modules.models.classes.Settings attribute)</a>
20352033
</li>
20362034
<li><a href="index.html#jarvis.modules.tv.lg.LGWebOS">LGWebOS (class in jarvis.modules.tv.lg)</a>
20372035
</li>
@@ -2065,10 +2063,10 @@ <h2 id="L">L</h2>
20652063
</ul></li>
20662064
<li><a href="index.html#jarvis.modules.camera.camera.list_splitter">list_splitter() (in module jarvis.modules.camera.camera)</a>
20672065
</li>
2068-
</ul></td>
2069-
<td style="width: 33%; vertical-align: top;"><ul>
20702066
<li><a href="index.html#jarvis.modules.audio.listener.listen">listen() (in module jarvis.modules.audio.listener)</a>
20712067
</li>
2068+
</ul></td>
2069+
<td style="width: 33%; vertical-align: top;"><ul>
20722070
<li><a href="index.html#jarvis.modules.audio.listener.listen_recursive">listen_recursive() (in module jarvis.modules.audio.listener)</a>
20732071
</li>
20742072
<li><a href="index.html#jarvis.executors.listener_controls.listener_control">listener_control() (in module jarvis.executors.listener_controls)</a>
@@ -3064,8 +3062,12 @@ <h2 id="S">S</h2>
30643062
</li>
30653063
<li><a href="index.html#jarvis.executors.controls.starter">starter() (in module jarvis.executors.controls)</a>
30663064
</li>
3067-
<li><a href="index.html#jarvis.modules.tv.roku.RokuECP.startup">startup() (jarvis.modules.tv.roku.RokuECP method)</a>
3065+
<li><a href="index.html#jarvis.api.main.startup">startup() (in module jarvis.api.main)</a>
3066+
3067+
<ul>
3068+
<li><a href="index.html#jarvis.modules.tv.roku.RokuECP.startup">(jarvis.modules.tv.roku.RokuECP method)</a>
30683069
</li>
3070+
</ul></li>
30693071
<li><a href="index.html#jarvis.modules.models.classes.FileIO.startup_dir">startup_dir (jarvis.modules.models.classes.FileIO attribute)</a>
30703072
</li>
30713073
<li><a href="index.html#jarvis.api.main.startup_func">startup_func() (in module jarvis.api.main)</a>

docs/index.html

+7-6
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,12 @@ <h1>———-Jarvis API———-<a class="headerlink" href="#jarvis-api" title
842842
<dd><p>Allow CORS: Cross-Origin Resource Sharing to allow restricted resources on the API.</p>
843843
</dd></dl>
844844

845+
<dl class="py function">
846+
<dt class="sig sig-object py" id="jarvis.api.main.startup">
847+
<span class="sig-prename descclassname"><span class="pre">jarvis.api.main.</span></span><span class="sig-name descname"><span class="pre">startup</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#jarvis.api.main.startup" title="Permalink to this definition">¶</a></dt>
848+
<dd><p>Runs startup scripts (<code class="docutils literal notranslate"><span class="pre">.py</span></code>, <code class="docutils literal notranslate"><span class="pre">.sh</span></code>, <code class="docutils literal notranslate"><span class="pre">.zsh</span></code>) stored in <code class="docutils literal notranslate"><span class="pre">fileio/startup</span></code> directory.</p>
849+
</dd></dl>
850+
845851
<dl class="py function">
846852
<dt class="sig sig-object py" id="jarvis.api.main.startup_func">
847853
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">jarvis.api.main.</span></span><span class="sig-name descname"><span class="pre">startup_func</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#jarvis.api.main.startup_func" title="Permalink to this definition">¶</a></dt>
@@ -3407,7 +3413,7 @@ <h1>———-Executors———-<a class="headerlink" href="#executors" title="
34073413
<dl class="py method">
34083414
<dt class="sig sig-object py">
34093415
<span class="sig-name descname"><span class="pre">-</span> <span class="pre">volume</span></span></dt>
3410-
<dd><p>To default the master volume 50%.</p>
3416+
<dd><p>To default the master volume a specific percent.</p>
34113417
</dd></dl>
34123418

34133419
<dl class="py method">
@@ -5753,11 +5759,6 @@ <h1>———-Models———-<a class="headerlink" href="#models" title="Permal
57535759
<span class="sig-name descname"><span class="pre">os</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">str</span></em><a class="headerlink" href="#jarvis.modules.models.classes.Settings.os" title="Permalink to this definition">¶</a></dt>
57545760
<dd></dd></dl>
57555761

5756-
<dl class="py attribute">
5757-
<dt class="sig sig-object py" id="jarvis.modules.models.classes.Settings.legacy">
5758-
<span class="sig-name descname"><span class="pre">legacy</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">bool</span></em><a class="headerlink" href="#jarvis.modules.models.classes.Settings.legacy" title="Permalink to this definition">¶</a></dt>
5759-
<dd></dd></dl>
5760-
57615762
<dl class="py method">
57625763
<dt class="sig sig-object py" id="jarvis.modules.models.classes.Settings.model_post_init">
57635764
<span class="sig-name descname"><span class="pre">model_post_init</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">__context</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Any</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#jarvis.modules.models.classes.Settings.model_post_init" title="Permalink to this definition">¶</a></dt>

docs/objects.inv

-5 Bytes
Binary file not shown.

docs/searchindex.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jarvis/api/main.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,8 @@ def enable_cors() -> None:
6161
app.include_router(router)
6262

6363

64-
@app.on_event(event_type="startup")
65-
async def startup_func() -> None:
66-
"""Simple startup function to add anything that has to be triggered when Jarvis API starts up."""
67-
logger.info(
68-
"Hosting at http://%s:%s", models.env.offline_host, models.env.offline_port
69-
)
70-
if models.env.author_mode:
71-
Thread(target=stockanalysis_squire.nasdaq).start()
64+
def startup() -> None:
65+
"""Runs startup scripts (``.py``, ``.sh``, ``.zsh``) stored in ``fileio/startup`` directory."""
7266
if not os.path.isdir(models.fileio.startup_dir):
7367
return
7468
for startup_script in os.listdir(models.fileio.startup_dir):
@@ -102,3 +96,14 @@ async def startup_func() -> None:
10296
logger.warning(
10397
"Unsupported file format for startup script: %s", startup_script
10498
)
99+
100+
101+
@app.on_event(event_type="startup")
102+
async def startup_func() -> None:
103+
"""Simple startup function to add anything that has to be triggered when Jarvis API starts up."""
104+
logger.info(
105+
"Hosting at http://%s:%s", models.env.offline_host, models.env.offline_port
106+
)
107+
if models.env.author_mode:
108+
Thread(target=stockanalysis_squire.nasdaq).start()
109+
startup()

jarvis/executors/controls.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def starter() -> None:
341341
342342
Methods:
343343
- put_listener_state: To activate listener enabling voice conversations.
344-
- volume: To default the master volume 50%.
344+
- volume: To default the master volume a specific percent.
345345
- voices: To change the voice to default value.
346346
- delete_logs: To purge log files older than the set log retention time.
347347
- delete_pycache: To purge pycache directories.

jarvis/lib/install_darwin.sh

100755100644
+14-25
Original file line numberDiff line numberDiff line change
@@ -42,34 +42,23 @@ brew install portaudio coreutils ffmpeg lame
4242
# Install macOS specifics
4343
python -m pip install playsound==1.3.0 ftransc==7.0.3 pyobjc-framework-CoreWLAN==9.0.1
4444

45-
# Checks current version and installs legacy version of dependencies if macOS is older han 10.14
46-
base_ver="10.14" # Versions older than Mojave (High Sierra and older versions)
47-
os_ver=$(sw_vers | grep ProductVersion | cut -d':' -f2 | tr -d ' ' | xargs)
4845
# Uninstall any remaining cmake packages from pypi before brew installing it to avoid conflict
4946
python -m pip uninstall --no-cache --no-cache-dir cmake && brew install cmake
50-
if awk "BEGIN {exit !($base_ver > $os_ver)}"; then
51-
echo ""
52-
echo "*****************************************************************************************************************"
53-
echo " macOS $os_ver will be deprecated in the near future"
54-
echo " Please upgrade to $base_ver to continue using Jarvis"
55-
echo "*****************************************************************************************************************"
56-
echo ""
57-
python -m pip install pvporcupine==1.6.0 dlib==19.21.0 opencv-python==4.4.0.44
47+
48+
# shellcheck disable=SC2154
49+
if [ "$pyversion" -eq 310 ]; then
50+
python -m pip install dlib==19.24.0
51+
fi
52+
if [ "$pyversion" -eq 311 ]; then
53+
python -m pip install dlib==19.24.4
54+
fi
55+
python -m pip install opencv-python==4.9.0.80
56+
57+
# shellcheck disable=SC2154
58+
if [[ "$architecture" == "arm64" ]]; then
59+
python -m pip install pvporcupine==3.0.2
5860
else
59-
# shellcheck disable=SC2154
60-
if [ "$pyversion" -eq 310 ]; then
61-
python -m pip install dlib==19.24.0
62-
fi
63-
if [ "$pyversion" -eq 311 ]; then
64-
python -m pip install dlib==19.24.4
65-
fi
66-
python -m pip install opencv-python==4.9.0.80
67-
# shellcheck disable=SC2154
68-
if [[ "$architecture" == "arm64" ]]; then
69-
python -m pip install pvporcupine==3.0.2
70-
else
71-
python -m pip install pvporcupine==1.9.5
72-
fi
61+
python -m pip install pvporcupine==1.9.5
7362
fi
7463

7564
# Install as stand alone as face recognition depends on dlib

jarvis/main.py

+4-15
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,8 @@ def constructor() -> Dict[str, str | List[float] | List[str]]:
4343
if models.WAKE_WORD_DETECTOR == "1.9.5":
4444
arguments["library_path"] = pvporcupine.LIBRARY_PATH
4545
keyword_paths = [pvporcupine.KEYWORD_PATHS[x] for x in models.env.wake_words]
46-
if models.settings.legacy:
47-
arguments["model_file_path"] = pvporcupine.MODEL_PATH
48-
arguments["keyword_file_paths"] = keyword_paths
49-
else:
50-
arguments["model_path"] = pvporcupine.MODEL_PATH
51-
arguments["keyword_paths"] = keyword_paths
46+
arguments["model_path"] = pvporcupine.MODEL_PATH
47+
arguments["keyword_paths"] = keyword_paths
5248
elif Version(models.WAKE_WORD_DETECTOR) >= Version("3.0.2"):
5349
arguments["access_key"] = models.env.porcupine_key
5450
else:
@@ -149,7 +145,6 @@ def executor(self) -> None:
149145
def start(self) -> None:
150146
"""Runs ``audio_stream`` in a forever loop and calls ``initiator`` when the phrase ``Jarvis`` is heard."""
151147
try:
152-
wake_len = len(models.env.wake_words)
153148
support.write_screen(text=self.label)
154149
while True:
155150
result = self.detector.process(
@@ -161,14 +156,8 @@ def start(self) -> None:
161156
),
162157
)
163158
)
164-
if models.settings.legacy:
165-
if wake_len == 1 and result:
166-
self.executor()
167-
elif wake_len > 1 and result >= 0:
168-
self.executor()
169-
else:
170-
if result >= 0:
171-
self.executor()
159+
if result >= 0:
160+
self.executor()
172161
if models.settings.limited:
173162
continue
174163
restart_checker()

jarvis/modules/models/classes.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,13 @@ class Settings(BaseModel):
7474
distro: str = squire.get_distributor_info_linux()
7575

7676
os: str = platform.system()
77-
legacy: bool = False
7877
if os == enums.SupportedPlatforms.macOS and Version(
7978
platform.mac_ver()[0]
8079
) < Version("10.14"):
81-
legacy: bool = True
80+
raise DeprecationWarning(
81+
f"\nmacOS {platform.mac_ver()[0]} has been deprecated\n"
82+
f"Please upgrade to 10.14 or above to continue using Jarvis",
83+
)
8284

8385

8486
settings = Settings()
@@ -354,11 +356,7 @@ class EnvConfig(BaseSettings):
354356
wifi_password: str | None = None
355357
connection_retry: PositiveInt | PositiveFloat = 10
356358

357-
# Legacy macOS config
358-
if settings.legacy:
359-
wake_words: List[str] = ["alexa"]
360-
else:
361-
wake_words: List[str] = ["jarvis"]
359+
wake_words: List[str] = ["jarvis"]
362360

363361
class Config:
364362
"""Environment variables configuration."""

jarvis/modules/models/models.py

+16-38
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import os
99
import pathlib
10-
import platform
1110
import warnings
1211
from importlib import metadata
1312

@@ -128,38 +127,16 @@ def _set_default_voice_name() -> None:
128127

129128
def _main_process_validations() -> None:
130129
"""Validations that should happen only when the main process is triggered."""
131-
if settings.legacy:
132-
try:
133-
assert WAKE_WORD_DETECTOR == "1.6.0"
134-
except AssertionError:
135-
raise DependencyError(
136-
"Legacy macOS is only supported with porcupine version 1.6.0"
137-
)
138-
pvporcupine.KEYWORD_PATHS = {}
139-
base_path = os.path.dirname(pvporcupine.__file__)
140-
pvporcupine.MODEL_PATH = os.path.join(
141-
base_path, "lib/common/porcupine_params.pv"
130+
try:
131+
# 3.0.2 is the last tested version on macOS - arm64 - 14.5
132+
assert WAKE_WORD_DETECTOR == "1.9.5" or Version(WAKE_WORD_DETECTOR) >= Version(
133+
"3.0.2"
142134
)
143-
pvporcupine.LIBRARY_PATH = os.path.join(
144-
base_path, "lib/mac/x86_64/libpv_porcupine.dylib"
135+
except AssertionError:
136+
raise DependencyError(
137+
f"{settings.os} is only supported with porcupine versions 1.9.5 or 3.0.2 and above (requires key)"
145138
)
146139

147-
# Iterates over the available flash files, to override the object reference
148-
for x in os.listdir(os.path.join(base_path, "resources/keyword_files/mac/")):
149-
pvporcupine.KEYWORD_PATHS[x.split("_")[0]] = os.path.join(
150-
base_path, f"resources/keyword_files/mac/{x}"
151-
)
152-
else:
153-
try:
154-
# 3.0.2 is the last tested version on macOS - arm64 - 14.5
155-
assert WAKE_WORD_DETECTOR == "1.9.5" or Version(
156-
WAKE_WORD_DETECTOR
157-
) >= Version("3.0.2")
158-
except AssertionError:
159-
raise DependencyError(
160-
f"{settings.os} is only supported with porcupine versions 1.9.5 or 3.0.2 and above (requires key)"
161-
)
162-
163140
for keyword in env.wake_words:
164141
if not pvporcupine.KEYWORD_PATHS.get(keyword) or not os.path.isfile(
165142
pvporcupine.KEYWORD_PATHS[keyword]
@@ -193,13 +170,6 @@ def _main_process_validations() -> None:
193170
def _global_validations() -> None:
194171
"""Validations that should happen for all processes including parent and child."""
195172
main = True if settings.pname == "JARVIS" else False
196-
if settings.legacy:
197-
warnings.warn(
198-
f"\nmacOS {platform.mac_ver()[0]} will be deprecated in the near future\n"
199-
f"Please upgrade to 10.14 or above to continue using Jarvis",
200-
DeprecationWarning,
201-
)
202-
203173
if voice_names := [__voice.name for __voice in voices]:
204174
if not env.voice_name:
205175
_set_default_voice_name()
@@ -325,10 +295,18 @@ def _global_validations() -> None:
325295

326296

327297
_global_validations()
298+
328299
# Required at top level to let other modules access it
329300
if env.temperature_unit == TemperatureUnits.IMPERIAL:
330301
temperature_symbol = "F"
331302
elif env.temperature_unit == TemperatureUnits.METRIC:
332303
temperature_symbol = "C"
333-
if settings.pname in ("JARVIS", "pre_commit"):
304+
305+
if settings.pname in (
306+
"JARVIS",
307+
"pre_commit",
308+
"startup_script",
309+
"plot_mic",
310+
"crontab_executor",
311+
):
334312
_main_process_validations()

0 commit comments

Comments
 (0)