"""
import os, re
-from oe import *
+import oe
+import oe.data
class FetchError(Exception):
"""Exception raised when a download fails"""
def go():
"""Fetch all urls"""
for m in methods:
- m.go()
+ if m.urls:
+ m.go()
def localpaths():
"""Return a list of the local filenames, assuming successful fetch"""
def __init__(self, urls = []):
self.urls = []
for url in urls:
- if self.supports(decodeurl(url)) is 1:
+ if self.supports(oe.decodeurl(url)) is 1:
self.urls.append(url)
def supports(url):
"""Check to see if a given url can be fetched using wget.
Expects supplied url in list form, as outputted by oe.decodeurl().
"""
- (type, host, path, user, pswd, parm) = decodeurl(expand(url))
+ (type, host, path, user, pswd, parm) = oe.decodeurl(oe.expand(url))
return type in ['http','https','ftp']
supports = staticmethod(supports)
def localpath(url):
# strip off parameters
- (type, host, path, user, pswd, parm) = decodeurl(expand(url))
+ (type, host, path, user, pswd, parm) = oe.decodeurl(oe.expand(url))
if parm.has_key("localpath"):
# if user overrides local path, use it.
return parm["localpath"]
- url = encodeurl([type, host, path, user, pswd, {}])
- return os.path.join(getenv("DL_DIR"), os.path.basename(url))
+ url = oe.encodeurl([type, host, path, user, pswd, {}])
+ return os.path.join(oe.getenv("DL_DIR"), os.path.basename(url))
localpath = staticmethod(localpath)
def go(self, urls = []):
urls = self.urls
for loc in urls:
- (type, host, path, user, pswd, parm) = decodeurl(expand(loc))
+ (type, host, path, user, pswd, parm) = oe.decodeurl(oe.expand(loc))
myfile = os.path.basename(path)
dlfile = self.localpath(loc)
- myfetch = getenv("RESUMECOMMAND")
- note("fetch " +loc)
- myfetch = myfetch.replace("${URI}",encodeurl([type, host, path, user, pswd, {}]))
+ myfetch = oe.getenv("RESUMECOMMAND")
+ oe.note("fetch " +loc)
+ myfetch = myfetch.replace("${URI}",oe.encodeurl([type, host, path, user, pswd, {}]))
myfetch = myfetch.replace("${FILE}",myfile)
- debug(2,myfetch)
+ oe.debug(2,myfetch)
myret = os.system(myfetch)
if myret != 0:
raise FetchError(myfile)
"""Check to see if a given url can be fetched with cvs.
Expects supplied url in list form, as outputted by oe.decodeurl().
"""
- (type, host, path, user, pswd, parm) = decodeurl(expand(url))
+ (type, host, path, user, pswd, parm) = oe.decodeurl(oe.expand(url))
return type in ['cvs', 'pserver']
supports = staticmethod(supports)
def localpath(url):
- (type, host, path, user, pswd, parm) = decodeurl(expand(url))
+ (type, host, path, user, pswd, parm) = oe.decodeurl(oe.expand(url))
if parm.has_key("localpath"):
# if user overrides local path, use it.
return parm["localpath"]
if not parm.has_key("module"):
return url
else:
- return os.path.join(getenv("DL_DIR"), parm["module"])
+ return os.path.join(oe.getenv("DL_DIR"), parm["module"])
localpath = staticmethod(localpath)
def go(self, urls = []):
urls = self.urls
for loc in urls:
- (type, host, path, user, pswd, parm) = decodeurl(expand(loc))
+ (type, host, path, user, pswd, parm) = oe.decodeurl(oe.expand(loc))
if not parm.has_key("module"):
raise MissingParameterError("cvs method needs a 'module' parameter")
else:
else:
method = "pserver"
- os.chdir(expand(dldir))
+ os.chdir(oe.expand(dldir))
cvsroot = ":" + method + ":" + user
if pswd is not None:
cvsroot += ":" + pswd
cvscmd = "cvs -d" + cvsroot
cvscmd += " checkout " + string.join(options) + " " + module
- note("fetch " + loc)
+ oe.note("fetch " + loc)
myret = os.system(cvscmd)
if myret != 0:
raise FetchError(module)
"""Check to see if a given url can be fetched via bitkeeper.
Expects supplied url in list form, as outputted by oe.decodeurl().
"""
- (type, host, path, user, pswd, parm) = decodeurl(expand(url))
+ (type, host, path, user, pswd, parm) = oe.decodeurl(oe.expand(url))
return type in ['bk']
supports = staticmethod(supports)
"""Check to see if a given url can be fetched in the local filesystem.
Expects supplied url in list form, as outputted by oe.decodeurl().
"""
- (type, host, path, user, pswd, parm) = decodeurl(expand(url))
+ (type, host, path, user, pswd, parm) = oe.decodeurl(oe.expand(url))
return type in ['file','patch']
supports = staticmethod(supports)