Exemple #1
0
            if o == "-" + key.split(",")[0] or o == "--" + key.split(",")[1]:
                opts_left.remove(key.split(",")[0])
                if "," in value:
                    ret_val[value.split(",")[0]] = a.split(",")[0]
                    ret_val[value.split(",")[1]] = a.split(",")[1]
                else:
                    ret_val[value] = a

    if len(opts_left) == 0 or len(opts_left) == len(options):
        return ret_val
    else:
        return "bad"


# Create a new UCVM object.
u = UCVM()

ret_val = get_user_opts({"b,bottomleft":"lat1,lon1", "u,upperright":"lat2,lon2", \
                         "s,spacing":"spacing", "c,cvm":"cvm_selected"})

if ret_val == "bad":
    usage()
    exit(1)
elif len(ret_val) > 0:
    print "Using parameters:\n"
    for key, value in ret_val.iteritems():
        print key + " = " + value
        try:
            float(value)
            exec("%s = float(%s)" % (key, value))
        except StandardError, e:
    installdir = None
    configfile = None

    # Ask if a different installdir should be  used
    cwd = os.getcwd()
    installdir = ask_path(
        "Do you want to use different UCVM install directory", cwd + "/..")
    # Ask if a different ucvm.conf should be  used
    configfile = ask_file("Do you want to use different ucvm.conf file",
                          cwd + "/../ucvm.conf")

    # Ask which CVMs to use.
    print "\nFrom which CVM would you like this data to come:"

    # Create a new UCVM object.
    u = UCVM(install_dir=installdir, config_file=configfile)

    for cvm in u.models:
        cvmtoprint = cvm
        if cvm in UCVM_CVMS:
            cvmtoprint = UCVM_CVMS[cvm]
        corresponding_cvm.append(cvm)
        print "\t%d) %s" % (counter, cvmtoprint)
        counter += 1

    cvm_selected = -1
    while cvm_selected < 0 or cvm_selected > counter:
        cvm_selected = int(ask_number("\nSelect the CVM: ")) - 1

        if cvm_selected < 0 or cvm_selected > counter:
            print "Error: the number you selected must be between 1 and %d" % counter