commit
db06962ca2
|
@ -20,7 +20,7 @@ install:
|
||||||
- pip install -r test-requirements.txt
|
- pip install -r test-requirements.txt
|
||||||
# command to run tests
|
# command to run tests
|
||||||
script:
|
script:
|
||||||
- pep8 mycroft test
|
- pycodestyle mycroft test
|
||||||
- ./start-mycroft.sh unittest
|
- ./start-mycroft.sh unittest
|
||||||
env:
|
env:
|
||||||
- IS_TRAVIS=true
|
- IS_TRAVIS=true
|
||||||
|
|
|
@ -369,8 +369,8 @@ source "${VIRTUALENV_ROOT}/bin/activate"
|
||||||
cd "${TOP}"
|
cd "${TOP}"
|
||||||
|
|
||||||
# Install pep8 pre-commit hook
|
# Install pep8 pre-commit hook
|
||||||
if [ -z ${INSTALL_PRECOMMIT_HOOK} ] ; then
|
HOOK_FILE="./.git/hooks/pre-commit"
|
||||||
HOOK_FILE="./.git/hooks/pre-commit"
|
if [ ! -z ${INSTALL_PRECOMMIT_HOOK+x} ] || grep -q "MYCROFT DEV SETUP" ${HOOK_FILE}; then
|
||||||
if [ ! -f ${HOOK_FILE} ] || grep -q "MYCROFT DEV SETUP" ${HOOK_FILE} ; then
|
if [ ! -f ${HOOK_FILE} ] || grep -q "MYCROFT DEV SETUP" ${HOOK_FILE} ; then
|
||||||
echo "Installing PEP8 check as precommit-hook"
|
echo "Installing PEP8 check as precommit-hook"
|
||||||
echo "#! $( which python )" > ${HOOK_FILE}
|
echo "#! $( which python )" > ${HOOK_FILE}
|
||||||
|
|
|
@ -171,7 +171,7 @@ class Api:
|
||||||
def get_data(self, response):
|
def get_data(self, response):
|
||||||
try:
|
try:
|
||||||
return response.json()
|
return response.json()
|
||||||
except:
|
except Exception:
|
||||||
return response.text
|
return response.text
|
||||||
|
|
||||||
def build_headers(self, params):
|
def build_headers(self, params):
|
||||||
|
@ -331,7 +331,7 @@ class DeviceApi(Api):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return self.get_subscription().get('@type') != 'free'
|
return self.get_subscription().get('@type') != 'free'
|
||||||
except:
|
except Exception:
|
||||||
# If can't retrieve, assume not paired and not a subscriber yet
|
# If can't retrieve, assume not paired and not a subscriber yet
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ class MopidyService(RemoteAudioBackend):
|
||||||
url = self.config.get('url', url)
|
url = self.config.get('url', url)
|
||||||
try:
|
try:
|
||||||
self.mopidy = Mopidy(url)
|
self.mopidy = Mopidy(url)
|
||||||
except:
|
except Exception:
|
||||||
if self.connection_attempts < 1:
|
if self.connection_attempts < 1:
|
||||||
LOG.debug('Could not connect to server, will retry quietly')
|
LOG.debug('Could not connect to server, will retry quietly')
|
||||||
self.connection_attempts += 1
|
self.connection_attempts += 1
|
||||||
|
|
|
@ -53,11 +53,11 @@ class Mopidy:
|
||||||
d['method'] = 'core.library.search'
|
d['method'] = 'core.library.search'
|
||||||
d['params'] = {'album': [album]}
|
d['params'] = {'album': [album]}
|
||||||
r = requests.post(self.url, data=json.dumps(d))
|
r = requests.post(self.url, data=json.dumps(d))
|
||||||
l = [res['albums'] for res in r.json()['result'] if 'albums' in res]
|
lst = [res['albums'] for res in r.json()['result'] if 'albums' in res]
|
||||||
if filter is None:
|
if filter is None:
|
||||||
return l
|
return lst
|
||||||
else:
|
else:
|
||||||
return [i for sl in l for i in sl if filter + ':' in i['uri']]
|
return [i for sl in lst for i in sl if filter + ':' in i['uri']]
|
||||||
|
|
||||||
def find_exact(self, uris='null'):
|
def find_exact(self, uris='null'):
|
||||||
d = copy(_base_dict)
|
d = copy(_base_dict)
|
||||||
|
|
|
@ -41,7 +41,7 @@ class WebsocketEventHandler(tornado.websocket.WebSocketHandler):
|
||||||
# LOG.debug(message)
|
# LOG.debug(message)
|
||||||
try:
|
try:
|
||||||
deserialized_message = Message.deserialize(message)
|
deserialized_message = Message.deserialize(message)
|
||||||
except:
|
except Exception:
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -132,7 +132,7 @@ class MycroftSTT(STT):
|
||||||
try:
|
try:
|
||||||
return self.api.stt(audio.get_flac_data(convert_rate=16000),
|
return self.api.stt(audio.get_flac_data(convert_rate=16000),
|
||||||
self.lang, 1)[0]
|
self.lang, 1)[0]
|
||||||
except:
|
except Exception:
|
||||||
return self.api.stt(audio.get_flac_data(), self.lang, 1)[0]
|
return self.api.stt(audio.get_flac_data(), self.lang, 1)[0]
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ class KaldiSTT(STT):
|
||||||
try:
|
try:
|
||||||
hypotheses = response.json()["hypotheses"]
|
hypotheses = response.json()["hypotheses"]
|
||||||
return re.sub(r'\s*\[noise\]\s*', '', hypotheses[0]["utterance"])
|
return re.sub(r'\s*\[noise\]\s*', '', hypotheses[0]["utterance"])
|
||||||
except:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ class PlaybackThread(Thread):
|
||||||
self.queue.get()
|
self.queue.get()
|
||||||
try:
|
try:
|
||||||
self.p.terminate()
|
self.p.terminate()
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
@ -386,7 +386,7 @@ class TTS:
|
||||||
with open(pho_file, "r") as cachefile:
|
with open(pho_file, "r") as cachefile:
|
||||||
phonemes = cachefile.read().strip()
|
phonemes = cachefile.read().strip()
|
||||||
return phonemes
|
return phonemes
|
||||||
except:
|
except Exception:
|
||||||
LOG.debug("Failed to read .PHO from cache")
|
LOG.debug("Failed to read .PHO from cache")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ class ESpeakValidator(TTSValidator):
|
||||||
def validate_connection(self):
|
def validate_connection(self):
|
||||||
try:
|
try:
|
||||||
subprocess.call(['espeak', '--version'])
|
subprocess.call(['espeak', '--version'])
|
||||||
except:
|
except Exception:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
'ESpeak is not installed. Run: sudo apt-get install espeak')
|
'ESpeak is not installed. Run: sudo apt-get install espeak')
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ class FATTSValidator(TTSValidator):
|
||||||
content = resp.json()
|
content = resp.json()
|
||||||
if content.get('product', '').find('FA-TTS') < 0:
|
if content.get('product', '').find('FA-TTS') < 0:
|
||||||
raise Exception('Invalid FA-TTS server.')
|
raise Exception('Invalid FA-TTS server.')
|
||||||
except:
|
except Exception:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
'FA-TTS server could not be verified. Check your connection '
|
'FA-TTS server could not be verified. Check your connection '
|
||||||
'to the server: ' + self.tts.url)
|
'to the server: ' + self.tts.url)
|
||||||
|
|
|
@ -39,7 +39,7 @@ class GoogleTTSValidator(TTSValidator):
|
||||||
def validate_connection(self):
|
def validate_connection(self):
|
||||||
try:
|
try:
|
||||||
gTTS(text='Hi').save(self.tts.filename)
|
gTTS(text='Hi').save(self.tts.filename)
|
||||||
except:
|
except Except:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
'GoogleTTS server could not be verified. Please check your '
|
'GoogleTTS server could not be verified. Please check your '
|
||||||
'internet connection.')
|
'internet connection.')
|
||||||
|
|
|
@ -53,7 +53,7 @@ class MaryTTSValidator(TTSValidator):
|
||||||
resp = requests.get(self.tts.url + "/version", verify=False)
|
resp = requests.get(self.tts.url + "/version", verify=False)
|
||||||
if resp.content.find('Mary TTS server') < 0:
|
if resp.content.find('Mary TTS server') < 0:
|
||||||
raise Exception('Invalid MaryTTS server.')
|
raise Exception('Invalid MaryTTS server.')
|
||||||
except:
|
except Exception:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
'MaryTTS server could not be verified. Check your connection '
|
'MaryTTS server could not be verified. Check your connection '
|
||||||
'to the server: ' + self.tts.url)
|
'to the server: ' + self.tts.url)
|
||||||
|
|
|
@ -168,7 +168,7 @@ class MimicValidator(TTSValidator):
|
||||||
def validate_connection(self):
|
def validate_connection(self):
|
||||||
try:
|
try:
|
||||||
subprocess.call([BIN, '--version'])
|
subprocess.call([BIN, '--version'])
|
||||||
except:
|
except Exception:
|
||||||
LOG.info("Failed to find mimic at: " + BIN)
|
LOG.info("Failed to find mimic at: " + BIN)
|
||||||
raise Exception(
|
raise Exception(
|
||||||
'Mimic was not found. Run install-mimic.sh to install it.')
|
'Mimic was not found. Run install-mimic.sh to install it.')
|
||||||
|
|
|
@ -39,7 +39,7 @@ class SpdSayValidator(TTSValidator):
|
||||||
def validate_connection(self):
|
def validate_connection(self):
|
||||||
try:
|
try:
|
||||||
subprocess.call(['spd-say', '--version'])
|
subprocess.call(['spd-say', '--version'])
|
||||||
except:
|
except Exception:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
'SpdSay is not installed. Run: sudo apt-get install '
|
'SpdSay is not installed. Run: sudo apt-get install '
|
||||||
'speech-dispatcher')
|
'speech-dispatcher')
|
||||||
|
|
|
@ -13,7 +13,7 @@ import tempfile
|
||||||
# don't fill in both of these
|
# don't fill in both of these
|
||||||
select_codes = []
|
select_codes = []
|
||||||
ignore_codes = ["E121", "E122", "E123", "E124", "E125", "E126", "E127", "E128",
|
ignore_codes = ["E121", "E122", "E123", "E124", "E125", "E126", "E127", "E128",
|
||||||
"E129", "E501", "E722", "E226"]
|
"E129", "E501", "E722", "E226", "W504"]
|
||||||
# Add things like "--max-line-length=120" below
|
# Add things like "--max-line-length=120" below
|
||||||
overrides = []
|
overrides = []
|
||||||
|
|
||||||
|
@ -40,7 +40,10 @@ def main():
|
||||||
with open(filename, 'w') as f:
|
with open(filename, 'w') as f:
|
||||||
system('git', 'show', ':' + name, stdout=f)
|
system('git', 'show', ':' + name, stdout=f)
|
||||||
|
|
||||||
args = ['pep8']
|
checker_path = os.path.join(os.path.dirname(__file__),
|
||||||
|
'..', '..', '.venv', 'bin', 'pycodestyle')
|
||||||
|
checker_path = os.path.abspath(checker_path)
|
||||||
|
args = [checker_path]
|
||||||
if select_codes and ignore_codes:
|
if select_codes and ignore_codes:
|
||||||
print(u'Error: select and ignore codes are mutually exclusive')
|
print(u'Error: select and ignore codes are mutually exclusive')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
pep8==1.7.0
|
pycodestyle===2.5.0
|
||||||
coveralls==1.5.0
|
coveralls==1.5.0
|
||||||
pytest==3.5.0
|
pytest==3.5.0
|
||||||
pytest-cov==2.5.1
|
pytest-cov==2.5.1
|
||||||
|
|
|
@ -44,7 +44,7 @@ class TestTTS(unittest.TestCase):
|
||||||
"a lower pitch preferable?"
|
"a lower pitch preferable?"
|
||||||
sentence_bad_ssml = "<foo_invalid>" + sentence + \
|
sentence_bad_ssml = "<foo_invalid>" + sentence + \
|
||||||
"</foo_invalid end=whatever>"
|
"</foo_invalid end=whatever>"
|
||||||
sentence_extra_ssml = "<whispered>whisper tts<\whispered>"
|
sentence_extra_ssml = "<whispered>whisper tts<\\whispered>"
|
||||||
|
|
||||||
# test valid ssml
|
# test valid ssml
|
||||||
tts = TestTTS("en-US", {}, TestTTSValidator(None),
|
tts = TestTTS("en-US", {}, TestTTSValidator(None),
|
||||||
|
|
|
@ -353,5 +353,6 @@ class TestPronounceNumber(unittest.TestCase):
|
||||||
self.assertEqual(pronounce_number(float("-inf"),
|
self.assertEqual(pronounce_number(float("-inf"),
|
||||||
lang="it"), "meno infinito")
|
lang="it"), "meno infinito")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue