Hi, that could be useful for the unzip part: http://www.web2py.com/examples/static/epydoc/web2py.gluon.admin-pysrc.html#unzip
And that could be used/customized for the downloading part (Its taken from the great clienttools module: http://www.web2pyslices.com/main/slices/take_slice/8): def __init__(self, environment): self.environment = Storage(environment) self.resources = [] self.onready = [] def include(self, path, download=False, overwrite=False, subfolder=None): request = self.environment.request out = path if hasattr(path, 'xml'): out = path.xml() if download and path.startswith("http://"): if not request.env.web2py_runtime_gae: fname = valid_filename(path.split("/")[-1]) if len(fname): pieces = (request.folder, 'static', subfolder) fld = os.path.join(*(x for x in pieces if x)) if not os.path.exists(fld): os.mkdir(fld) fpath = os.path.join(fld,fname) exists = os.path.exists(fpath) if (not exists) or (exists and overwrite): urllib.urlretrieve(path, fpath) out = URL(r=request,c='/'.join( x for x in ['static', subfolder] if x),f=fname) self.resources.append(out) On 18 Jun., 15:12, scausten <scaus...@googlemail.com> wrote: > Should have tried harder myself - this works, but is there a better > way of doing it? > > filename, headers = urllib.urlretrieve(link, path.join(os.getcwd(), > "applications", request.application, "uploads", "foo.zip")) > > On Jun 18, 1:56 pm, scausten <scaus...@googlemail.com> wrote: > > > I'm trying to download (using urllib.urlretrieve) a remote file into > > my application. It's a zip file containing an IP-to-country lookup > > table. I want to download the zip to the application's file system > > (probably 'uploads'), unzip it, process the csv and then import the > > sanitised data into my ip-to-country database (using > > import_from_csv_file). > > > How should I specify/access locations in the filesystem?