Beispiel #1
0
def usage(progname):
    global Defaults
    
    ReplaceDic = {}
    VarsDic = vars();
    for Key in VarsDic.keys():
        ReplaceDic[Key] = VarsDic[Key]
    ListOfTestsData = AIStorageUtils.dict_sortbykey( TestData, AIStorageUtils.SORT_ASCENDING )
    ListOfSortedNames = []
    for Name, Dummy in ListOfTestsData:
        ListOfSortedNames.append(Name)
    ReplaceDic['AvailableTests'] = ','.join(ListOfSortedNames)
    
    print __doc__ % ReplaceDic
Beispiel #2
0
def main(argv):                  

    try:                                
        opts, args = getopt.getopt(argv, "h", ["help", "version"])
    except getopt.GetoptError:
        print "Error while converting options: unknown option(s) encountered.\n\n"
        usage(os.path.basename(sys.argv[0]))
        sys.exit(2)
    
    for opt, arg in opts:
        if opt in ("-h", "--help"):
            usage(os.path.basename(sys.argv[0]))
            sys.exit()
        elif opt in ["--version"]:
            version()
            sys.exit()
        else:
            print "Unknown parameter", opt
    
    if len(args) < 1:
        #print "Error: No sites file given.\n\n"
        #usage(os.path.basename(sys.argv[0]))
        #sys.exit(3)
        SitesFileName = "grid-sites.xml"
    else:
        SitesFileName = args[0];
        
    if not os.path.isfile( SitesFileName ):
        if os.path.exists( SitesFileName ):
            print "\n\n****\nError: %s is not a file!\n****\n" % SitesFileName
        else:
            print "\n\n****\nError: %s does not exist!\n****\n" % SitesFileName
        usage(os.path.basename(sys.argv[0]))
        sys.exit(1)
        
    #---Read a sites file
    #print "%s Parsing sites file %s" % \
    #      ( time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(time.time())), SitesFileName )
    handlerXML = WLDocHandlers.readSiteFile(SitesFileName)
    #print "%s Sites file processed, proceeding to submission"  % \
    #      time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(time.time()))  
    
    DictionaryOfSites = handlerXML.getDictionaryOfSites()
    ListOfSites = AIStorageUtils.dict_sortbykey( DictionaryOfSites, AIStorageUtils.SORT_DESCENDING )
    for (id, Site) in ListOfSites: 
        print id, Site['location'], Site['machines']
    print