X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=apps%2Fpatchwork%2Fbin%2Fpwclient;h=dba68fb036b1b28c9351548f6cf142b770238ccb;hb=ad4715cef72910b1310d4b93a2294ace878b0b4a;hp=b4804080921b0c90ebd4a4140d8751c64529b463;hpb=d5edf740c9c2c31fa60c757aa8d66e1dedbab74a;p=patchwork diff --git a/apps/patchwork/bin/pwclient b/apps/patchwork/bin/pwclient index b480408..dba68fb 100755 --- a/apps/patchwork/bin/pwclient +++ b/apps/patchwork/bin/pwclient @@ -79,12 +79,13 @@ class Filter: """Return human-readable description of the filter.""" return str(self.d) -class BasicHTTPAuthTransport(xmlrpclib.Transport): +class BasicHTTPAuthTransport(xmlrpclib.SafeTransport): - def __init__(self, username = None, password = None): + def __init__(self, username = None, password = None, use_https = False): self.username = username self.password = password - xmlrpclib.Transport.__init__(self) + self.use_https = use_https + xmlrpclib.SafeTransport.__init__(self) def authenticated(self): return self.username != None and self.password != None @@ -97,6 +98,13 @@ class BasicHTTPAuthTransport(xmlrpclib.Transport): auth = 'Basic ' + base64.encodestring(credentials).strip() connection.putheader('Authorization', auth) + def make_connection(self, host): + if self.use_https: + fn = xmlrpclib.SafeTransport.make_connection + else: + fn = xmlrpclib.Transport.make_connection + return fn(self, host) + def usage(): sys.stderr.write("Usage: %s [options]\n\n" % \ (os.path.basename(sys.argv[0]))) @@ -171,7 +179,8 @@ def action_list(rpc, filter, submitter_str, delegate_str): for id in ids: person = rpc.person_get(id) print "Patches submitted by %s <%s>:" % \ - (person['name'], person['email']) + (unicode(person['name']).encode("utf-8"), \ + unicode(person['email']).encode("utf-8")) f = filter f.add("submitter_id", id) patches = rpc.patch_list(f.d) @@ -365,9 +374,12 @@ def main(): if config.has_option('auth', 'username') and \ config.has_option('auth', 'password'): + use_https = url.startswith('https') + transport = BasicHTTPAuthTransport( \ config.get('auth', 'username'), - config.get('auth', 'password')) + config.get('auth', 'password'), + use_https) else: sys.stderr.write(("The %s action requires authentication, "