Fix subprocess.call() issue and add error logging.

pull/891/merge
Åke Forslund 2017-07-05 12:10:04 +02:00 committed by Arron Atchison
parent cfdc609586
commit 28c15eb64e
1 changed files with 6 additions and 2 deletions

View File

@ -65,16 +65,20 @@ def install_default_skills(speak=True):
speak (optional): Enable response for success. Default True
"""
if exists(MSM_BIN):
res = subprocess.call(MSM_BIN + " default", stderr=subprocess.STDOUT,
stdout=subprocess.PIPE, shell=True)
p = subprocess.Popen(MSM_BIN + " default", stderr=subprocess.STDOUT,
stdout=subprocess.PIPE, shell=True)
(output, err) = p.communicate()
res = p.returncode
if res == 0 and speak:
# ws.emit(Message("speak", {
# 'utterance': mycroft.dialog.get("skills updated")}))
pass
elif not connected():
logger.error('msm failed, network connection is not available')
ws.emit(Message("speak", {
'utterance': mycroft.dialog.get("no network connection")}))
elif res != 0:
logger.error('msm failed with error {}: {}'.format(res, output))
ws.emit(Message("speak", {
'utterance': mycroft.dialog.get(
"sorry I couldn't install default skills")}))