Merge lp:~mgorse/duplicity/0.8-series into lp:~duplicity-team/duplicity/0.8-series
- 0.8-series
- Merge into 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 | ||||
Related bugs: |
|
||||
Related blueprints: |
Python 3 Support
(High)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
duplicity-team | Pending | ||
Review via email: mp+363752@code.launchpad.net |
Commit message
More python 3 fixes
Description of the change
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
1 | === modified file 'bin/duplicity' | |||
2 | --- bin/duplicity 2018-11-29 19:00:15 +0000 | |||
3 | +++ bin/duplicity 2019-02-27 22:47:02 +0000 | |||
4 | @@ -1136,7 +1136,7 @@ | |||
5 | 1136 | @rtype: void | 1136 | @rtype: void |
6 | 1137 | @return: void | 1137 | @return: void |
7 | 1138 | """ | 1138 | """ |
9 | 1139 | suffixes = [u".g", u".gpg", u".z", u".gz", u".part"] | 1139 | suffixes = [b".g", b".gpg", b".z", b".gz", b".part"] |
10 | 1140 | 1140 | ||
11 | 1141 | def get_metafiles(filelist): | 1141 | def get_metafiles(filelist): |
12 | 1142 | u""" | 1142 | u""" |
13 | 1143 | 1143 | ||
14 | === modified file 'duplicity/backends/ncftpbackend.py' | |||
15 | --- duplicity/backends/ncftpbackend.py 2018-11-29 19:00:15 +0000 | |||
16 | +++ duplicity/backends/ncftpbackend.py 2019-02-27 22:47:02 +0000 | |||
17 | @@ -31,6 +31,7 @@ | |||
18 | 31 | from duplicity import globals | 31 | from duplicity import globals |
19 | 32 | from duplicity import log | 32 | from duplicity import log |
20 | 33 | from duplicity import tempdir | 33 | from duplicity import tempdir |
21 | 34 | from duplicity import util | ||
22 | 34 | 35 | ||
23 | 35 | 36 | ||
24 | 36 | class NCFTPBackend(duplicity.backend.Backend): | 37 | class NCFTPBackend(duplicity.backend.Backend): |
25 | @@ -86,28 +87,31 @@ | |||
26 | 86 | else: | 87 | else: |
27 | 87 | self.conn_opt = u'-F' | 88 | self.conn_opt = u'-F' |
28 | 88 | 89 | ||
34 | 89 | self.tempfile, self.tempname = tempdir.default().mkstemp() | 90 | self.tempfd, self.tempname = tempdir.default().mkstemp() |
35 | 90 | os.write(self.tempfile, u"host %s\n" % self.parsed_url.hostname) | 91 | self.tempfile = os.fdopen(self.tempfd, u"w") |
36 | 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) |
37 | 92 | os.write(self.tempfile, u"pass %s\n" % self.password) | 93 | self.tempfile.write(u"user %s\n" % self.parsed_url.username) |
38 | 93 | os.close(self.tempfile) | 94 | self.tempfile.write(u"pass %s\n" % self.password) |
39 | 95 | self.tempfile.close() | ||
40 | 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 " % \ |
41 | 95 | (self.tempname, self.conn_opt, globals.timeout) | 97 | (self.tempname, self.conn_opt, globals.timeout) |
42 | 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: |
43 | 97 | self.flags += u" -P '%s'" % (parsed_url.port) | 99 | self.flags += u" -P '%s'" % (parsed_url.port) |
44 | 98 | 100 | ||
45 | 99 | def _put(self, source_path, remote_filename): | 101 | def _put(self, source_path, remote_filename): |
46 | 102 | remote_filename = util.fsdecode(remote_filename) | ||
47 | 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)), |
48 | 101 | remote_filename).rstrip() | 104 | remote_filename).rstrip() |
49 | 102 | commandline = u"ncftpput %s -m -V -C '%s' '%s'" % \ | 105 | commandline = u"ncftpput %s -m -V -C '%s' '%s'" % \ |
51 | 103 | (self.flags, source_path.name, remote_path) | 106 | (self.flags, source_path.uc_name, remote_path) |
52 | 104 | self.subprocess_popen(commandline) | 107 | self.subprocess_popen(commandline) |
53 | 105 | 108 | ||
54 | 106 | def _get(self, remote_filename, local_path): | 109 | def _get(self, remote_filename, local_path): |
55 | 110 | remote_filename = util.fsdecode(remote_filename) | ||
56 | 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)), |
57 | 108 | remote_filename).rstrip() | 112 | remote_filename).rstrip() |
58 | 109 | commandline = u"ncftpget %s -V -C '%s' '%s' '%s'" % \ | 113 | commandline = u"ncftpget %s -V -C '%s' '%s' '%s'" % \ |
60 | 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) |
61 | 111 | self.subprocess_popen(commandline) | 115 | self.subprocess_popen(commandline) |
62 | 112 | 116 | ||
63 | 113 | def _list(self): | 117 | def _list(self): |
64 | @@ -115,7 +119,7 @@ | |||
65 | 115 | commandline = u"ncftpls %s -l '%s'" % (self.flags, self.url_string) | 119 | commandline = u"ncftpls %s -l '%s'" % (self.flags, self.url_string) |
66 | 116 | _, l, _ = self.subprocess_popen(commandline) | 120 | _, l, _ = self.subprocess_popen(commandline) |
67 | 117 | # Look for our files as the last element of a long list line | 121 | # Look for our files as the last element of a long list line |
69 | 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 ")] |
70 | 119 | 123 | ||
71 | 120 | def _delete(self, filename): | 124 | def _delete(self, filename): |
72 | 121 | commandline = u"ncftpls %s -l -X 'DELE %s' '%s'" % \ | 125 | commandline = u"ncftpls %s -l -X 'DELE %s' '%s'" % \ |
73 | 122 | 126 | ||
74 | === modified file 'duplicity/backends/rsyncbackend.py' | |||
75 | --- duplicity/backends/rsyncbackend.py 2018-11-29 19:00:15 +0000 | |||
76 | +++ duplicity/backends/rsyncbackend.py 2019-02-27 22:47:02 +0000 | |||
77 | @@ -109,13 +109,15 @@ | |||
78 | 109 | u"" % self.munge_password(url)) | 109 | u"" % self.munge_password(url)) |
79 | 110 | 110 | ||
80 | 111 | def _put(self, source_path, remote_filename): | 111 | def _put(self, source_path, remote_filename): |
81 | 112 | remote_filename = util.fsdecode(remote_filename) | ||
82 | 112 | remote_path = os.path.join(self.url_string, remote_filename) | 113 | remote_path = os.path.join(self.url_string, remote_filename) |
84 | 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) |
85 | 114 | self.subprocess_popen(commandline) | 115 | self.subprocess_popen(commandline) |
86 | 115 | 116 | ||
87 | 116 | def _get(self, remote_filename, local_path): | 117 | def _get(self, remote_filename, local_path): |
88 | 118 | remote_filename = util.fsdecode(remote_filename) | ||
89 | 117 | remote_path = os.path.join(self.url_string, remote_filename) | 119 | remote_path = os.path.join(self.url_string, remote_filename) |
91 | 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) |
92 | 119 | self.subprocess_popen(commandline) | 121 | self.subprocess_popen(commandline) |
93 | 120 | 122 | ||
94 | 121 | def _list(self): | 123 | def _list(self): |
95 | @@ -127,7 +129,7 @@ | |||
96 | 127 | return None | 129 | return None |
97 | 128 | commandline = u"%s %s" % (self.cmd, self.url_string) | 130 | commandline = u"%s %s" % (self.cmd, self.url_string) |
98 | 129 | result, stdout, stderr = self.subprocess_popen(commandline) | 131 | result, stdout, stderr = self.subprocess_popen(commandline) |
100 | 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] |
101 | 131 | 133 | ||
102 | 132 | def _delete_list(self, filename_list): | 134 | def _delete_list(self, filename_list): |
103 | 133 | delete_list = filename_list | 135 | delete_list = filename_list |
104 | 134 | 136 | ||
105 | === modified file 'duplicity/backends/ssh_pexpect_backend.py' | |||
106 | --- duplicity/backends/ssh_pexpect_backend.py 2019-02-25 16:30:59 +0000 | |||
107 | +++ duplicity/backends/ssh_pexpect_backend.py 2019-02-27 22:47:02 +0000 | |||
108 | @@ -38,10 +38,9 @@ | |||
109 | 38 | import duplicity.backend | 38 | import duplicity.backend |
110 | 39 | from duplicity import globals | 39 | from duplicity import globals |
111 | 40 | from duplicity import log | 40 | from duplicity import log |
112 | 41 | from duplicity import util | ||
113 | 41 | from duplicity.errors import BackendException | 42 | from duplicity.errors import BackendException |
114 | 42 | 43 | ||
115 | 43 | global pexpect | ||
116 | 44 | |||
117 | 45 | 44 | ||
118 | 46 | class SSHPExpectBackend(duplicity.backend.Backend): | 45 | class SSHPExpectBackend(duplicity.backend.Backend): |
119 | 47 | u"""This backend copies files using scp. List not supported. Filenames | 46 | u"""This backend copies files using scp. List not supported. Filenames |
120 | @@ -52,6 +51,8 @@ | |||
121 | 52 | 51 | ||
122 | 53 | try: | 52 | try: |
123 | 54 | import pexpect | 53 | import pexpect |
124 | 54 | global pexpect | ||
125 | 55 | |||
126 | 55 | except ImportError: | 56 | except ImportError: |
127 | 56 | raise | 57 | raise |
128 | 57 | 58 | ||
129 | @@ -172,7 +173,7 @@ | |||
130 | 172 | u"open(.*): Failure"] | 173 | u"open(.*): Failure"] |
131 | 173 | max_response_len = max([len(p) for p in responses[1:]]) | 174 | max_response_len = max([len(p) for p in responses[1:]]) |
132 | 174 | log.Info(u"Running '%s'" % (commandline)) | 175 | log.Info(u"Running '%s'" % (commandline)) |
134 | 175 | child = pexpect.spawn(commandline, timeout=None, maxread=maxread) | 176 | child = pexpect.spawn(commandline, timeout=None, maxread=maxread, encoding=globals.fsencoding) |
135 | 176 | cmdloc = 0 | 177 | cmdloc = 0 |
136 | 177 | passprompt = 0 | 178 | passprompt = 0 |
137 | 178 | while 1: | 179 | while 1: |
138 | @@ -228,6 +229,7 @@ | |||
139 | 228 | raise BackendException(u"Error running '%s': %s" % (commandline, msg)) | 229 | raise BackendException(u"Error running '%s': %s" % (commandline, msg)) |
140 | 229 | 230 | ||
141 | 230 | def _put(self, source_path, remote_filename): | 231 | def _put(self, source_path, remote_filename): |
142 | 232 | remote_filename = util.fsdecode(remote_filename) | ||
143 | 231 | if self.use_scp: | 233 | if self.use_scp: |
144 | 232 | self.put_scp(source_path, remote_filename) | 234 | self.put_scp(source_path, remote_filename) |
145 | 233 | else: | 235 | else: |
146 | @@ -235,7 +237,7 @@ | |||
147 | 235 | 237 | ||
148 | 236 | def put_sftp(self, source_path, remote_filename): | 238 | def put_sftp(self, source_path, remote_filename): |
149 | 237 | commands = [u"put \"%s\" \"%s.%s.part\"" % | 239 | commands = [u"put \"%s\" \"%s.%s.part\"" % |
151 | 238 | (source_path.name, self.remote_prefix, remote_filename), | 240 | (source_path.uc_name, self.remote_prefix, remote_filename), |
152 | 239 | u"rename \"%s.%s.part\" \"%s%s\"" % | 241 | u"rename \"%s.%s.part\" \"%s%s\"" % |
153 | 240 | (self.remote_prefix, remote_filename, self.remote_prefix, remote_filename)] | 242 | (self.remote_prefix, remote_filename, self.remote_prefix, remote_filename)] |
154 | 241 | commandline = (u"%s %s %s" % (self.sftp_command, | 243 | commandline = (u"%s %s %s" % (self.sftp_command, |
155 | @@ -245,11 +247,12 @@ | |||
156 | 245 | 247 | ||
157 | 246 | def put_scp(self, source_path, remote_filename): | 248 | def put_scp(self, source_path, remote_filename): |
158 | 247 | commandline = u"%s %s %s %s:%s%s" % \ | 249 | commandline = u"%s %s %s %s:%s%s" % \ |
160 | 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, |
161 | 249 | self.remote_prefix, remote_filename) | 251 | self.remote_prefix, remote_filename) |
162 | 250 | self.run_scp_command(commandline) | 252 | self.run_scp_command(commandline) |
163 | 251 | 253 | ||
164 | 252 | def _get(self, remote_filename, local_path): | 254 | def _get(self, remote_filename, local_path): |
165 | 255 | remote_filename = util.fsdecode(remote_filename) | ||
166 | 253 | if self.use_scp: | 256 | if self.use_scp: |
167 | 254 | self.get_scp(remote_filename, local_path) | 257 | self.get_scp(remote_filename, local_path) |
168 | 255 | else: | 258 | else: |
169 | @@ -257,7 +260,7 @@ | |||
170 | 257 | 260 | ||
171 | 258 | def get_sftp(self, remote_filename, local_path): | 261 | def get_sftp(self, remote_filename, local_path): |
172 | 259 | commands = [u"get \"%s%s\" \"%s\"" % | 262 | commands = [u"get \"%s%s\" \"%s\"" % |
174 | 260 | (self.remote_prefix, remote_filename, local_path.name)] | 263 | (self.remote_prefix, remote_filename, local_path.uc_name)] |
175 | 261 | commandline = (u"%s %s %s" % (self.sftp_command, | 264 | commandline = (u"%s %s %s" % (self.sftp_command, |
176 | 262 | globals.ssh_options, | 265 | globals.ssh_options, |
177 | 263 | self.host_string)) | 266 | self.host_string)) |
178 | @@ -266,7 +269,7 @@ | |||
179 | 266 | def get_scp(self, remote_filename, local_path): | 269 | def get_scp(self, remote_filename, local_path): |
180 | 267 | commandline = u"%s %s %s:%s%s %s" % \ | 270 | commandline = u"%s %s %s:%s%s %s" % \ |
181 | 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, |
183 | 269 | remote_filename, local_path.name) | 272 | remote_filename, local_path.uc_name) |
184 | 270 | self.run_scp_command(commandline) | 273 | self.run_scp_command(commandline) |
185 | 271 | 274 | ||
186 | 272 | def _list(self): | 275 | def _list(self): |
187 | @@ -289,7 +292,7 @@ | |||
188 | 289 | 292 | ||
189 | 290 | l = self.run_sftp_command(commandline, commands).split(u'\n')[1:] | 293 | l = self.run_sftp_command(commandline, commands).split(u'\n')[1:] |
190 | 291 | 294 | ||
192 | 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] |
193 | 293 | 296 | ||
194 | 294 | def _delete(self, filename): | 297 | def _delete(self, filename): |
195 | 295 | commands = [u"cd \"%s\"" % (self.remote_dir,)] | 298 | commands = [u"cd \"%s\"" % (self.remote_dir,)] |
196 | 296 | 299 | ||
197 | === modified file 'duplicity/backends/sxbackend.py' | |||
198 | --- duplicity/backends/sxbackend.py 2018-07-23 14:55:39 +0000 | |||
199 | +++ duplicity/backends/sxbackend.py 2019-02-27 22:47:02 +0000 | |||
200 | @@ -20,6 +20,7 @@ | |||
201 | 20 | 20 | ||
202 | 21 | import os.path | 21 | import os.path |
203 | 22 | import duplicity.backend | 22 | import duplicity.backend |
204 | 23 | import duplicity.util | ||
205 | 23 | 24 | ||
206 | 24 | 25 | ||
207 | 25 | class SXBackend(duplicity.backend.Backend): | 26 | class SXBackend(duplicity.backend.Backend): |
208 | @@ -29,13 +30,15 @@ | |||
209 | 29 | self.url_string = parsed_url.url_string | 30 | self.url_string = parsed_url.url_string |
210 | 30 | 31 | ||
211 | 31 | def _put(self, source_path, remote_filename): | 32 | def _put(self, source_path, remote_filename): |
212 | 33 | remote_filename = util.fsdecode(remote_filename) | ||
213 | 32 | remote_path = os.path.join(self.url_string, remote_filename) | 34 | remote_path = os.path.join(self.url_string, remote_filename) |
215 | 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) |
216 | 34 | self.subprocess_popen(commandline) | 36 | self.subprocess_popen(commandline) |
217 | 35 | 37 | ||
218 | 36 | def _get(self, remote_filename, local_path): | 38 | def _get(self, remote_filename, local_path): |
219 | 39 | remote_filename = util.fsdecode(remote_filename) | ||
220 | 37 | remote_path = os.path.join(self.url_string, remote_filename) | 40 | remote_path = os.path.join(self.url_string, remote_filename) |
222 | 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) |
223 | 39 | self.subprocess_popen(commandline) | 42 | self.subprocess_popen(commandline) |
224 | 40 | 43 | ||
225 | 41 | def _list(self): | 44 | def _list(self): |
226 | @@ -43,7 +46,7 @@ | |||
227 | 43 | commandline = u"sxls {0}".format(self.url_string) | 46 | commandline = u"sxls {0}".format(self.url_string) |
228 | 44 | _, l, _ = self.subprocess_popen(commandline) | 47 | _, l, _ = self.subprocess_popen(commandline) |
229 | 45 | # Look for our files as the last element of a long list line | 48 | # Look for our files as the last element of a long list line |
231 | 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 ")] |
232 | 47 | 50 | ||
233 | 48 | def _delete(self, filename): | 51 | def _delete(self, filename): |
234 | 49 | commandline = u"sxrm {0}/{1}".format(self.url_string, filename) | 52 | commandline = u"sxrm {0}/{1}".format(self.url_string, filename) |
235 | 50 | 53 | ||
236 | === modified file 'testing/unit/test_selection.py' | |||
237 | --- testing/unit/test_selection.py 2018-11-29 19:00:15 +0000 | |||
238 | +++ testing/unit/test_selection.py 2019-02-27 22:47:02 +0000 | |||
239 | @@ -45,7 +45,7 @@ | |||
240 | 45 | 45 | ||
241 | 46 | def testRegexp(self): | 46 | def testRegexp(self): |
242 | 47 | u"""Test regular expression selection func""" | 47 | u"""Test regular expression selection func""" |
244 | 48 | sf1 = self.Select.regexp_get_sf(u".*\.py", 1) | 48 | sf1 = self.Select.regexp_get_sf(u".*\\.py", 1) |
245 | 49 | assert sf1(self.makeext(u"1.py")) == 1 | 49 | assert sf1(self.makeext(u"1.py")) == 1 |
246 | 50 | assert sf1(self.makeext(u"usr/foo.py")) == 1 | 50 | assert sf1(self.makeext(u"usr/foo.py")) == 1 |
247 | 51 | assert sf1(self.root.append(u"1.doc")) is None | 51 | assert sf1(self.root.append(u"1.doc")) is None |