diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-12-30 15:50:49 +0100 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2014-12-30 15:50:49 +0100 |
| commit | bbe37376761a3a36d903e9a60d689034a989cd51 (patch) | |
| tree | 51969d7ec33c450ea1ed78155d88462ad4573be3 /client | |
| parent | 277c97091a6c837f03e694b42b7a818fdca2cf08 (diff) | |
| download | jasper-client-bbe37376761a3a36d903e9a60d689034a989cd51.tar.gz jasper-client-bbe37376761a3a36d903e9a60d689034a989cd51.zip | |
Better error handling in g2p module
Diffstat (limited to 'client')
| -rw-r--r-- | client/g2p.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/client/g2p.py b/client/g2p.py index c40e3a2..7b80226 100644 --- a/client/g2p.py +++ b/client/g2p.py @@ -39,19 +39,22 @@ class PhonetisaurusG2P(object): proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdoutdata, stderrdata = proc.communicate() - if proc.returncode != 0: - logger.warning("Command '%s' return with exit status %d", - ' '.join(cmd), proc.returncode) except OSError: logger.error("Error occured while executing command '%s'", ' '.join(cmd), exc_info=True) - stdoutdata, stderrdata = None, None - if stderrdata is not None: + raise + + if stderrdata: for line in stderrdata.splitlines(): message = line.strip() if message: logger.debug(message) + if proc.returncode != 0: + logger.error("Command '%s' return with exit status %d", + ' '.join(cmd), proc.returncode) + raise OSError("Command execution failed") + result = {} if stdoutdata is not None: for word, precision, pronounc in cls.PATTERN.findall(stdoutdata): |
