From 8aa63dbdd4876334ff06cf3e4065533074d3a9fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yohann=C3=A8s=20ALEMU?= Date: Thu, 3 Jan 2019 15:47:22 +0100 Subject: [PATCH] bug with written_files_count in backup rsync+ssh module --- libtisbackup/backup_rsync.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/libtisbackup/backup_rsync.py b/libtisbackup/backup_rsync.py index 860175b..43723ec 100644 --- a/libtisbackup/backup_rsync.py +++ b/libtisbackup/backup_rsync.py @@ -170,15 +170,20 @@ class backup_rsync(backup_generic): log = monitor_stdout(process,ondata,self) + reg_total_files = re.compile('Number of files: (?P\d+)') + reg_transferred_files = re.compile('Number of .*files transferred: (?P\d+)') for l in log.splitlines(): - if l.startswith('Number of files:'): - stats['total_files_count'] += int(re.sub("[^0-9]", "", l.split(':')[1])) - if l.startswith('Number of files transferred:'): - stats['written_files_count'] += int(re.sub("[^0-9]", "", l.split(':')[1])) - if l.startswith('Total file size:'): - stats['total_bytes'] += int(re.sub("[^0-9]", "", l.split(':')[1].split()[0])) - if l.startswith('Total transferred file size:'): - stats['written_bytes'] += int(re.sub("[^0-9]", "", l.split(':')[1].split()[0])) + line = l.replace(',','') + m = reg_total_files.match(line) + if m: + stats['total_files_count'] += int(m.groupdict()['file']) + m = reg_transferred_files.match(line) + if m: + stats['written_files_count'] += int(m.groupdict()['file']) + if line.startswith('Total file size:'): + stats['total_bytes'] += int(line.split(':')[1].split()[0]) + if line.startswith('Total transferred file size:'): + stats['written_bytes'] += int(line.split(':')[1].split()[0]) returncode = process.returncode ## deal with exit code 24 (file vanished)