way better rsync logging

This commit is contained in:
brent s. 2020-06-18 13:01:25 -04:00
parent ac1886e46b
commit 0ff9af4c48
Signed by: bts
GPG Key ID: 8C004C2F93481F6B
2 changed files with 31 additions and 4 deletions

View File

@ -10,6 +10,7 @@ sys.path.append(os.path.abspath(os.path.join(_cur_dir, '..')))
import constants import constants
# import logger # import logger
from . import _base from . import _base
from . import rsync_returns




_logger = logging.getLogger() _logger = logging.getLogger()
@ -70,9 +71,11 @@ class RSync(_base.BaseFetcher):
if stdout != '': if stdout != '':
_logger.debug('STDOUT: {0}'.format(stdout)) _logger.debug('STDOUT: {0}'.format(stdout))
if stderr != '' or cmd.returncode != 0: 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)) _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) return(None)


def fetch_content(self, remote_filepath): def fetch_content(self, remote_filepath):
@ -91,9 +94,11 @@ class RSync(_base.BaseFetcher):
if stdout != '': if stdout != '':
_logger.debug('STDOUT: {0}'.format(stdout)) _logger.debug('STDOUT: {0}'.format(stdout))
if stderr != '' or cmd.returncode != 0: 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)) _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: with open(tf, 'rb') as fh:
raw_content = fh.read() raw_content = fh.read()
os.remove(tf) os.remove(tf)

View File

@ -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'}