Commit b1a9c3ff authored by Roland Haas's avatar Roland Haas
Browse files

add python code to showcase how to use module

parent e10a6f9a
#!/usr/bin/env python
import os
import globustransferhelper as globushl
# create the helper, this logs you in
helper = globushl.GlobusTransferHelper()
# show the content of your $HOME on BlueWaters
print("Your $HOME contains (down to 2 levels):")
files = helper.ls(globushl.EP_BLUEWATERS, "~", depth=2)
for file in files:
print("%s (%s) [%d bytes]" % \
(file, files[file]['type'], files[file]['size']))
# create a file an duplicate it using globus
foxfile = "%s/%s-foxfile" % (os.getcwd(), os.environ["USER"])
houndfile = "%s/%s-houndfile" % (os.getcwd(), os.environ["USER"])
with open(foxfile, "w") as fh:
fh.write("The quick brown fox jumps over the lazy dog\n")
print("Copying %s to %s" % (foxfile, houndfile))
transfer = helper.transfer(globushl.EP_BLUEWATERS, globushl.EP_BLUEWATERS,
[(foxfile, houndfile)])
helper.task_wait(transfer)
with open(houndfile, "r") as fh:
print("Hounds contains:", fh.readlines())
print("done")
# get rid of files
print("Removing files")
helper.delete(globushl.EP_BLUEWATERS, [foxfile, houndfile])
print("All done")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment