whoops, did that in the wrong place

This commit is contained in:
brent s 2019-06-02 03:49:00 -04:00
parent 6d6d1e20b1
commit e4b7bf85e9

View File

@ -522,39 +522,39 @@ class Backup(object):
repo['name'], repo['name'],
('::{0}'.format(self.args['archive']) if self.args['archive'] ('::{0}'.format(self.args['archive']) if self.args['archive']
else ''))) else '')))
if not self.args['dryrun']: if not self.args['dryrun']:
_out = subprocess.run(_cmd, _out = subprocess.run(_cmd,
env = _loc_env, env = _loc_env,
stdout = subprocess.PIPE, stdout = subprocess.PIPE,
stderr = subprocess.PIPE) stderr = subprocess.PIPE)
_stdout = '\n'.join([i.strip() for i in _out.stdout.decode('utf-8').splitlines()]) _stdout = '\n'.join([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 _returncode = _out.returncode
if self.args['archive']:
output[server][repo['name']] = [json.loads(i) for i in _stdout.splitlines()]
else:
output[repo['name']] = json.loads(_stdout)['archives']
self.logger.debug('[{0}]: (RESULT) {1}'.format(repo['name'],
'\n'.join(_stdout)))
self.logger.debug('[{0}]: STDERR: ({2}) ({1})'.format(repo['name'],
_stderr,
' '.join(_cmd)))
if _stderr != '' and self.cron and _returncode != 0:
self.logger.warning('Command {0} failed: {1}'.format(' '.join(_cmd),
_stderr))
if not self.args['archive']:
if self.args['numlimit'] > 0:
try: try:
if self.args['archive']:
output[server][repo['name']] = [json.loads(i) for i in _stdout.splitlines()]
else:
output[server][repo['name']] = json.loads(_stdout)['archives']
except json.decoder.JSONDecodeError:
output[server][repo['name']] = []
self.logger.debug('[{0}]: (RESULT) {1}'.format(repo['name'],
'\n'.join(_stdout)))
self.logger.debug('[{0}]: STDERR: ({2}) ({1})'.format(repo['name'],
_stderr,
' '.join(_cmd)))
if _stderr != '' and self.cron and _returncode != 0:
self.logger.warning('Command {0} failed: {1}'.format(' '.join(_cmd),
_stderr))
if not self.args['archive']:
if self.args['numlimit'] > 0:
if self.args['old']: if self.args['old']:
output[server][repo['name']] = output[server][repo['name']][:self.args['numlimit']] output[server][repo['name']] = output[server][repo['name']][:self.args['numlimit']]
else: else:
output[server][repo['name']] = list( output[server][repo['name']] = list(
reversed( reversed(
output[server][repo['name']]))[:self.args['numlimit']] output[server][repo['name']]))[:self.args['numlimit']]
except KeyError: if self.args['invert']:
print('(No archives/snapshots found)') output[server][repo['name']] = reversed(output[server][repo['name']])
if self.args['invert']:
output[server][repo['name']] = reversed(output[server][repo['name']])
self.logger.debug('END: lister') self.logger.debug('END: lister')
return(output) return(output)