modify for better error detection since some programs write to stderr for non-error output
This commit is contained in:
parent
5ab91b01f7
commit
ae118ee9ed
@ -103,12 +103,16 @@ class Backup(object):
|
|||||||
if self.args['dryrun']:
|
if self.args['dryrun']:
|
||||||
return() # no-op
|
return() # no-op
|
||||||
if stdoutfh:
|
if stdoutfh:
|
||||||
_err = subprocess.run(cmd, stdout = stdoutfh, stderr = subprocess.PIPE).stderr.decode('utf-8').strip()
|
_cmd = subprocess.run(cmd, stdout = stdoutfh, stderr = subprocess.PIPE)
|
||||||
else:
|
else:
|
||||||
with open(os.devnull, 'w') as DEVNULL:
|
_cmd = subprocess.run(cmd,
|
||||||
_err = subprocess.run(cmd, stdout = DEVNULL, stderr = subprocess.PIPE).stderr.decode('utf-8').strip()
|
stdout = subprocess.PIPE,
|
||||||
if _err != '':
|
stderr = subprocess.PIPE)
|
||||||
self.logger.error('STDERR: {0} ({1})'.format(_err.stderr.decode('utf-8'),
|
_out = _cmd.stdout.decode('utf-8').strip()
|
||||||
|
_err = _cmd.stderr.decode('utf-8').strip()
|
||||||
|
_returncode = _cmd.returncode
|
||||||
|
if _returncode != 0:
|
||||||
|
self.logger.error('STDERR: ({1})\n{0}'.format(_err,
|
||||||
' '.join(cmd)))
|
' '.join(cmd)))
|
||||||
return()
|
return()
|
||||||
|
|
||||||
@ -351,11 +355,12 @@ class Backup(object):
|
|||||||
stderr = subprocess.PIPE)
|
stderr = subprocess.PIPE)
|
||||||
_stdout = [i.strip() for i in _out.stdout.decode('utf-8').splitlines()]
|
_stdout = [i.strip() for i in _out.stdout.decode('utf-8').splitlines()]
|
||||||
_stderr = _out.stderr.decode('utf-8').strip()
|
_stderr = _out.stderr.decode('utf-8').strip()
|
||||||
|
_returncode = _out.returncode
|
||||||
output[r] = _stdout
|
output[r] = _stdout
|
||||||
self.logger.debug('[{0}]: (RESULT) {1}'.format(r,
|
self.logger.debug('[{0}]: (RESULT) {1}'.format(r,
|
||||||
'\n'.join(_stdout)))
|
'\n'.join(_stdout)))
|
||||||
if _stderr != '':
|
if _returncode != 0:
|
||||||
self.logger.error('[{0}]: STDERR: {1} ({2})'.format(r,
|
self.logger.error('[{0}]: STDERR: ({2}) ({1})'.format(r,
|
||||||
_stderr,
|
_stderr,
|
||||||
' '.join(_cmd)))
|
' '.join(_cmd)))
|
||||||
del(_env['BORG_PASSPHRASE'])
|
del(_env['BORG_PASSPHRASE'])
|
||||||
|
Loading…
Reference in New Issue
Block a user