Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The constructor of Client() checks for AssertionError in validate_url to open a file instead of connection to a URL if it fails. #872

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions IPython/parallel/client/client.py
Expand Up @@ -306,9 +306,7 @@ def __init__(self, url_or_file=None, profile=None, profile_dir=None, ipython_dir
assert url_or_file is not None, "I can't find enough information to connect to a hub!"\
" Please specify at least one of url_or_file or profile."

try:
util.validate_url(url_or_file)
except AssertionError:
if not is_url(url_or_file):
if not os.path.exists(url_or_file):
if self._cd:
url_or_file = os.path.join(self._cd.security_dir, url_or_file)
Expand Down
9 changes: 9 additions & 0 deletions IPython/parallel/util.py
Expand Up @@ -108,6 +108,15 @@ def asbytes(s):
s = s.encode('ascii')
return s

def is_url(url):
"""boolean check for whether a string is a zmq url"""
if '://' not in url:
return False
proto, addr = url.split('://', 1)
if proto.lower() not in ['tcp','pgm','epgm','ipc','inproc']:
return False
return True

def validate_url(url):
"""validate a url for zeromq"""
if not isinstance(url, basestring):
Expand Down