[PATCH] pwclient: do proper utf-8 encoding of all RPC responses
Arnout Vandecappelle (Essensium/Mind)
arnout at mind.be
Tue Mar 14 08:19:10 AEDT 2017
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout at mind.be>
---
Note that I haven't properly tested the change in the delegate printing,
because the ozlabs patchwork instance seems to barf on delegate requests.
I did, however, test that the bit that I modified still works correctly.
---
patchwork/bin/pwclient | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/patchwork/bin/pwclient b/patchwork/bin/pwclient
index 8d1f476..3a8b2d1 100755
--- a/patchwork/bin/pwclient
+++ b/patchwork/bin/pwclient
@@ -157,7 +157,9 @@ def list_patches(patches, format_str=None):
print("%-7s %-12s %s" % ("ID", "State", "Name"))
print("%-7s %-12s %s" % ("--", "-----", "----"))
for patch in patches:
- print("%-7d %-12s %s" % (patch['id'], patch['state'], patch['name']))
+ print("%-7d %-12s %s" % (patch['id'], \
+ unicode(patch['state']).encode("utf-8"), \
+ unicode(patch['name']).encode("utf-8")))
def action_list(rpc, filter, submitter_str, delegate_str, format_str=None):
filter.resolve_ids(rpc)
@@ -188,7 +190,8 @@ def action_list(rpc, filter, submitter_str, delegate_str, format_str=None):
for id in ids:
person = rpc.person_get(id)
print "Patches delegated to %s <%s>:" % \
- (person['name'], person['email'])
+ (unicode(person['name']).encode("utf-8"), \
+ unicode(person['email']).encode("utf-8"))
f = filter
f.add("delegate_id", id)
patches = rpc.patch_list(f.d)
@@ -204,8 +207,8 @@ def action_projects(rpc):
print("%-5s %-24s %s" % ("--", "----", "-----------"))
for project in projects:
print("%-5d %-24s %s" % (project['id'], \
- project['linkname'], \
- project['name']))
+ unicode(project['linkname']).encode("utf-8"), \
+ unicode(project['name']).encode("utf-8")))
def action_states(rpc):
states = rpc.state_list("", 0)
@@ -264,7 +267,7 @@ def action_apply(rpc, patch_id, apply_cmd=None):
print "Applying patch #%d using %s" % (
patch_id, repr(' '.join(apply_cmd)))
- print "Description: %s" % patch['name']
+ print "Description: %s" % unicode(patch['name']).encode("utf-8")
s = rpc.patch_get_mbox(patch_id)
if len(s) > 0:
proc = subprocess.Popen(apply_cmd, stdin = subprocess.PIPE)
--
2.11.0
More information about the Patchwork
mailing list