Browse Source

Open FTP session on the last moment possible

Used to open  fp = open(file_path,'wb') a few lines before it was needed. This shouldn't be too much of a problem but opening and closing it right after eachother keeps the session open for less time and there are less chances on failure.
pull/636/head
Alessio Gerace 10 years ago
committed by Dave Lasley
parent
commit
2181459fd4
  1. 2
      auto_backup/backup_scheduler.py

2
auto_backup/backup_scheduler.py

@ -152,7 +152,6 @@ password=passwordLogin,port=portHost)
#Create name for dumpfile. #Create name for dumpfile.
bkp_file='%s_%s.dump' % (time.strftime('%d_%m_%Y_%H_%M_%S'),rec.name) bkp_file='%s_%s.dump' % (time.strftime('%d_%m_%Y_%H_%M_%S'),rec.name)
file_path = os.path.join(rec.bkp_dir,bkp_file) file_path = os.path.join(rec.bkp_dir,bkp_file)
fp = open(file_path,'wb')
uri = 'http://' + rec.host + ':' + rec.port uri = 'http://' + rec.host + ':' + rec.port
conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/db') conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/db')
bkp='' bkp=''
@ -162,6 +161,7 @@ password=passwordLogin,port=portHost)
logger.notifyChannel('backup', netsvc.LOG_INFO, "Could'nt backup database %s. Bad database administrator password for server running at http://%s:%s" %(rec.name, rec.host, rec.port)) logger.notifyChannel('backup', netsvc.LOG_INFO, "Could'nt backup database %s. Bad database administrator password for server running at http://%s:%s" %(rec.name, rec.host, rec.port))
continue continue
bkp = base64.decodestring(bkp) bkp = base64.decodestring(bkp)
fp = open(file_path,'wb')
fp.write(bkp) fp.write(bkp)
fp.close() fp.close()
else: else:

Loading…
Cancel
Save