~ubuntu-branches/ubuntu/natty/duplicity/natty-updates

« back to all changes in this revision

Viewing changes to debian/duplicity-temp_error_recovery.patch

  • Committer: Bazaar Package Importer
  • Author(s): Steinar H. Gunderson
  • Date: 2006-11-11 13:32:07 UTC
  • mfrom: (2.1.3 feisty)
  • Revision ID: james.westby@ubuntu.com-20061111133207-9gizpeda242fwmtr
Tags: 0.4.2-10.1
Switch back to python 2.4, as python-central can apparently no longer cope
with 2.3, and 2.4 seems to work ok now; patch from Joey Hess.
(Closes: #396158)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
--- src/backends.py.orig        2003-08-10 04:17:21.000000000 +0200
2
 
+++ src/backends.py     2004-09-06 11:16:23.000000000 +0200
3
 
@@ -20,6 +20,7 @@
4
 
 
5
 
 import os, types, ftplib, tempfile
6
 
 import log, path, dup_temp, file_naming
7
 
+import time
8
 
 
9
 
 class BackendException(Exception): pass
10
 
 class ParsingException(Exception): pass
11
 
@@ -316,8 +317,10 @@
12
 
 
13
 
 class ftpBackend(Backend):
14
 
        """Connect to remote store using File Transfer Protocol"""
15
 
+       SLEEP = 10 # time in seconds before we try to reconnect on temporary errors
16
 
        def __init__(self, parsed_url):
17
 
                """Create a new ftp backend object, log in to host"""
18
 
+               self.parsed_url = parsed_url
19
 
                self.ftp = ftplib.FTP()
20
 
                if parsed_url.port is None: self.error_wrap('connect', parsed_url.host)
21
 
                else: self.error_wrap('connect', parsed_url.host, parsed_url.port)
22
 
@@ -330,6 +333,12 @@
23
 
        def error_wrap(self, command, *args):
24
 
                """Run self.ftp.command(*args), but raise BackendException on error"""
25
 
                try: return ftplib.FTP.__dict__[command](self.ftp, *args)
26
 
+               except ftplib.error_temp, e:
27
 
+                       log.Log("Temporary error '%s'. Trying to reconnect in %d seconds." %
28
 
+                                (str(e), self.SLEEP), 3)
29
 
+                       time.sleep(self.SLEEP)
30
 
+                       self.__init__(self.parsed_url)
31
 
+                       self.error_wrap(command, *args)
32
 
                except ftplib.all_errors, e: raise BackendException(e)
33
 
 
34
 
        def get_password(self):