##// END OF EJS Templates
Merge pull request #6087 from minrk/better-error-no-connection-file...
Min RK -
r18375:ce530ca4 merge
parent child Browse files
Show More
@@ -27,7 +27,7 b' from IPython.utils.capture import RichOutput'
27 from IPython.utils.coloransi import TermColors
27 from IPython.utils.coloransi import TermColors
28 from IPython.utils.jsonutil import rekey, extract_dates, parse_date
28 from IPython.utils.jsonutil import rekey, extract_dates, parse_date
29 from IPython.utils.localinterfaces import localhost, is_local_ip
29 from IPython.utils.localinterfaces import localhost, is_local_ip
30 from IPython.utils.path import get_ipython_dir
30 from IPython.utils.path import get_ipython_dir, compress_user
31 from IPython.utils.py3compat import cast_bytes, string_types, xrange, iteritems
31 from IPython.utils.py3compat import cast_bytes, string_types, xrange, iteritems
32 from IPython.utils.traitlets import (HasTraits, Integer, Instance, Unicode,
32 from IPython.utils.traitlets import (HasTraits, Integer, Instance, Unicode,
33 Dict, List, Bool, Set, Any)
33 Dict, List, Bool, Set, Any)
@@ -47,6 +47,7 b' from .view import DirectView, LoadBalancedView'
47 # Decorators for Client methods
47 # Decorators for Client methods
48 #--------------------------------------------------------------------------
48 #--------------------------------------------------------------------------
49
49
50
50 @decorator
51 @decorator
51 def spin_first(f, self, *args, **kwargs):
52 def spin_first(f, self, *args, **kwargs):
52 """Call spin() to sync state prior to calling the method."""
53 """Call spin() to sync state prior to calling the method."""
@@ -58,6 +59,10 b' def spin_first(f, self, *args, **kwargs):'
58 # Classes
59 # Classes
59 #--------------------------------------------------------------------------
60 #--------------------------------------------------------------------------
60
61
62 _no_connection_file_msg = """
63 Failed to connect because no Controller could be found.
64 Please double-check your profile and ensure that a cluster is running.
65 """
61
66
62 class ExecuteReply(RichOutput):
67 class ExecuteReply(RichOutput):
63 """wrapper for finished Execute results"""
68 """wrapper for finished Execute results"""
@@ -382,6 +387,11 b' class Client(HasTraits):'
382
387
383 self._setup_profile_dir(self.profile, profile_dir, ipython_dir)
388 self._setup_profile_dir(self.profile, profile_dir, ipython_dir)
384
389
390 no_file_msg = '\n'.join([
391 "You have attempted to connect to an IPython Cluster but no Controller could be found.",
392 "Please double-check your configuration and ensure that a cluster is running.",
393 ])
394
385 if self._cd is not None:
395 if self._cd is not None:
386 if url_file is None:
396 if url_file is None:
387 if not cluster_id:
397 if not cluster_id:
@@ -389,10 +399,19 b' class Client(HasTraits):'
389 else:
399 else:
390 client_json = 'ipcontroller-%s-client.json' % cluster_id
400 client_json = 'ipcontroller-%s-client.json' % cluster_id
391 url_file = pjoin(self._cd.security_dir, client_json)
401 url_file = pjoin(self._cd.security_dir, client_json)
402 if not os.path.exists(url_file):
403 msg = '\n'.join([
404 "Connection file %r not found." % compress_user(url_file),
405 no_file_msg,
406 ])
407 raise IOError(msg)
392 if url_file is None:
408 if url_file is None:
393 raise ValueError(
409 raise IOError(no_file_msg)
394 "I can't find enough information to connect to a hub!"
410
395 " Please specify at least one of url_file or profile."
411 if not os.path.exists(url_file):
412 # Connection file explicitly specified, but not found
413 raise IOError("Connection file %r not found. Is a controller running?" % \
414 compress_user(url_file)
396 )
415 )
397
416
398 with open(url_file) as f:
417 with open(url_file) as f:
General Comments 0
You need to be logged in to leave comments. Login now