Show More
@@ -28,6 +28,9 b' pjoin = os.path.join' | |||||
28 | import zmq |
|
28 | import zmq | |
29 | # from zmq.eventloop import ioloop, zmqstream |
|
29 | # from zmq.eventloop import ioloop, zmqstream | |
30 |
|
30 | |||
|
31 | from IPython.config.configurable import MultipleInstanceError | |||
|
32 | from IPython.core.application import BaseIPythonApplication | |||
|
33 | ||||
31 | from IPython.utils.jsonutil import rekey |
|
34 | from IPython.utils.jsonutil import rekey | |
32 | from IPython.utils.path import get_ipython_dir |
|
35 | from IPython.utils.path import get_ipython_dir | |
33 | from IPython.utils.traitlets import (HasTraits, Int, Instance, Unicode, |
|
36 | from IPython.utils.traitlets import (HasTraits, Int, Instance, Unicode, | |
@@ -117,13 +120,14 b' class Client(HasTraits):' | |||||
117 | Parameters |
|
120 | Parameters | |
118 | ---------- |
|
121 | ---------- | |
119 |
|
122 | |||
120 | url_or_file : bytes; zmq url or path to ipcontroller-client.json |
|
123 | url_or_file : bytes or unicode; zmq url or path to ipcontroller-client.json | |
121 | Connection information for the Hub's registration. If a json connector |
|
124 | Connection information for the Hub's registration. If a json connector | |
122 | file is given, then likely no further configuration is necessary. |
|
125 | file is given, then likely no further configuration is necessary. | |
123 | [Default: use profile] |
|
126 | [Default: use profile] | |
124 | profile : bytes |
|
127 | profile : bytes | |
125 | The name of the Cluster profile to be used to find connector information. |
|
128 | The name of the Cluster profile to be used to find connector information. | |
126 | [Default: 'default'] |
|
129 | If run from an IPython application, the default profile will be the same | |
|
130 | as the running application, otherwise it will be 'default'. | |||
127 | context : zmq.Context |
|
131 | context : zmq.Context | |
128 | Pass an existing zmq.Context instance, otherwise the client will create its own. |
|
132 | Pass an existing zmq.Context instance, otherwise the client will create its own. | |
129 | debug : bool |
|
133 | debug : bool | |
@@ -237,7 +241,20 b' class Client(HasTraits):' | |||||
237 | metadata = Instance('collections.defaultdict', (Metadata,)) |
|
241 | metadata = Instance('collections.defaultdict', (Metadata,)) | |
238 | history = List() |
|
242 | history = List() | |
239 | debug = Bool(False) |
|
243 | debug = Bool(False) | |
240 | profile=Unicode('default') |
|
244 | ||
|
245 | profile=Unicode() | |||
|
246 | def _profile_default(self): | |||
|
247 | if BaseIPythonApplication.initialized(): | |||
|
248 | # an IPython app *might* be running, try to get its profile | |||
|
249 | try: | |||
|
250 | return BaseIPythonApplication.instance().profile | |||
|
251 | except (AttributeError, MultipleInstanceError): | |||
|
252 | # could be a *different* subclass of config.Application, | |||
|
253 | # which would raise one of these two errors. | |||
|
254 | return u'default' | |||
|
255 | else: | |||
|
256 | return u'default' | |||
|
257 | ||||
241 |
|
258 | |||
242 | _outstanding_dict = Instance('collections.defaultdict', (set,)) |
|
259 | _outstanding_dict = Instance('collections.defaultdict', (set,)) | |
243 | _ids = List() |
|
260 | _ids = List() | |
@@ -258,18 +275,24 b' class Client(HasTraits):' | |||||
258 | _ignored_control_replies=Int(0) |
|
275 | _ignored_control_replies=Int(0) | |
259 | _ignored_hub_replies=Int(0) |
|
276 | _ignored_hub_replies=Int(0) | |
260 |
|
277 | |||
261 | def __init__(self, url_or_file=None, profile='default', profile_dir=None, ipython_dir=None, |
|
278 | def __new__(self, *args, **kw): | |
|
279 | # don't raise on positional args | |||
|
280 | return HasTraits.__new__(self, **kw) | |||
|
281 | ||||
|
282 | def __init__(self, url_or_file=None, profile=None, profile_dir=None, ipython_dir=None, | |||
262 | context=None, debug=False, exec_key=None, |
|
283 | context=None, debug=False, exec_key=None, | |
263 | sshserver=None, sshkey=None, password=None, paramiko=None, |
|
284 | sshserver=None, sshkey=None, password=None, paramiko=None, | |
264 | timeout=10, **extra_args |
|
285 | timeout=10, **extra_args | |
265 | ): |
|
286 | ): | |
266 | super(Client, self).__init__(debug=debug, profile=profile) |
|
287 | if profile: | |
|
288 | super(Client, self).__init__(debug=debug, profile=profile) | |||
|
289 | else: | |||
|
290 | super(Client, self).__init__(debug=debug) | |||
267 | if context is None: |
|
291 | if context is None: | |
268 | context = zmq.Context.instance() |
|
292 | context = zmq.Context.instance() | |
269 | self._context = context |
|
293 | self._context = context | |
270 |
|
||||
271 |
|
294 | |||
272 | self._setup_profile_dir(profile, profile_dir, ipython_dir) |
|
295 | self._setup_profile_dir(self.profile, profile_dir, ipython_dir) | |
273 | if self._cd is not None: |
|
296 | if self._cd is not None: | |
274 | if url_or_file is None: |
|
297 | if url_or_file is None: | |
275 | url_or_file = pjoin(self._cd.security_dir, 'ipcontroller-client.json') |
|
298 | url_or_file = pjoin(self._cd.security_dir, 'ipcontroller-client.json') |
General Comments 0
You need to be logged in to leave comments.
Login now