-from sfa.util.sfalogging import sfa_logger,sfa_logger_goes_to_console
-import sfa.util.xmlrpcprotocol as xmlrpcprotocol
-
-m_url_with_proto=re.compile("\w+://(?P<hostname>[\w\-\.]+):(?P<port>[0-9]+).*")
-m_url_without_proto=re.compile("(?P<hostname>[\w\-\.]+):(?P<port>[0-9]+).*")
-def url_to_hostname_port (url):
- match=m_url_with_proto.match(url)
- if match:
- return (match.group('hostname'),match.group('port'))
- match=m_url_without_proto.match(url)
- if match:
- return (match.group('hostname'),match.group('port'))
- return ('undefined','???')
+from sfa.util.sfalogging import logger, DEBUG
+import sfa.client.xmlrpcprotocol as xmlrpcprotocol
+
+def url_hostname_port (url):
+ if url.find("://")<0:
+ url="http://"+url
+ parsed_url=urlparse(url)
+ # 0(scheme) returns protocol
+ default_port='80'
+ if parsed_url[0]=='https': default_port='443'
+ # 1(netloc) returns the hostname+port part
+ parts=parsed_url[1].split(":")
+ # just a hostname
+ if len(parts)==1:
+ return (url,parts[0],default_port)
+ else:
+ return (url,parts[0],parts[1])