1 From 0991ccb0e7c0be66e087839f88a7120394c2f052 Mon Sep 17 00:00:00 2001
2 From: Mike Frysinger <vapier@chromium.org>
3 Date: Tue, 5 May 2015 23:54:16 -0400
4 Subject: [PATCH 2/3] pwclient: use print_function for better py3 compatibility
6 The script already tries to use print like a function in many places but
7 is really passing a parenthesized string. Import the print_function from
8 the future module so that it actually works as intended.
10 We also need to fix up a few latent print statements to make it work.
12 Signed-off-by: Mike Frysinger <vapier@chromium.org>
14 apps/patchwork/bin/pwclient | 26 ++++++++++++++------------
15 1 file changed, 14 insertions(+), 12 deletions(-)
17 diff --git a/apps/patchwork/bin/pwclient b/apps/patchwork/bin/pwclient
18 index 56aa909..2e6daa5 100755
19 --- a/apps/patchwork/bin/pwclient
20 +++ b/apps/patchwork/bin/pwclient
22 # along with Patchwork; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 +from __future__ import print_function
30 @@ -170,9 +172,9 @@ def action_list(rpc, filter, submitter_str, delegate_str, format_str=None):
33 person = rpc.person_get(id)
34 - print "Patches submitted by %s <%s>:" % \
35 - (unicode(person['name']).encode("utf-8"), \
36 - unicode(person['email']).encode("utf-8"))
37 + print('Patches submitted by %s <%s>:' %
38 + (unicode(person['name']).encode('utf-8'),
39 + unicode(person['email']).encode('utf-8')))
41 f.add("submitter_id", id)
42 patches = rpc.patch_list(f.d)
43 @@ -187,8 +189,8 @@ def action_list(rpc, filter, submitter_str, delegate_str, format_str=None):
46 person = rpc.person_get(id)
47 - print "Patches delegated to %s <%s>:" % \
48 - (person['name'], person['email'])
49 + print('Patches delegated to %s <%s>:' %
50 + (person['name'], person['email']))
52 f.add("delegate_id", id)
53 patches = rpc.patch_list(f.d)
54 @@ -245,7 +247,7 @@ def action_get(rpc, patch_id):
56 f.write(unicode(s).encode("utf-8"))
58 - print "Saved patch to %s" % fname
59 + print('Saved patch to %s' % fname)
61 sys.stderr.write("Failed to write to %s\n" % fname)
63 @@ -258,13 +260,13 @@ def action_apply(rpc, patch_id, apply_cmd=None):
67 - print "Applying patch #%d to current directory" % patch_id
68 + print('Applying patch #%d to current directory' % patch_id)
69 apply_cmd = ['patch', '-p1']
71 - print "Applying patch #%d using %s" % (
72 - patch_id, repr(' '.join(apply_cmd)))
73 + print('Applying patch #%d using %s' %
74 + (patch_id, repr(' '.join(apply_cmd))))
76 - print "Description: %s" % patch['name']
77 + print('Description: %s' % patch['name'])
78 s = rpc.patch_get_mbox(patch_id)
80 proc = subprocess.Popen(apply_cmd, stdin = subprocess.PIPE)
81 @@ -295,7 +297,7 @@ def action_update_patch(rpc, patch_id, state = None, commit = None):
84 success = rpc.patch_set(patch_id, params)
85 - except xmlrpclib.Fault, f:
86 + except xmlrpclib.Fault as f:
87 sys.stderr.write("Error updating patch: %s\n" % f.faultString)
90 @@ -668,7 +670,7 @@ def main():
91 for patch_id in non_empty(h, patch_ids):
92 s = rpc.patch_get_mbox(patch_id)
94 - print unicode(s).encode("utf-8")
95 + print(unicode(s).encode('utf-8'))
97 elif action == 'info':
98 for patch_id in non_empty(h, patch_ids):