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