some tweaks: easier retry, better maths

This commit is contained in:
Ryan Tucker 2009-12-30 09:35:15 -05:00
parent f942a2763f
commit 5fe7494f15

View file

@ -125,7 +125,7 @@ class SlowFile:
logger.debug('Target %i bytes/second (%i kilobits/second), delay factor %.2f, block len %i' % (targetspeed, targetspeed*8/1024, self.delayfactor, len)) logger.debug('Target %i bytes/second (%i kilobits/second), delay factor %.2f, block len %i' % (targetspeed, targetspeed*8/1024, self.delayfactor, len))
try: try:
newkbits = int(open('/home/rtucker/Dropbox/Semaphores/BackupPC_archiveHost_s3.maxspeed', 'r').readline()) newkbits = int(open('/home/rtucker/Dropbox/Semaphores/BackupPC_archiveHost_s3.maxspeed', 'r').readline())
newspeed = (newkbits/float(8))*1024 newspeed = int((newkbits/float(8))*1024)
if newspeed != self.speed: if newspeed != self.speed:
self.delayfactor = 1 self.delayfactor = 1
self.speed = newspeed self.speed = newspeed
@ -259,6 +259,10 @@ else:
fileglob = '%s/%s.%i.tar' % (outLoc, host, bkupNum) fileglob = '%s/%s.%i.tar' % (outLoc, host, bkupNum)
cmd += '> %s' % fileglob cmd += '> %s' % fileglob
# is there already evidence of this having been done before?
if glob.glob(fileglob):
logging.info('Evidence of failed execution run prior! Finishing it.')
else:
logging.debug('Executing %s' % cmd) logging.debug('Executing %s' % cmd)
returncode = os.system(cmd) returncode = os.system(cmd)
@ -270,9 +274,10 @@ if returncode != 0:
logging.info('Beginning post-processing of %i files from %s #%i' % (len(glob.glob(fileglob)), host, bkupNum)) logging.info('Beginning post-processing of %i files from %s #%i' % (len(glob.glob(fileglob)), host, bkupNum))
for i in sorted(glob.glob(fileglob)): for i in sorted(glob.glob(fileglob)):
if secrets.gpgsymmetrickey: if secrets.gpgsymmetrickey and not i.endswith('.gpg'):
sendfile = encrypt_file(i, secrets.gpgsymmetrickey, compPath) sendfile = encrypt_file(i, secrets.gpgsymmetrickey, compPath)
else: else:
# either encryption is off, or the file is already encrypted
sendfile = i sendfile = i
retry_count = 0 retry_count = 0