def checkHostURL(self): self.hostpath = self.userinput self.url = "ftp://" + self.hostpath # if no non-anon user, this is it. try: net_utils.sanityCheckUrl(self.url, expectedProtocols=['ftp']) except ValueError, msg: log.error(msg[0]) body = '\n'.join(['Invalid URL', msg[0], TransMenu.Back]) self.errorPushPop(self.title, body) return
def checkHostURL(self): self.url = self.userinput try: net_utils.sanityCheckUrl(self.url, expectedProtocols=['http', 'https']) except ValueError, msg: log.error(msg[0]) body = '\n'.join(['Invalid URL', msg[0], TransMenu.Back]) self.errorPushPop(self.title, body) return
def validateInstallURL(flagName, url): '''Test whether a string is a valid URL for the "install" command. >>> validateInstallURL('url', 'http://foobar.com:80/path') (1, [], []) >>> validateInstallURL('url', 'nfs') (1, [], []) >>> validateInstallURL('url', 'ftp://127.0.0.1/path') (1, [], []) >>> validateInstallURL('url', 'foo://hostname/path') (0, ['url is not one of the supported schemes: http, ftp', 'Hostname must be at least one character.'], []) >>> validateInstallURL('url', 'http://300.2.3.4/path') (0, ['IP string contains an invalid octet.'], []) ''' if url == "nfs": # Takes care of 'install nfs --dir=... --server=...' return makeResult([], []) errors = [] try: sanityCheckUrl(url) except ValueError, msg: errors.append(str(msg))