Merge lp:~mgorse/duplicity/0.8-series into lp:~duplicity-team/duplicity/0.8-series

Proposed by Mgorse
Status: Merged
Merged at revision: 1352
Proposed branch: lp:~mgorse/duplicity/0.8-series
Merge into: lp:~duplicity-team/duplicity/0.8-series
Diff against target: 247 lines (+36/-24)
6 files modified
bin/duplicity (+1/-1)
duplicity/backends/ncftpbackend.py (+12/-8)
duplicity/backends/rsyncbackend.py (+5/-3)
duplicity/backends/ssh_pexpect_backend.py (+11/-8)
duplicity/backends/sxbackend.py (+6/-3)
testing/unit/test_selection.py (+1/-1)
To merge this branch: bzr merge lp:~mgorse/duplicity/0.8-series
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+363752@code.launchpad.net

Commit message

More python 3 fixes

To post a comment you must log in.
lp:~mgorse/duplicity/0.8-series updated
1352. By Kenneth Loafman

 Merged in lp:~mgorse/duplicity/0.8-series
  - More python 3 fixes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/duplicity'
--- bin/duplicity 2018-11-29 19:00:15 +0000
+++ bin/duplicity 2019-02-27 22:47:02 +0000
@@ -1136,7 +1136,7 @@
1136 @rtype: void1136 @rtype: void
1137 @return: void1137 @return: void
1138 """1138 """
1139 suffixes = [u".g", u".gpg", u".z", u".gz", u".part"]1139 suffixes = [b".g", b".gpg", b".z", b".gz", b".part"]
11401140
1141 def get_metafiles(filelist):1141 def get_metafiles(filelist):
1142 u"""1142 u"""
11431143
=== modified file 'duplicity/backends/ncftpbackend.py'
--- duplicity/backends/ncftpbackend.py 2018-11-29 19:00:15 +0000
+++ duplicity/backends/ncftpbackend.py 2019-02-27 22:47:02 +0000
@@ -31,6 +31,7 @@
31from duplicity import globals31from duplicity import globals
32from duplicity import log32from duplicity import log
33from duplicity import tempdir33from duplicity import tempdir
34from duplicity import util
3435
3536
36class NCFTPBackend(duplicity.backend.Backend):37class NCFTPBackend(duplicity.backend.Backend):
@@ -86,28 +87,31 @@
86 else:87 else:
87 self.conn_opt = u'-F'88 self.conn_opt = u'-F'
8889
89 self.tempfile, self.tempname = tempdir.default().mkstemp()90 self.tempfd, self.tempname = tempdir.default().mkstemp()
90 os.write(self.tempfile, u"host %s\n" % self.parsed_url.hostname)91 self.tempfile = os.fdopen(self.tempfd, u"w")
91 os.write(self.tempfile, u"user %s\n" % self.parsed_url.username)92 self.tempfile.write(u"host %s\n" % self.parsed_url.hostname)
92 os.write(self.tempfile, u"pass %s\n" % self.password)93 self.tempfile.write(u"user %s\n" % self.parsed_url.username)
93 os.close(self.tempfile)94 self.tempfile.write(u"pass %s\n" % self.password)
95 self.tempfile.close()
94 self.flags = u"-f %s %s -t %s -o useCLNT=0,useHELP_SITE=0 " % \96 self.flags = u"-f %s %s -t %s -o useCLNT=0,useHELP_SITE=0 " % \
95 (self.tempname, self.conn_opt, globals.timeout)97 (self.tempname, self.conn_opt, globals.timeout)
96 if parsed_url.port is not None and parsed_url.port != 21:98 if parsed_url.port is not None and parsed_url.port != 21:
97 self.flags += u" -P '%s'" % (parsed_url.port)99 self.flags += u" -P '%s'" % (parsed_url.port)
98100
99 def _put(self, source_path, remote_filename):101 def _put(self, source_path, remote_filename):
102 remote_filename = util.fsdecode(remote_filename)
100 remote_path = os.path.join(urllib.parse.unquote(re.sub(u'^/', u'', self.parsed_url.path)),103 remote_path = os.path.join(urllib.parse.unquote(re.sub(u'^/', u'', self.parsed_url.path)),
101 remote_filename).rstrip()104 remote_filename).rstrip()
102 commandline = u"ncftpput %s -m -V -C '%s' '%s'" % \105 commandline = u"ncftpput %s -m -V -C '%s' '%s'" % \
103 (self.flags, source_path.name, remote_path)106 (self.flags, source_path.uc_name, remote_path)
104 self.subprocess_popen(commandline)107 self.subprocess_popen(commandline)
105108
106 def _get(self, remote_filename, local_path):109 def _get(self, remote_filename, local_path):
110 remote_filename = util.fsdecode(remote_filename)
107 remote_path = os.path.join(urllib.parse.unquote(re.sub(u'^/', u'', self.parsed_url.path)),111 remote_path = os.path.join(urllib.parse.unquote(re.sub(u'^/', u'', self.parsed_url.path)),
108 remote_filename).rstrip()112 remote_filename).rstrip()
109 commandline = u"ncftpget %s -V -C '%s' '%s' '%s'" % \113 commandline = u"ncftpget %s -V -C '%s' '%s' '%s'" % \
110 (self.flags, self.parsed_url.hostname, remote_path.lstrip(u'/'), local_path.name)114 (self.flags, self.parsed_url.hostname, remote_path.lstrip(u'/'), local_path.uc_name)
111 self.subprocess_popen(commandline)115 self.subprocess_popen(commandline)
112116
113 def _list(self):117 def _list(self):
@@ -115,7 +119,7 @@
115 commandline = u"ncftpls %s -l '%s'" % (self.flags, self.url_string)119 commandline = u"ncftpls %s -l '%s'" % (self.flags, self.url_string)
116 _, l, _ = self.subprocess_popen(commandline)120 _, l, _ = self.subprocess_popen(commandline)
117 # Look for our files as the last element of a long list line121 # Look for our files as the last element of a long list line
118 return [x.split()[-1] for x in l.split(u'\n') if x and not x.startswith(u"total ")]122 return [x.split()[-1] for x in l.split(b'\n') if x and not x.startswith(b"total ")]
119123
120 def _delete(self, filename):124 def _delete(self, filename):
121 commandline = u"ncftpls %s -l -X 'DELE %s' '%s'" % \125 commandline = u"ncftpls %s -l -X 'DELE %s' '%s'" % \
122126
=== modified file 'duplicity/backends/rsyncbackend.py'
--- duplicity/backends/rsyncbackend.py 2018-11-29 19:00:15 +0000
+++ duplicity/backends/rsyncbackend.py 2019-02-27 22:47:02 +0000
@@ -109,13 +109,15 @@
109 u"" % self.munge_password(url))109 u"" % self.munge_password(url))
110110
111 def _put(self, source_path, remote_filename):111 def _put(self, source_path, remote_filename):
112 remote_filename = util.fsdecode(remote_filename)
112 remote_path = os.path.join(self.url_string, remote_filename)113 remote_path = os.path.join(self.url_string, remote_filename)
113 commandline = u"%s %s %s" % (self.cmd, source_path.name, remote_path)114 commandline = u"%s %s %s" % (self.cmd, source_path.uc_name, remote_path)
114 self.subprocess_popen(commandline)115 self.subprocess_popen(commandline)
115116
116 def _get(self, remote_filename, local_path):117 def _get(self, remote_filename, local_path):
118 remote_filename = util.fsdecode(remote_filename)
117 remote_path = os.path.join(self.url_string, remote_filename)119 remote_path = os.path.join(self.url_string, remote_filename)
118 commandline = u"%s %s %s" % (self.cmd, remote_path, local_path.name)120 commandline = u"%s %s %s" % (self.cmd, remote_path, local_path.uc_name)
119 self.subprocess_popen(commandline)121 self.subprocess_popen(commandline)
120122
121 def _list(self):123 def _list(self):
@@ -127,7 +129,7 @@
127 return None129 return None
128 commandline = u"%s %s" % (self.cmd, self.url_string)130 commandline = u"%s %s" % (self.cmd, self.url_string)
129 result, stdout, stderr = self.subprocess_popen(commandline)131 result, stdout, stderr = self.subprocess_popen(commandline)
130 return [x for x in map(split, stdout.split(u'\n')) if x]132 return [x for x in map(split, stdout.split(b'\n')) if x]
131133
132 def _delete_list(self, filename_list):134 def _delete_list(self, filename_list):
133 delete_list = filename_list135 delete_list = filename_list
134136
=== modified file 'duplicity/backends/ssh_pexpect_backend.py'
--- duplicity/backends/ssh_pexpect_backend.py 2019-02-25 16:30:59 +0000
+++ duplicity/backends/ssh_pexpect_backend.py 2019-02-27 22:47:02 +0000
@@ -38,10 +38,9 @@
38import duplicity.backend38import duplicity.backend
39from duplicity import globals39from duplicity import globals
40from duplicity import log40from duplicity import log
41from duplicity import util
41from duplicity.errors import BackendException42from duplicity.errors import BackendException
4243
43global pexpect
44
4544
46class SSHPExpectBackend(duplicity.backend.Backend):45class SSHPExpectBackend(duplicity.backend.Backend):
47 u"""This backend copies files using scp. List not supported. Filenames46 u"""This backend copies files using scp. List not supported. Filenames
@@ -52,6 +51,8 @@
5251
53 try:52 try:
54 import pexpect53 import pexpect
54 global pexpect
55
55 except ImportError:56 except ImportError:
56 raise57 raise
5758
@@ -172,7 +173,7 @@
172 u"open(.*): Failure"]173 u"open(.*): Failure"]
173 max_response_len = max([len(p) for p in responses[1:]])174 max_response_len = max([len(p) for p in responses[1:]])
174 log.Info(u"Running '%s'" % (commandline))175 log.Info(u"Running '%s'" % (commandline))
175 child = pexpect.spawn(commandline, timeout=None, maxread=maxread)176 child = pexpect.spawn(commandline, timeout=None, maxread=maxread, encoding=globals.fsencoding)
176 cmdloc = 0177 cmdloc = 0
177 passprompt = 0178 passprompt = 0
178 while 1:179 while 1:
@@ -228,6 +229,7 @@
228 raise BackendException(u"Error running '%s': %s" % (commandline, msg))229 raise BackendException(u"Error running '%s': %s" % (commandline, msg))
229230
230 def _put(self, source_path, remote_filename):231 def _put(self, source_path, remote_filename):
232 remote_filename = util.fsdecode(remote_filename)
231 if self.use_scp:233 if self.use_scp:
232 self.put_scp(source_path, remote_filename)234 self.put_scp(source_path, remote_filename)
233 else:235 else:
@@ -235,7 +237,7 @@
235237
236 def put_sftp(self, source_path, remote_filename):238 def put_sftp(self, source_path, remote_filename):
237 commands = [u"put \"%s\" \"%s.%s.part\"" %239 commands = [u"put \"%s\" \"%s.%s.part\"" %
238 (source_path.name, self.remote_prefix, remote_filename),240 (source_path.uc_name, self.remote_prefix, remote_filename),
239 u"rename \"%s.%s.part\" \"%s%s\"" %241 u"rename \"%s.%s.part\" \"%s%s\"" %
240 (self.remote_prefix, remote_filename, self.remote_prefix, remote_filename)]242 (self.remote_prefix, remote_filename, self.remote_prefix, remote_filename)]
241 commandline = (u"%s %s %s" % (self.sftp_command,243 commandline = (u"%s %s %s" % (self.sftp_command,
@@ -245,11 +247,12 @@
245247
246 def put_scp(self, source_path, remote_filename):248 def put_scp(self, source_path, remote_filename):
247 commandline = u"%s %s %s %s:%s%s" % \249 commandline = u"%s %s %s %s:%s%s" % \
248 (self.scp_command, globals.ssh_options, source_path.name, self.host_string,250 (self.scp_command, globals.ssh_options, source_path.uc_name, self.host_string,
249 self.remote_prefix, remote_filename)251 self.remote_prefix, remote_filename)
250 self.run_scp_command(commandline)252 self.run_scp_command(commandline)
251253
252 def _get(self, remote_filename, local_path):254 def _get(self, remote_filename, local_path):
255 remote_filename = util.fsdecode(remote_filename)
253 if self.use_scp:256 if self.use_scp:
254 self.get_scp(remote_filename, local_path)257 self.get_scp(remote_filename, local_path)
255 else:258 else:
@@ -257,7 +260,7 @@
257260
258 def get_sftp(self, remote_filename, local_path):261 def get_sftp(self, remote_filename, local_path):
259 commands = [u"get \"%s%s\" \"%s\"" %262 commands = [u"get \"%s%s\" \"%s\"" %
260 (self.remote_prefix, remote_filename, local_path.name)]263 (self.remote_prefix, remote_filename, local_path.uc_name)]
261 commandline = (u"%s %s %s" % (self.sftp_command,264 commandline = (u"%s %s %s" % (self.sftp_command,
262 globals.ssh_options,265 globals.ssh_options,
263 self.host_string))266 self.host_string))
@@ -266,7 +269,7 @@
266 def get_scp(self, remote_filename, local_path):269 def get_scp(self, remote_filename, local_path):
267 commandline = u"%s %s %s:%s%s %s" % \270 commandline = u"%s %s %s:%s%s %s" % \
268 (self.scp_command, globals.ssh_options, self.host_string, self.remote_prefix,271 (self.scp_command, globals.ssh_options, self.host_string, self.remote_prefix,
269 remote_filename, local_path.name)272 remote_filename, local_path.uc_name)
270 self.run_scp_command(commandline)273 self.run_scp_command(commandline)
271274
272 def _list(self):275 def _list(self):
@@ -289,7 +292,7 @@
289292
290 l = self.run_sftp_command(commandline, commands).split(u'\n')[1:]293 l = self.run_sftp_command(commandline, commands).split(u'\n')[1:]
291294
292 return [x for x in map(string.strip, l) if x]295 return [x for x in map(u"".__class__.strip, l) if x]
293296
294 def _delete(self, filename):297 def _delete(self, filename):
295 commands = [u"cd \"%s\"" % (self.remote_dir,)]298 commands = [u"cd \"%s\"" % (self.remote_dir,)]
296299
=== modified file 'duplicity/backends/sxbackend.py'
--- duplicity/backends/sxbackend.py 2018-07-23 14:55:39 +0000
+++ duplicity/backends/sxbackend.py 2019-02-27 22:47:02 +0000
@@ -20,6 +20,7 @@
2020
21import os.path21import os.path
22import duplicity.backend22import duplicity.backend
23import duplicity.util
2324
2425
25class SXBackend(duplicity.backend.Backend):26class SXBackend(duplicity.backend.Backend):
@@ -29,13 +30,15 @@
29 self.url_string = parsed_url.url_string30 self.url_string = parsed_url.url_string
3031
31 def _put(self, source_path, remote_filename):32 def _put(self, source_path, remote_filename):
33 remote_filename = util.fsdecode(remote_filename)
32 remote_path = os.path.join(self.url_string, remote_filename)34 remote_path = os.path.join(self.url_string, remote_filename)
33 commandline = u"sxcp {0} {1}".format(source_path.name, remote_path)35 commandline = u"sxcp {0} {1}".format(source_path.uc_name, remote_path)
34 self.subprocess_popen(commandline)36 self.subprocess_popen(commandline)
3537
36 def _get(self, remote_filename, local_path):38 def _get(self, remote_filename, local_path):
39 remote_filename = util.fsdecode(remote_filename)
37 remote_path = os.path.join(self.url_string, remote_filename)40 remote_path = os.path.join(self.url_string, remote_filename)
38 commandline = u"sxcp {0} {1}".format(remote_path, local_path.name)41 commandline = u"sxcp {0} {1}".format(remote_path, local_path.uc_name)
39 self.subprocess_popen(commandline)42 self.subprocess_popen(commandline)
4043
41 def _list(self):44 def _list(self):
@@ -43,7 +46,7 @@
43 commandline = u"sxls {0}".format(self.url_string)46 commandline = u"sxls {0}".format(self.url_string)
44 _, l, _ = self.subprocess_popen(commandline)47 _, l, _ = self.subprocess_popen(commandline)
45 # Look for our files as the last element of a long list line48 # Look for our files as the last element of a long list line
46 return [x[x.rindex(u'/') + 1:].split()[-1] for x in l.split(u'\n') if x and not x.startswith(u"total ")]49 return [x[x.rindex(u'/') + 1:].split()[-1] for x in l.split(b'\n') if x and not x.startswith(b"total ")]
4750
48 def _delete(self, filename):51 def _delete(self, filename):
49 commandline = u"sxrm {0}/{1}".format(self.url_string, filename)52 commandline = u"sxrm {0}/{1}".format(self.url_string, filename)
5053
=== modified file 'testing/unit/test_selection.py'
--- testing/unit/test_selection.py 2018-11-29 19:00:15 +0000
+++ testing/unit/test_selection.py 2019-02-27 22:47:02 +0000
@@ -45,7 +45,7 @@
4545
46 def testRegexp(self):46 def testRegexp(self):
47 u"""Test regular expression selection func"""47 u"""Test regular expression selection func"""
48 sf1 = self.Select.regexp_get_sf(u".*\.py", 1)48 sf1 = self.Select.regexp_get_sf(u".*\\.py", 1)
49 assert sf1(self.makeext(u"1.py")) == 149 assert sf1(self.makeext(u"1.py")) == 1
50 assert sf1(self.makeext(u"usr/foo.py")) == 150 assert sf1(self.makeext(u"usr/foo.py")) == 1
51 assert sf1(self.root.append(u"1.doc")) is None51 assert sf1(self.root.append(u"1.doc")) is None

Subscribers

People subscribed via source and target branches