Show More
@@ -28,6 +28,9 b' pjoin = os.path.join' | |||
|
28 | 28 | import zmq |
|
29 | 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 | 34 | from IPython.utils.jsonutil import rekey |
|
32 | 35 | from IPython.utils.path import get_ipython_dir |
|
33 | 36 | from IPython.utils.traitlets import (HasTraits, Int, Instance, Unicode, |
@@ -117,13 +120,14 b' class Client(HasTraits):' | |||
|
117 | 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 | 124 | Connection information for the Hub's registration. If a json connector |
|
122 | 125 | file is given, then likely no further configuration is necessary. |
|
123 | 126 | [Default: use profile] |
|
124 | 127 | profile : bytes |
|
125 | 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 | 131 | context : zmq.Context |
|
128 | 132 | Pass an existing zmq.Context instance, otherwise the client will create its own. |
|
129 | 133 | debug : bool |
@@ -237,7 +241,20 b' class Client(HasTraits):' | |||
|
237 | 241 | metadata = Instance('collections.defaultdict', (Metadata,)) |
|
238 | 242 | history = List() |
|
239 | 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 | 259 | _outstanding_dict = Instance('collections.defaultdict', (set,)) |
|
243 | 260 | _ids = List() |
@@ -258,18 +275,24 b' class Client(HasTraits):' | |||
|
258 | 275 | _ignored_control_replies=Int(0) |
|
259 | 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 | 283 | context=None, debug=False, exec_key=None, |
|
263 | 284 | sshserver=None, sshkey=None, password=None, paramiko=None, |
|
264 | 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 | 291 | if context is None: |
|
268 | 292 | context = zmq.Context.instance() |
|
269 | 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 | 296 | if self._cd is not None: |
|
274 | 297 | if url_or_file is None: |
|
275 | 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