Example #1
0
def retrieve_files(host, filelist, destdir='.', indicator=None):
   """
   <Purpose>
      This retrieves files from a host to a destdir.

   <Arguments>
      host:
         'host' holds two things, a server name and target directory.
         For example, if you want to retrieve files from '/tmp/' directory
         in 'quadrus.cs.arizona.edu' server, the 'host' will be
         'quadrus.cs.arizona.edu/tmp'.

      filelist:
         'filelist' is a list of files which need to be retrieved.

      destdir:
         'destdir' is a destination directory where retrieved files will
         be placed. A user should have 'destdir' exist before retrieving
         files. 'destdir' should be a string. Default is a current dir.

      indicator:
         'indicator' is a module which has set_filename and
         download_indicator functions. 'indicator' will be passed in
         'urlretrieve' function so that progress bar will be shown
         while downloading files. Default is 'None'.

   <Exceptions>
      None.

   <Side Effects>
      None.

   <Returns>
      (True, grabbed_list)
      'grabbed_list' is a list of files which are retrieved
   """
   
   # use the cache
   return arizonatransfer_iftd.retrieve_files(host, filelist, destdir, indicator, True)
sys.path.append("../../../2.0/python")
sys.path.append("/usr/lib/python2.5/site-packages/transfer")

import arizonatransfer_iftd as arizonatransfer

rc = arizonatransfer.init_transfer_program( None, None, None, None )

assert rc == True, "init_transfer_program failed!"


filedat = {
   "filename" : "X1Hi1.gif",
   "hashfuncs" : "default",
   "size" : 53966,
   "hash" : 'da2056c2062dfb52102756568e6c5a1982c5aa36'
}

rc, file_list = arizonatransfer.retrieve_files( "i.imgur.com", [filedat], "/tmp/iftd/files", None, nestmode=False )

assert rc == True, "retrieve_files failed!"

print "files retrieved:"
for file in file_list:
   print "   " + str(file)

rc = arizonatransfer.close_transfer_program()

assert rc == True, "close_transfer_program failed!"