Skip to content
This repository was archived by the owner on Sep 8, 2024. It is now read-only.

Commit e307df2

Browse files
author
penrods
committed
Duplicate service hack #2... performing check in the Enclosure client after a
60 second delay. The packaging system was preventing the previous approach from rebooting.
1 parent 8cbc73e commit e307df2

File tree

3 files changed

+39
-37
lines changed

3 files changed

+39
-37
lines changed

mycroft/client/enclosure/__init__.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ def on_arduino_responded(self, event=None):
270270
# quickly and the user wasn't notified what to do.
271271
Timer(5, self._do_net_check).start()
272272

273+
Timer(60, self._hack_check_for_duplicates).start()
274+
273275
def on_no_internet(self, event=None):
274276
if connected():
275277
# One last check to see if connection was established
@@ -384,3 +386,39 @@ def _do_net_check(self):
384386
"either plug me in with a network cable,"
385387
" or use wifi. To setup wifi ",
386388
'allow_timeout': False}))
389+
390+
def _hack_check_for_duplicates(self):
391+
# TEMPORARY HACK: Look for multiple instance of the
392+
# mycroft-speech-client and/or mycroft-skills services, which could
393+
# happen when upgrading a shipping Mark 1 from release 0.8.17 or
394+
# before. When found, force the unit to reboot.
395+
import psutil
396+
397+
LOG.info("Hack to check for duplicate service instances")
398+
399+
count_instances = 0
400+
needs_reboot = False
401+
for process in psutil.process_iter():
402+
if process.cmdline() == ['python2.7',
403+
'/usr/local/bin/mycroft-speech-client']:
404+
count_instances += 1
405+
if (count_instances > 1):
406+
LOG.info("Duplicate mycroft-speech-client found")
407+
needs_reboot = True
408+
409+
count_instances = 0
410+
for process in psutil.process_iter():
411+
if process.cmdline() == ['python2.7',
412+
'/usr/local/bin/mycroft-skills']:
413+
count_instances += 1
414+
if (count_instances > 1):
415+
LOG.info("Duplicate mycroft-skills found")
416+
needs_reboot = True
417+
418+
if needs_reboot:
419+
LOG.info("Hack reboot...")
420+
self.reader.process("unit.reboot")
421+
ws.emit(Message("enclosure.eyes.spin"))
422+
ws.emit(Message("enclosure.mouth.reset"))
423+
# END HACK
424+
# TODO: Remove this hack ASAP

mycroft/client/speech/main.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -178,24 +178,6 @@ def handle_open():
178178
# Reset the UI to indicate ready for speech processing
179179
EnclosureAPI(ws).reset()
180180

181-
# TEMPORARY HACK: Look for multiple instance of the mycroft-speech-client
182-
# which could happen when upgrading a shipping Mark 1 from release 0.8.17
183-
# or before. When found, force the unit to reboot...
184-
import psutil
185-
import subprocess
186-
count_instances = 0
187-
for process in psutil.process_iter():
188-
if process.cmdline() == ['python2.7',
189-
'/usr/local/bin/mycroft-speech-client']:
190-
count_instances += 1
191-
if (count_instances > 1):
192-
ws.emit(Message("enclosure.eyes.spin"))
193-
ws.emit(Message("enclosure.mouth.reset"))
194-
time.sleep(0.5) # Allows system time to start the eyes spinning
195-
subprocess.call('systemctl reboot -i', shell=True)
196-
# END HACK
197-
# TODO: Remove this hack ASAP
198-
199181

200182
def connect():
201183
ws.run_forever()

mycroft/skills/main.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -212,25 +212,7 @@ def _watch_skills():
212212

213213

214214
def _starting_up():
215-
global ws
216-
217-
# TEMPORARY HACK: Look for multiple instance of the mycroft-skills, which
218-
# could happen when upgrading a shipping Mark 1 from release 0.8.17 or
219-
# before. When found, force the unit to reboot...
220-
import psutil
221-
count_instances = 0
222-
for process in psutil.process_iter():
223-
if process.cmdline() == ['python2.7', '/usr/local/bin/mycroft-skills']:
224-
count_instances += 1
225-
if (count_instances > 1):
226-
ws.emit(Message("enclosure.eyes.spin"))
227-
ws.emit(Message("enclosure.mouth.reset"))
228-
time.sleep(0.5) # Allows system time to start the eyes spinning
229-
subprocess.call('systemctl reboot -i', shell=True)
230-
# END HACK
231-
# TODO: Remove this hack ASAP
232-
233-
# Startup: Kick off loading of skills, etc.
215+
# Startup: Kick off loading of skills
234216
_load_skills()
235217

236218

0 commit comments

Comments
 (0)