def download(self, ud, d): """Fetch urls""" urlo = URI(ud.url) basecmd = 'sftp -oBatchMode=yes' port = '' if urlo.port: port = '-P %d' % urlo.port urlo.port = None dldir = data.getVar('DL_DIR', d, True) lpath = os.path.join(dldir, ud.localfile) user = '' if urlo.userinfo: user = urlo.userinfo + '@' path = urlo.path # Supoprt URIs relative to the user's home directory, with # the tilde syntax. (E.g. <sftp://example.com/~/foo.diff>). if path[:3] == '/~/': path = path[3:] remote = '%s%s:%s' % (user, urlo.hostname, path) cmd = '%s %s %s %s' % (basecmd, port, remote, lpath) bb.fetch2.check_network_access(d, cmd, ud.url) runfetchcmd(cmd, d) return True
def download(self, ud, d): """Fetch urls""" urlo = URI(ud.url) basecmd = "sftp -oPasswordAuthentication=no" port = "" if urlo.port: port = "-P %d" % urlo.port urlo.port = None dldir = data.getVar("DL_DIR", d, True) lpath = os.path.join(dldir, ud.localfile) user = "" if urlo.userinfo: user = urlo.userinfo + "@" path = urlo.path # Supoprt URIs relative to the user's home directory, with # the tilde syntax. (E.g. <sftp://example.com/~/foo.diff>). if path[:3] == "/~/": path = path[3:] remote = "%s%s:%s" % (user, urlo.hostname, path) cmd = "%s %s %s %s" % (basecmd, port, commands.mkarg(remote), commands.mkarg(lpath)) bb.fetch2.check_network_access(d, cmd, ud.url) runfetchcmd(cmd, d) return True
def test_dict(self): for test in self.test_uris.values(): uri = URI() self.assertEqual(uri.scheme, '') self.assertEqual(uri.userinfo, '') self.assertEqual(uri.username, '') self.assertEqual(uri.password, '') self.assertEqual(uri.hostname, '') self.assertEqual(uri.port, None) self.assertEqual(uri.path, '') self.assertEqual(uri.params, {}) uri.scheme = test['scheme'] self.assertEqual(uri.scheme, test['scheme']) uri.userinfo = test['userinfo'] self.assertEqual(uri.userinfo, test['userinfo']) self.assertEqual(uri.username, test['username']) self.assertEqual(uri.password, test['password']) # make sure changing the values doesn't do anything unexpected uri.username = '******' self.assertEqual(uri.username, 'changeme') self.assertEqual(uri.password, test['password']) uri.password = '******' self.assertEqual(uri.username, 'changeme') self.assertEqual(uri.password, 'insecure') # reset back after our trickery uri.userinfo = test['userinfo'] self.assertEqual(uri.userinfo, test['userinfo']) self.assertEqual(uri.username, test['username']) self.assertEqual(uri.password, test['password']) uri.hostname = test['hostname'] self.assertEqual(uri.hostname, test['hostname']) self.assertEqual(uri.hostport, test['hostname']) uri.port = test['port'] self.assertEqual(uri.port, test['port']) self.assertEqual(uri.hostport, test['hostport']) uri.path = test['path'] self.assertEqual(uri.path, test['path']) uri.params = test['params'] self.assertEqual(uri.params, test['params']) uri.query = test['query'] self.assertEqual(uri.query, test['query']) self.assertEqual(str(uri), test['uri']) uri.params = {} self.assertEqual(uri.params, {}) self.assertEqual(str(uri), (str(uri).split(";"))[0])
def test_dict(self): for test in self.test_uris.values(): uri = URI() self.assertEqual(uri.scheme, '') self.assertEqual(uri.userinfo, '') self.assertEqual(uri.username, '') self.assertEqual(uri.password, '') self.assertEqual(uri.hostname, '') self.assertEqual(uri.port, None) self.assertEqual(uri.path, '') self.assertEqual(uri.params, {}) uri.scheme = test['scheme'] self.assertEqual(uri.scheme, test['scheme']) uri.userinfo = test['userinfo'] self.assertEqual(uri.userinfo, test['userinfo']) self.assertEqual(uri.username, test['username']) self.assertEqual(uri.password, test['password']) uri.hostname = test['hostname'] self.assertEqual(uri.hostname, test['hostname']) self.assertEqual(uri.hostport, test['hostname']) uri.port = test['port'] self.assertEqual(uri.port, test['port']) self.assertEqual(uri.hostport, test['hostport']) uri.path = test['path'] self.assertEqual(uri.path, test['path']) uri.params = test['params'] self.assertEqual(uri.params, test['params']) self.assertEqual( str(uri) + str(uri.relative), str(test['uri']) + str(test['relative'])) self.assertEqual(str(uri), test['uri']) uri.params = {} self.assertEqual(uri.params, {}) self.assertEqual(str(uri), (str(uri).split(";"))[0])
def test_dict(self): for test in self.test_uris.values(): uri = URI() self.assertEqual(uri.scheme, '') self.assertEqual(uri.userinfo, '') self.assertEqual(uri.username, '') self.assertEqual(uri.password, '') self.assertEqual(uri.hostname, '') self.assertEqual(uri.port, None) self.assertEqual(uri.path, '') self.assertEqual(uri.params, {}) uri.scheme = test['scheme'] self.assertEqual(uri.scheme, test['scheme']) uri.userinfo = test['userinfo'] self.assertEqual(uri.userinfo, test['userinfo']) self.assertEqual(uri.username, test['username']) self.assertEqual(uri.password, test['password']) uri.hostname = test['hostname'] self.assertEqual(uri.hostname, test['hostname']) self.assertEqual(uri.hostport, test['hostname']) uri.port = test['port'] self.assertEqual(uri.port, test['port']) self.assertEqual(uri.hostport, test['hostport']) uri.path = test['path'] self.assertEqual(uri.path, test['path']) uri.params = test['params'] self.assertEqual(uri.params, test['params']) self.assertEqual(str(uri)+str(uri.relative), str(test['uri'])+str(test['relative'])) self.assertEqual(str(uri), test['uri']) uri.params = {} self.assertEqual(uri.params, {}) self.assertEqual(str(uri), (str(uri).split(";"))[0])