89
94
return _backends[pu.scheme](pu)
96
_urlparser_initialized = False
97
_urlparser_initialized_lock = dup_threading.threading_module().Lock()
99
def _ensure_urlparser_initialized():
101
Ensure that the appropriate clobbering of variables in the
102
urlparser module has been done. In the future, the need for this
103
clobbering to begin with should preferably be eliminated.
106
global _urlparser_initialized
108
if not _urlparser_initialized:
109
# These URL schemes have a backend with a notion of an RFC "network location".
110
# The 'file' and 's3+http' schemes should not be in this list.
111
# 'http' and 'https' are not actually used for duplicity backend urls, but are needed
112
# in order to properly support urls returned from some webdav servers. adding them here
113
# is a hack. we should instead not stomp on the url parsing module to begin with.
115
# todo: eliminate the need for backend specific hacking here completely.
116
urlparser.uses_netloc = [ 'ftp', 'hsi', 'rsync', 's3', 'scp', 'ssh', 'webdav', 'webdavs', 'http', 'https', 'imap', 'imaps' ]
118
# Do not transform or otherwise parse the URL path component.
119
urlparser.uses_query = []
120
urlparser.uses_fragm = []
122
_urlparser_initialized = True
124
dup_threading.with_lock(_urlparser_initialized_lock,
91
127
def ParsedUrl(url_string):
92
# These URL schemes have a backend with a notion of an RFC "network location".
93
# The 'file' and 's3+http' schemes should not be in this list.
94
# 'http' and 'https' are not actually used for duplicity backend urls, but are needed
95
# in order to properly support urls returned from some webdav servers. adding them here
96
# is a hack. we should instead not stomp on the url parsing module to begin with.
98
# todo: eliminate the need for backend specific hacking here completely.
99
urlparser.uses_netloc = [ 'ftp', 'hsi', 'rsync', 's3', 'scp', 'ssh', 'webdav', 'webdavs', 'http', 'https', 'gmail' ]
101
# Do not transform or otherwise parse the URL path component.
102
urlparser.uses_query = []
103
urlparser.uses_fragment = []
129
Parse the given URL as a duplicity backend URL.
131
@return A parsed URL of the same form as that of the standard
134
@raise InvalidBackendURL
136
_ensure_urlparser_initialized()
105
138
pu = urlparser.urlparse(url_string)
211
244
raise a BackendException.
213
246
private = self.munge_password(commandline)
214
log.Log("Running '%s'" % private, 5)
247
log.Log(_("Running '%s'") % private, 5)
215
248
if os.system(commandline):
216
249
raise BackendException("Error running '%s'" % private)
223
256
private = self.munge_password(commandline)
224
257
for n in range(1, globals.num_retries+1):
225
log.Log("Running '%s' (attempt #%d)" % (private, n), 5)
258
log.Log(gettext.ngettext("Running '%s' (attempt #%d)",
259
"Running '%s' (attempt #%d)", n) %
226
261
if not os.system(commandline):
228
log.Log("Running '%s' failed (attempt #%d)" % (private, n), 1)
263
log.Log(gettext.ngettext("Running '%s' failed (attempt #%d)",
264
"Running '%s' failed (attempt #%d)", n) %
230
log.Log("Giving up trying to execute '%s' after %d attempts" % (private, globals.num_retries), 1)
267
log.Log(gettext.ngettext("Giving up trying to execute '%s' after %d attempt",
268
"Giving up trying to execute '%s' after %d attempts",
269
globals.num_retries) % (private, globals.num_retries),
231
271
raise BackendException("Error running '%s'" % private)
233
273
def popen(self, commandline):
251
291
private = self.munge_password(commandline)
252
292
for n in range(1, globals.num_retries+1):
253
log.Log("Reading results of '%s'" % private, 5)
293
log.Log(_("Reading results of '%s'") % private, 5)
254
294
fout = os.popen(commandline)
255
295
results = fout.read()
256
296
result_status = fout.close()
260
300
# This squelches the "file not found" result fromm ncftpls when
261
301
# the ftp backend looks for a collection that does not exist.
263
log.Log("Running '%s' failed (attempt #%d)" % (private, n), 1)
303
log.Log(gettext.ngettext("Running '%s' failed (attempt #%d)",
304
"Running '%s' failed (attempt #%d)", n) %
265
log.Log("Giving up trying to execute '%s' after %d attempts" % (private, globals.num_retries), 1)
307
log.Log(gettext.ngettext("Giving up trying to execute '%s' after %d attempt",
308
"Giving up trying to execute '%s' after %d attempts",
309
globals.num_retries) % (private, globals.num_retries),
266
311
raise BackendException("Error running '%s'" % private)
268
313
def get_fileobj_read(self, filename, parseresults = None):