From 0ff9af4c486e1af9c31f9dc0e1da4a387d86cdd2 Mon Sep 17 00:00:00 2001 From: brent s Date: Thu, 18 Jun 2020 13:01:25 -0400 Subject: [PATCH] way better rsync logging --- repomirror/fetcher/rsync.py | 13 +++++++++---- repomirror/fetcher/rsync_returns.py | 22 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 repomirror/fetcher/rsync_returns.py diff --git a/repomirror/fetcher/rsync.py b/repomirror/fetcher/rsync.py index dd87cc1..1a0e861 100644 --- a/repomirror/fetcher/rsync.py +++ b/repomirror/fetcher/rsync.py @@ -10,6 +10,7 @@ sys.path.append(os.path.abspath(os.path.join(_cur_dir, '..'))) import constants # import logger from . import _base +from . import rsync_returns _logger = logging.getLogger() @@ -70,9 +71,11 @@ class RSync(_base.BaseFetcher): if stdout != '': _logger.debug('STDOUT: {0}'.format(stdout)) if stderr != '' or cmd.returncode != 0: - _logger.error('Rsync to {0}:{1} returned exit status {2}'.format(self.domain, self.port, cmd.returncode)) + rtrn = cmd.returncode + err = rsync_returns.returns[rtrn] + _logger.error(('Rsync to {0}:{1} returned exit status {2}: {3}').format(self.domain, self.port, rtrn, err)) _logger.debug('STDERR: {0}'.format(stderr)) - warnings.warn('Rsync process returned non-zero ({0}) for {1}'.format(cmd.returncode, ' '.join(cmd_str))) + warnings.warn('Rsync process returned non-zero {0} ({1}) for {2}'.format(rtrn, err, ' '.join(cmd_str))) return(None) def fetch_content(self, remote_filepath): @@ -91,9 +94,11 @@ class RSync(_base.BaseFetcher): if stdout != '': _logger.debug('STDOUT: {0}'.format(stdout)) if stderr != '' or cmd.returncode != 0: - _logger.error('Rsync to {0}:{1} returned exit status {2}'.format(self.domain, self.port, cmd.returncode)) + rtrn = cmd.returncode + err = rsync_returns.returns[rtrn] + _logger.error(('Rsync to {0}:{1} returned exit status {2}: {3}').format(self.domain, self.port, rtrn, err)) _logger.debug('STDERR: {0}'.format(stderr)) - warnings.warn('Rsync process returned non-zero ({0}) for {1}'.format(cmd.returncode, ' '.join(cmd_str))) + warnings.warn('Rsync process returned non-zero {0} ({1}) for {2}'.format(rtrn, err, ' '.join(cmd_str))) with open(tf, 'rb') as fh: raw_content = fh.read() os.remove(tf) diff --git a/repomirror/fetcher/rsync_returns.py b/repomirror/fetcher/rsync_returns.py new file mode 100644 index 0000000..cc99616 --- /dev/null +++ b/repomirror/fetcher/rsync_returns.py @@ -0,0 +1,22 @@ +returns = {0: 'Success', + 1: 'Syntax or usage error', + 2: 'Protocol incompatibility', + 3: 'Errors selecting input/output files, dirs', + 4: ('Requested action not supported: ' + 'an attempt was made to manipulate 64-bit files on a platform that cannot support them; ' + 'or an option was specified that is supported by the client and not by the server.'), + 5: 'Error starting client-server protocol', + 6: 'Daemon unable to append to log-file', + 10: 'Error in socket I/O', + 11: 'Error in file I/O', + 12: 'Error in rsync protocol data stream', + 13: 'Errors with program diagnostics', + 14: 'Error in IPC code', + 20: 'Received SIGUSR1 or SIGINT', + 21: 'Some error returned by waitpid()', + 22: 'Error allocating core memory buffers', + 23: 'Partial transfer due to error', + 24: 'Partial transfer due to vanished source files', + 25: 'The --max-delete limit stopped deletions', + 30: 'Timeout in data send/receive', + 35: 'Timeout waiting for daemon connection'}