Skip to content

Commit f9c7cce

Browse files
vapierstephenfin
authored andcommitted
pwclient: use print_function for better py3 compatibility
The script already tries to use print like a function in many places but is really passing a parenthesized string. Import the print_function from the future module so that it actually works as intended. We also need to fix up a few latent print statements to make it work. Signed-off-by: Mike Frysinger <[email protected]> Reviewed-by: Stephen Finucane <[email protected]>
1 parent 7032070 commit f9c7cce

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

patchwork/bin/pwclient

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
# along with Patchwork; if not, write to the Free Software
2020
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2121

22+
from __future__ import print_function
23+
2224
import os
2325
import sys
2426
import xmlrpclib
@@ -170,9 +172,9 @@ def action_list(rpc, filter, submitter_str, delegate_str, format_str=None):
170172
else:
171173
for id in ids:
172174
person = rpc.person_get(id)
173-
print "Patches submitted by %s <%s>:" % \
174-
(unicode(person['name']).encode("utf-8"), \
175-
unicode(person['email']).encode("utf-8"))
175+
print('Patches submitted by %s <%s>:' %
176+
(unicode(person['name']).encode('utf-8'),
177+
unicode(person['email']).encode('utf-8')))
176178
f = filter
177179
f.add("submitter_id", id)
178180
patches = rpc.patch_list(f.d)
@@ -187,8 +189,8 @@ def action_list(rpc, filter, submitter_str, delegate_str, format_str=None):
187189
else:
188190
for id in ids:
189191
person = rpc.person_get(id)
190-
print "Patches delegated to %s <%s>:" % \
191-
(person['name'], person['email'])
192+
print('Patches delegated to %s <%s>:' %
193+
(person['name'], person['email']))
192194
f = filter
193195
f.add("delegate_id", id)
194196
patches = rpc.patch_list(f.d)
@@ -245,7 +247,7 @@ def action_get(rpc, patch_id):
245247
try:
246248
f.write(unicode(s).encode("utf-8"))
247249
f.close()
248-
print "Saved patch to %s" % fname
250+
print('Saved patch to %s' % fname)
249251
except:
250252
sys.stderr.write("Failed to write to %s\n" % fname)
251253
sys.exit(1)
@@ -258,13 +260,13 @@ def action_apply(rpc, patch_id, apply_cmd=None):
258260
sys.exit(1)
259261

260262
if apply_cmd is None:
261-
print "Applying patch #%d to current directory" % patch_id
263+
print('Applying patch #%d to current directory' % patch_id)
262264
apply_cmd = ['patch', '-p1']
263265
else:
264-
print "Applying patch #%d using %s" % (
265-
patch_id, repr(' '.join(apply_cmd)))
266+
print('Applying patch #%d using %s' %
267+
(patch_id, repr(' '.join(apply_cmd))))
266268

267-
print "Description: %s" % patch['name']
269+
print('Description: %s' % patch['name'])
268270
s = rpc.patch_get_mbox(patch_id)
269271
if len(s) > 0:
270272
proc = subprocess.Popen(apply_cmd, stdin = subprocess.PIPE)
@@ -299,7 +301,7 @@ def action_update_patch(rpc, patch_id, state = None, archived = None, commit = N
299301
success = False
300302
try:
301303
success = rpc.patch_set(patch_id, params)
302-
except xmlrpclib.Fault, f:
304+
except xmlrpclib.Fault as f:
303305
sys.stderr.write("Error updating patch: %s\n" % f.faultString)
304306

305307
if not success:
@@ -702,7 +704,7 @@ def main():
702704
for patch_id in non_empty(h, patch_ids):
703705
s = rpc.patch_get_mbox(patch_id)
704706
if len(s) > 0:
705-
print unicode(s).encode("utf-8")
707+
print(unicode(s).encode("utf-8"))
706708

707709
elif action == 'info':
708710
for patch_id in non_empty(h, patch_ids):

0 commit comments

Comments
 (0)