def main(argv):
    input_folder = ''
    input_email = ''

    try:
        opts, args = getopt.getopt(argv,"hf:e:",["ffolder=","eemail="])
    except getopt.GetoptError:
        print 'test.py -f <folder> -e <email>'
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print 'globus_share.py -f <folder> -e <email>'
            sys.exit()
        elif opt in ("-f", "--ffolder"):
            input_folder = arg
        elif opt in ("-e", "--eemail"):
            input_email = arg
    
    input_folder = os.path.normpath(input_folder) + os.sep # will add the trailing slash if it's not already there.
    if validate_email(input_email) and os.path.isdir(local_folder + input_folder):

        globus_add = "acl-add " + local_user + local_share1 + os.sep + input_folder  + " --perm r --email " + input_email
        cmd =  globus_ssh + " " + globus_add
        print cmd
        print "ssh [email protected] acl-add decarlo#data/test/ --perm r --email [email protected]"
        #os.system(cmd)
        print "Download link sent to: ", input_email
    else:
        print "ERROR: "
        print "EXAMPLE: python globus_local_share.py -f test -e [email protected]"
        if not validate_email(input_email):
            print "email is not valid ..."
        else:
            print local_folder + input_folder, "does not exists under the Globus Personal Share folder"
        gb.settings()
def main(argv):
    input_folder = ''
    input_email = ''

    try:
        opts, args = getopt.getopt(argv,"hf:e:",["ffolder=","eemail="])
    except getopt.GetoptError:
        print 'test.py -f <folder> -e <email>'
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print 'globus_copy_share.py -f <folder> -e <email>'
            print 'copy data from globus connect personal ', local_user + local_share + os.sep + '<folder> to ' + remote_user + remote_share + os.sep + remote_folder
            print 'share data from', remote_user + remote_share + os.sep + remote_folder + "<folder>", ' with ' + "<email>"

            sys.exit()
        elif opt in ("-f", "--ffolder"):
            input_folder = arg
        elif opt in ("-e", "--eemail"):
            input_email = arg
    
    input_folder = os.path.normpath(input_folder) + os.sep # will add the trailing slash if it's not already there.

    path_list = remote_folder.split(os.sep)
    remote_data_share = path_list[len(path_list)-2] + os.sep + path_list[len(path_list)-1]


    globus_scp = "scp -r " + local_user + local_share1 + ":" + os.sep + input_folder + " " + remote_user + remote_share + ":" + os.sep + remote_data_share
    globus_add = "acl-add " + local_user + local_share2  + os.sep + input_folder + " --perm r --email " + input_email
    if validate_email(input_email) and os.path.isdir(local_folder + input_folder):
        cmd_1 = globus_ssh + " " + globus_scp
        cmd_2 = globus_ssh + " " + globus_add
        print cmd_1
        print "ssh [email protected] scp -r decarlo#data:/test/ petrel#tomography:/img/"
        #os.system(cmd1)
        print "Done data trasfer to: ", remote_user
        #os.system(cmd2)
        print cmd_2
        print "ssh [email protected] acl-add decarlo#img/test/ --perm r --email [email protected]"
        print "Download link sent to: ", input_email
    else:
        print "ERROR: "
        print "EXAMPLE: python globus_copy_remote_share.py -f test -e [email protected]"

        if not validate_email(input_email):
            print "email is not valid ..."
        else:
            print local_folder + input_folder, "does not exists under the Globus Personal Share folder"
        gb.settings()
Exemple #3
0
# POSSIBILITY OF SUCH DAMAGE.                                             #
# #########################################################################

"""
Module containing an example on how to use globus.py and scheduling.py to manage and 
distribute data

"""

import pytz
import datetime

import scheduling as sch
import globus as gb

gb.settings()

now = datetime.datetime(2014, 10, 18, 10, 10, 30).replace(tzinfo=pytz.timezone('US/Central'))
print "\n\nExperiment date: ", now

exp_start = sch.find_experiment_start(now)
print "Experiment starting date/time: ", exp_start

exp_id = sch.create_experiment_id(now)
print "Unique experiment ID: ", exp_id
                  
unique_directory = gb.create_unique_directory(exp_start, exp_id)

gb.upload(unique_directory)

users = sch.find_users(now)