boopak.fetch
index
boopak/fetch.py

fetch: Utility classes for downloading a file from a server.
 
This is used by PackageCollection to fetch packages from an archive
server.

 
Modules
       
urllib

 
Classes
       
builtins.object
Fetcher
URLFetcher

 
class Fetcher(builtins.object)
    Fetcher(loader)
 
Fetcher: represents a file which is being downloaded from a web
site, or some other source which potentially take a while.
 
The idea is to use this object in a loop:
 
    while (not fetcher.is_done()):
        fetcher.work()
 
One could equally well manage several fetchers in parallel. (But, see
the caveat in URLFetcher.)
 
Fetcher(loader) -- constructor
 
The argument must be a PackageCollection. (When the download is complete,
the loader's downloaded_files map will be updated.)
 
(This is an abstract base class, so creating a Fetcher is not of
any particular use.)
 
  Methods defined here:
__init__(self, loader)
Initialize self.  See help(type(self)) for accurate signature.
is_done(self)
is_done() -> bool
 
Return whether the fetching process is complete.
work(self)
work() -> None
 
Do another increment of work.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class URLFetcher(Fetcher)
    URLFetcher(loader, url, filename)
 
URLFetcher: represents a file which is being downloaded via a URL.
 
URLFetcher(loader, url, filename) -- constructor
 
The loader argument must be a PackageCollection. The URL is the one
to download; the data will be written to filename. (The directory
containing filename must exist already.)
 
Caveat: Python's urllib2 always uses a blocking socket. Therefore,
any call to work() may take arbitrarily long. (It will actually take
as long as necessary to get another 1000 bytes. Which could be forever.)
This is not the way the Fetcher class is supposed to work, but it's what
we've got.
 
 
Method resolution order:
URLFetcher
Fetcher
builtins.object

Methods defined here:
__del__(self)
__init__(self, loader, url, filename)
Initialize self.  See help(type(self)) for accurate signature.
closeall(self)
closeall() ->
 
Close the in (HTTP) and out (file write) streams, if necessary.
 
(This is an internal method. Do not call.)
is_done(self)
is_done() -> bool
 
Return whether the fetching process is complete.
work(self)
work() -> None
 
Do another increment of work. If the download is complete, close
the files.

Data descriptors inherited from Fetcher:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)