##// END OF EJS Templates
introduce is_url() replacing validate_url() in cases where it is used in a control structure (as opposed to an assert)
Hannes Schulz -
Show More
@@ -306,9 +306,7 b' class Client(HasTraits):'
306 assert url_or_file is not None, "I can't find enough information to connect to a hub!"\
306 assert url_or_file is not None, "I can't find enough information to connect to a hub!"\
307 " Please specify at least one of url_or_file or profile."
307 " Please specify at least one of url_or_file or profile."
308
308
309 try:
309 if not is_url(url_or_file):
310 util.validate_url(url_or_file)
311 except AssertionError:
312 if not os.path.exists(url_or_file):
310 if not os.path.exists(url_or_file):
313 if self._cd:
311 if self._cd:
314 url_or_file = os.path.join(self._cd.security_dir, url_or_file)
312 url_or_file = os.path.join(self._cd.security_dir, url_or_file)
@@ -108,6 +108,15 b' def asbytes(s):'
108 s = s.encode('ascii')
108 s = s.encode('ascii')
109 return s
109 return s
110
110
111 def is_url(url):
112 """boolean check for whether a string is a zmq url"""
113 if '://' not in url:
114 return False
115 proto, addr = url.split('://', 1)
116 if proto.lower() not in ['tcp','pgm','epgm','ipc','inproc']:
117 return False
118 return True
119
111 def validate_url(url):
120 def validate_url(url):
112 """validate a url for zeromq"""
121 """validate a url for zeromq"""
113 if not isinstance(url, basestring):
122 if not isinstance(url, basestring):
General Comments 0
You need to be logged in to leave comments. Login now