From a8502ab17d8132502a4976e5feb82284d0015a6f Mon Sep 17 00:00:00 2001 From: schneefux Date: Fri, 12 Sep 2014 06:34:19 +0100 Subject: Added extra diagnostics - Check if say or espeak are installed - Check if all pip requirements were installed --- client/diagnose.py | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/client/diagnose.py b/client/diagnose.py index 28cd9c8..5249965 100755 --- a/client/diagnose.py +++ b/client/diagnose.py @@ -3,8 +3,9 @@ import time import re import socket import os -from subprocess import check_output, call import jasperpath +import subprocess +from distutils.spawn import find_executable class Diagnostics: @@ -36,11 +37,33 @@ class Diagnostics: @classmethod def check_phonetisaurus_program(cls): - return call(['which', 'phonetisaurus-g2p']) == 0 + return cls.do_check_program('phonetisaurus-g2p') + + @classmethod + def check_espeak_program(cls): + return cls.do_check_program('espeak') + + @classmethod + def check_say_program(cls): + return cls.do_check_program('say') + + @classmethod + def do_check_program(cls, program): + return find_executable(program) is not None + + @classmethod + def check_all_pip_requirements_installed(cls): + try: + cmd = ['pip', 'install', '-r', 'requirements.txt', '--no-install', '--no-download'] + reqs = subprocess.check_output(cmd) + except subprocess.CalledProcessError: + return False + else: + return True @classmethod def info_git_revision(cls): - return check_output(['git', 'rev-parse', 'HEAD']) + return subprocess.check_output(['git', 'rev-parse', 'HEAD']) class DiagnosticRunner: -- cgit v1.3.1