transfer server
Robert Olson
olson at mcs.anl.gov
Thu Feb 20 16:34:53 CST 2003
oh, and you can use the DataStore.GSIDownloadFile(url, destination_file,
size, checksum) function to effect the download. See the new
AccessGrid/tests/test_datastore_{put,get}.py.
--bob
At 04:31 PM 2/20/2003 -0600, Robert Olson wrote:
>the refactored transfer server should do what you want now. I'm waiting to
>commit changes until ivan gets his fixes in, but here is what the code
>will sort of look lke (from teh bottom of the datastore module).
>
>What you'd do is define a handler class that answers GetDownloadFilename
>with the pathname of the things you want to export. The URLs to those
>things are generated by calling the GetDownloadDescriptor method on the
>transfer server. You'll need to register a prefix for your downloads like
>I do below.
>
>If you have CanUploadFile return 0 and GetUploadFilename returnm, upload
>attempts will fail.
>
>--bob
>
>
> s = GSIHTTPTransferServer(('', 9011))
>
> class Handler:
> def GetDownloadFilename(self, id_token, url_path):
> print "Get download: id='%s' path='%s'" % (id_token, url_path)
> return r"c:\temp\junoSetup.exe"
>
> def GetUploadFilename(self, id_token, file_info):
> print "Get upload filename for %s %s" % (id_token, file_info)
> return os.path.join("c:\\", "temp", "uploads", file_info['name'])
>
> def CanUploadFile(self, id_token, file_info):
> print "CanUpload: id=%s file_info=%s" % (id_token, file_info)
> return 1
>
> def AddPendingUpload(self, id_token, filename):
> print "AddPendingUpload: %s %s" % (id_token, filename)
>
> def CompleteUpload(self, id_token, file_info):
> print "CompleteUpload %s %s" % (id_token, file_info)
>
> prefix = "test"
> s.RegisterPrefix(prefix, Handler())
>
> print s.GetDownloadDescriptor(prefix, "JunoSetup.exe")
> print s.GetUploadDescriptor(prefix)
>
> s.run()
>
> try:
> while 1:
> time.sleep(.1)
>
> except:
> os._exit(0)
More information about the ag-dev
mailing list