Mercurial > hg > AuthRPC
comparison wibble/client/__init__.py @ 13:21eb67081c43
Added docstrings
author | Ben Croston <ben@croston.org> |
---|---|
date | Mon, 05 Sep 2011 12:42:05 +0100 |
parents | 23743b0f67ab |
children |
comparison
equal
deleted
inserted
replaced
12:4ac14cfadc15 | 13:21eb67081c43 |
---|---|
78 class _JSONRPCTransport(object): | 78 class _JSONRPCTransport(object): |
79 headers = {'Content-Type':'application/json', | 79 headers = {'Content-Type':'application/json', |
80 'Accept':'application/json'} | 80 'Accept':'application/json'} |
81 | 81 |
82 def __init__(self, uri, proxy_uri=None, user_agent=None): | 82 def __init__(self, uri, proxy_uri=None, user_agent=None): |
83 self.headers['User-Agent'] = user_agent if user_agent is not None else 'jsonrpclib' | 83 self.headers['User-Agent'] = user_agent if user_agent is not None else 'wibble' |
84 if proxy_uri is not None: | 84 if proxy_uri is not None: |
85 self.connection_url = urlparse(proxy_uri) | 85 self.connection_url = urlparse(proxy_uri) |
86 self.request_path = uri | 86 self.request_path = uri |
87 else: | 87 else: |
88 self.connection_url = urlparse(uri) | 88 self.connection_url = urlparse(uri) |
134 """HTTP 502 - Bad Gateway""" | 134 """HTTP 502 - Bad Gateway""" |
135 def __init__(self): | 135 def __init__(self): |
136 Exception.__init__(self,'HTTP 502 - Bad Gateway') | 136 Exception.__init__(self,'HTTP 502 - Bad Gateway') |
137 | 137 |
138 class ServerProxy(object): | 138 class ServerProxy(object): |
139 def __init__(self, uri=None, transport=None, proxy_uri=None, user_agent=None, username=None, password=None): | 139 """ |
140 if uri is None and transport is None: | 140 A client class to communicate with a wibble server |
141 raise Exception('either uri or transport needs to be specified') | 141 """ |
142 | 142 def __init__(self, uri, proxy_uri=None, user_agent=None, username=None, password=None): |
143 if transport is None: | 143 """ |
144 transport = _JSONRPCTransport(uri, proxy_uri=proxy_uri, user_agent=user_agent) | 144 uri - the URI of a corresponding wibble server |
145 self.__transport = transport | 145 proxy_uri - the http proxy to use, if any |
146 user_agent - user agent to be used (can be used as part of authentication) | |
147 username - username to use in requests | |
148 password - password to use in requests | |
149 """ | |
150 assert uri is not None | |
151 self.__transport = _JSONRPCTransport(uri, proxy_uri=proxy_uri, user_agent=user_agent) | |
146 self._username = username | 152 self._username = username |
147 self._password = password | 153 self._password = password |
148 | 154 |
149 def __request(self, request): | 155 def __request(self, request): |
150 # call a method on the remote server | 156 # call a method on the remote server |