# HG changeset patch # User Tuomo Valkonen # Date 1517235423 0 # Node ID 41bd7025532ffa66bdde4bb33ade4e52d1dd1228 # Parent 2a11fd29c1925015ee19f62274e14edc9140265d Fixes to borg output processing after testing on a Linux system diff -r 2a11fd29c192 -r 41bd7025532f borgend/instance.py --- a/borgend/instance.py Mon Jan 29 14:02:55 2018 +0000 +++ b/borgend/instance.py Mon Jan 29 14:17:03 2018 +0000 @@ -78,23 +78,27 @@ def read_result(self): stream=self.proc.stdout - line=stream.read(-1) + try: + line=stream.read(-1) + except Exception: + logger.exception('Borg stdout pipe read failed') + if line==b'': - logger.debug('Borg stdout pipe EOF?') + #logger.debug('Borg stdout pipe EOF?') return None try: - return json.loads(line) - except Exception as err: - logger.warning('JSON parse failed on: "%s"' % line) + return json.loads(line.decode()) + except Exception: + logger.exception('JSON parse failed on: %s' % str(line)) return None def read_log(self): stream=self.proc.stderr try: line=stream.readline() - except err: - logger.debug('Pipe read failed: %s' % str(err)) + except Exception: + logger.exception('Pipe stderr pipe read failed') return {'type': 'log_message', 'levelname': 'CRITICAL', @@ -103,18 +107,17 @@ 'message': err} if line==b'': - - logger.debug('Borg stderr pipe EOF?') - + #logger.debug('Borg stderr pipe EOF?') return None + try: - res=json.loads(line) + res=json.loads(line.decode()) if 'type' not in res: res['type']='UNKNOWN' return res except: - logger.debug('JSON parse failed on: "%s"' % str(line)) + logger.exception('JSON parse failed on: %s' % str(line)) errmsg=line for line in iter(stream.readline, b''):