From 23032beb950b16aa57556329cb4b557c6d2a26ee Mon Sep 17 00:00:00 2001 From: Felix Andersen Date: Fri, 29 Jul 2016 13:23:25 +0300 Subject: [PATCH 1/2] Retry 3 times on network failure --- git-ftp.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/git-ftp.py b/git-ftp.py index f4453ee..789d2c3 100755 --- a/git-ftp.py +++ b/git-ftp.py @@ -41,6 +41,7 @@ import logging import textwrap import fnmatch +import socket # Note about Tree.path/Blob.path: *real* Git trees and blobs don't # actually provide path information, but the git-python bindings, as a @@ -457,7 +458,23 @@ def upload_blob(blob, ftp, quiet=False): ftp.delete(blob.path) except ftplib.error_perm: pass - ftp.storbinary('STOR ' + blob.path, blob.data_stream) + + attempts = 0 + + while True: + try: + ftp.storbinary('STOR ' + blob.path, blob.data_stream) + break + except socket.error, e: + attempts += 1 + if attempts >= 3: + logging.warning('Failed to upload ' + blob.path) + raise + else: + logging.warning('Retrying ' + blob.path) + + + try: ftp.voidcmd('SITE CHMOD ' + format_mode(blob.mode) + ' ' + blob.path) except ftplib.error_perm: From ba8004349835c5910aee91aaadd1678642ecb691 Mon Sep 17 00:00:00 2001 From: Felix Andersen Date: Fri, 29 Jul 2016 13:23:45 +0300 Subject: [PATCH 2/2] A temporary .maintenance file to disable Wordpress sites --- git-ftp.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/git-ftp.py b/git-ftp.py index 789d2c3..56be73e 100755 --- a/git-ftp.py +++ b/git-ftp.py @@ -176,7 +176,9 @@ def main(): if oldtree.hexsha == tree.hexsha: logging.info('Nothing to do!') else: + ftp.storbinary('STOR .maintenance', cStringIO.StringIO('')) upload_diff(repo, oldtree, tree, ftp, [base], patterns) + ftp.delete('.maintenance') ftp.storbinary('STOR git-rev.txt', cStringIO.StringIO(commit.hexsha)) ftp.quit()