From bc86f8b81f729ac556b480c6a6cb6a19e3409ebb 2011-10-17 23:17:53 From: Hannes Schulz Date: 2011-10-17 23:17:53 Subject: [PATCH] introduce is_url() replacing validate_url() in cases where it is used in a control structure (as opposed to an assert) --- diff --git a/IPython/parallel/client/client.py b/IPython/parallel/client/client.py index 4d93d84..167a8b1 100644 --- a/IPython/parallel/client/client.py +++ b/IPython/parallel/client/client.py @@ -306,9 +306,7 @@ class Client(HasTraits): 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) diff --git a/IPython/parallel/util.py b/IPython/parallel/util.py index b9a5153..222b49d 100644 --- a/IPython/parallel/util.py +++ b/IPython/parallel/util.py @@ -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):