##// END OF EJS Templates
allow configuration of packer/unpacker in client
MinRK -
Show More
@@ -120,11 +120,27 b' class Client(HasTraits):'
120 120 [Default: 'default']
121 121 context : zmq.Context
122 122 Pass an existing zmq.Context instance, otherwise the client will create its own.
123 username : bytes
124 set username to be passed to the Session object
125 123 debug : bool
126 124 flag for lots of message printing for debug purposes
125 timeout : int/float
126 time (in seconds) to wait for connection replies from the Hub
127 [Default: 10]
127 128
129 #-------------- session related args ----------------
130
131 config : Config object
132 If specified, this will be relayed to the Session for configuration
133 username : str
134 set username for the session object
135 packer : str (import_string) or callable
136 Can be either the simple keyword 'json' or 'pickle', or an import_string to a
137 function to serialize messages. Must support same input as
138 JSON, and output must be bytes.
139 You can pass a callable directly as `pack`
140 unpacker : str (import_string) or callable
141 The inverse of packer. Only necessary if packer is specified as *not* one
142 of 'json' or 'pickle'.
143
128 144 #-------------- ssh related args ----------------
129 145 # These are args for configuring the ssh tunnel to be used
130 146 # credentials are used to forward connections over ssh to the Controller
@@ -150,9 +166,10 b' class Client(HasTraits):'
150 166
151 167 ------- exec authentication args -------
152 168 If even localhost is untrusted, you can have some protection against
153 unauthorized execution by using a key. Messages are still sent
154 as cleartext, so if someone can snoop your loopback traffic this will
155 not help against malicious attacks.
169 unauthorized execution by signing messages with HMAC digests.
170 Messages are still sent as cleartext, so if someone can snoop your
171 loopback traffic this will not protect your privacy, but will prevent
172 unauthorized execution.
156 173
157 174 exec_key : str
158 175 an authentication key or file containing a key
@@ -236,9 +253,9 b' class Client(HasTraits):'
236 253 _ignored_hub_replies=Int(0)
237 254
238 255 def __init__(self, url_or_file=None, profile='default', profile_dir=None, ipython_dir=None,
239 context=None, username=None, debug=False, exec_key=None,
256 context=None, debug=False, exec_key=None,
240 257 sshserver=None, sshkey=None, password=None, paramiko=None,
241 timeout=10
258 timeout=10, **extra_args
242 259 ):
243 260 super(Client, self).__init__(debug=debug, profile=profile)
244 261 if context is None:
@@ -289,15 +306,15 b' class Client(HasTraits):'
289 306 else:
290 307 password = getpass("SSH Password for %s: "%sshserver)
291 308 ssh_kwargs = dict(keyfile=sshkey, password=password, paramiko=paramiko)
292 if exec_key is not None and os.path.isfile(exec_key):
293 arg = 'keyfile'
294 else:
295 arg = 'key'
296 key_arg = {arg:exec_key}
297 if username is None:
298 self.session = Session(**key_arg)
299 else:
300 self.session = Session(username=username, **key_arg)
309
310 # configure and construct the session
311 if exec_key is not None:
312 if os.path.isfile(exec_key):
313 extra_args['keyfile'] = exec_key
314 else:
315 extra_args['key'] = exec_key
316 self.session = Session(**extra_args)
317
301 318 self._query_socket = self._context.socket(zmq.XREQ)
302 319 self._query_socket.setsockopt(zmq.IDENTITY, self.session.session)
303 320 if self._ssh:
General Comments 0
You need to be logged in to leave comments. Login now