Пример #1
0
def validateArgs():
    parser = UsageArgumentParser.UsageArgumentParser(prog='publishGFE', conflict_handler="resolve")
    parser.add_argument("-h", action="store", dest="host",
                      help="where the ifpServer is running", 
                      required=True, metavar="hostname")
    parser.add_argument("-r", action="store", type=int, dest="port", 
                      help="the port that ifpServer is serving",
                      required=True, metavar="portNumber")
    parser.add_argument("-t", action="store", dest="definedTR", 
                      help="(Optional) named time range, supersedes -s and -e",
                      default="", metavar="namedTR")
    parser.add_argument("-s", action=StoreTimeAction, dest="sT", 
                      help="(Optional) start time, format = yyyymmdd_hhmm", 
                      metavar="startTime")
    parser.add_argument("-e", action=StoreTimeAction, dest="eT", 
                      help="(Optional) end time, format = yyyymmdd_hhmm", 
                      metavar="endTime")
    parser.add_argument("-u", action="store", dest="user", 
                      help="(Optional) user, defaults to SITE",
                      default="SITE", metavar="user")
    parser.add_argument("-o", action="store", dest="site", 
                      help="(Optional) site to publish grids for, defaults to server's primary site",
                      metavar="site")
    parser.add_argument("-p", action=AppendParmNameAndLevelAction, dest="parmNamesAndLevels", 
                      help="(Optional) parm, can have multiple switches; if none, defaults to all parms.",
                      default=[], metavar="parm")
    options = parser.parse_args()
    
    tr = TimeRange.allTimes()
    if options.sT is not None:
        tr.setStart(options.sT)
    if options.eT is not None:
        tr.setEnd(options.eT)
    setattr(options, 'tr', tr)
    
    return options
Пример #2
0
def validateArgs():
    parser = UsageArgumentParser.UsageArgumentParser(prog='publishGFE', conflict_handler="resolve")
    parser.add_argument("-h", action="store", dest="host",
                      help="where the ifpServer is running", 
                      required=True, metavar="hostname")
    parser.add_argument("-r", action="store", type=int, dest="port", 
                      help="the port that ifpServer is serving",
                      required=True, metavar="portNumber")
    parser.add_argument("-t", action="store", dest="definedTR", 
                      help="(Optional) named time range, supersedes -s and -e",
                      default="", metavar="namedTR")
    parser.add_argument("-s", action=StoreTimeAction, dest="sT", 
                      help="(Optional) start time, format = yyyymmdd_hhmm", 
                      metavar="startTime")
    parser.add_argument("-e", action=StoreTimeAction, dest="eT", 
                      help="(Optional) end time, format = yyyymmdd_hhmm", 
                      metavar="endTime")
    parser.add_argument("-u", action="store", dest="user", 
                      help="(Optional) user, defaults to SITE",
                      default="SITE", metavar="user")
    parser.add_argument("-o", action="store", dest="site", 
                      help="(Optional) site to publish grids for, defaults to server's primary site",
                      metavar="site")
    parser.add_argument("-p", action=AppendParmNameAndLevelAction, dest="parmNamesAndLevels", 
                      help="(Optional) parm, can have multiple switches; if none, defaults to all parms.",
                      default=[], metavar="parm")
    options = parser.parse_args()
    
    tr = TimeRange.allTimes()
    if options.sT is not None:
        tr.setStart(options.sT)
    if options.eT is not None:
        tr.setEnd(options.eT)
    setattr(options, 'tr', tr)
    
    return options
Пример #3
0
def decodeArguments():
    parser = UsageArgumentParser.UsageArgumentParser(
        prog='ifpAG',
        conflict_handler="resolve",
        usage=
        """ifpAG -o outputFile -h hostname -r rpcPortNumber -d databaseID [-p parmID] [-s startTime] [-e endTime] [-u username] [-c coordConversionString]
or
ifpAG -i inputFile -h hostname -r rpcPortNumber [-u username]
""")
    modeGroup = parser.add_mutually_exclusive_group(required=True)
    modeGroup.add_argument("-o",
                           action="store",
                           dest="outputFile",
                           help="Specifies the name of the output file.",
                           metavar="outputFile")
    modeGroup.add_argument("-i",
                           action="store",
                           dest="inputFile",
                           help="Specifies the name of the input file.",
                           metavar="inputFile")
    parser.add_argument(
        "-h",
        action="store",
        dest="hostname",
        help="""Host name upon which the EDEX server is running. 
                              Please specify the host name of the server.""",
        required=True,
        metavar="hostname")
    parser.add_argument("-r",
                        action="store",
                        type=int,
                        dest="portNumber",
                        help="the port that ifpServer is serving",
                        required=True,
                        metavar="portNumber")
    parser.add_argument(
        "-u",
        action="store",
        dest="userName",
        help="If no username is specified, then your username is used.",
        metavar="username")
    parser.add_argument(
        "-d",
        action=AppendDatabaseIDAction,
        dest="databaseIds",
        help="""DatabaseID from which to get the data.  There may
                              be several DatabaseIDs specified.
                             format: (DEN_GRID__eta_19980604_1200)""",
        metavar="databaseID")
    parser.add_argument("-p",
                        action="append",
                        dest="parmNames",
                        help="""If none specified, get all parms for
                               all databases listed.  There may be several
                               parmIDs specified.
                               format: (Temp)""",
                        metavar="parmID")
    parser.add_argument("-s",
                        action=StoreTimeAction,
                        dest="startTime",
                        help="""If no start time specified, make start
                              time = 0. format: (19980604_1200)""",
                        metavar="startTime")
    parser.add_argument("-e",
                        action=StoreTimeAction,
                        dest="endTime",
                        help="""If no end time specified, make end
                              time = Abstime::MaxFutureTime().
                              format: (19980604_1200)""",
                        metavar="endTime")
    parser.add_argument("-c",
                        action="store",
                        dest="coordConversionString",
                        help="""If no coordinate conversion string
                               is specified, then output is done in the
                               server's inherinet resolution. Must be quoted.
                             String format:
                             xsize ysize projID originX originY extentX extentY
                             "35 35 Grid211 35.0 14.0 9.0 9.0"
                             Coord conversion is automatic on input.""",
                        metavar="coordinateConversionString")
    options = parser.parse_args()
    options.parmIds = []

    # check that we have the required arguments for either output or input
    if options.outputFile is not None:
        # for output: hostname, RPC port number, database id are required
        if options.databaseIds is None:
            parser.error("The database id argument is missing.")

        # if no start time specified, set it to 0
        if options.startTime is None:
            options.startTime = TimeRange.allTimes().getStart()

        if options.endTime is None:
            options.endTime = TimeRange.allTimes().getEnd()

        # if parms are specified, append them the parmIds
        if options.parmNames is not None:
            for parm in options.parmNames:
                for dbID in options.databaseIds:
                    pos = parm.find("_")
                    if pos > -1:
                        options.parmIds.append(
                            ParmID(parm[:pos], dbID, parm[pos + 1:]))
                    else:
                        options.parmIds.append(ParmID(parm, dbID))

    # if no username, assign SITE
    if options.userName is None:
        options.userName = pwd.getpwuid(os.getuid()).pw_name

    return options
Пример #4
0
def decodeArguments():
    parser = UsageArgumentParser.UsageArgumentParser(prog='ifpAG', conflict_handler="resolve", usage=
"""ifpAG -o outputFile -h hostname -r rpcPortNumber -d databaseID [-p parmID] [-s startTime] [-e endTime] [-u username] [-c coordConversionString]
or
ifpAG -i inputFile -h hostname -r rpcPortNumber [-u username]
""")
    modeGroup = parser.add_mutually_exclusive_group(required=True)
    modeGroup.add_argument("-o", action="store", dest="outputFile", 
                        help="Specifies the name of the output file.",
                        metavar="outputFile")
    modeGroup.add_argument("-i", action="store", dest="inputFile", 
                      help="Specifies the name of the input file.",
                      metavar="inputFile")
    parser.add_argument("-h", action="store", dest="hostname",
                      help="""Host name upon which the EDEX server is running. 
                              Please specify the host name of the dx3 or dx4 server.""", 
                      required=True, metavar="hostname")
    parser.add_argument("-r", action="store", type=int, dest="portNumber", 
                      help="the port that ifpServer is serving",
                      required=True, metavar="portNumber")
    parser.add_argument("-u", action="store", dest="userName", 
                      help="If no username is specified, then your username is used.",
                      metavar="username")    
    parser.add_argument("-d", action=AppendDatabaseIDAction, dest="databaseIds", 
                      help="""DatabaseID from which to get the data.  There may
                              be several DatabaseIDs specified.
                             format: (DEN_GRID__eta_19980604_1200)""", 
                      metavar="databaseID")
    parser.add_argument("-p", action="append", dest="parmNames", 
                      help="""If none specified, get all parms for
                               all databases listed.  There may be several
                               parmIDs specified.
                               format: (Temp)""",
                      metavar="parmID")
    parser.add_argument("-s", action=StoreTimeAction, dest="startTime", 
                      help="""If no start time specified, make start
                              time = 0. format: (19980604_1200)""",
                      metavar="startTime")
    parser.add_argument("-e", action=StoreTimeAction, dest="endTime", 
                      help="""If no end time specified, make end
                              time = Abstime::MaxFutureTime().
                              format: (19980604_1200)""",
                      metavar="endTime")
    parser.add_argument("-c", action="store", dest="coordConversionString", 
                      help="""If no coordinate conversion string
                               is specified, then output is done in the
                               server's inherinet resolution. Must be quoted.
                             String format:
                             xsize ysize projID originX originY extentX extentY
                             "35 35 Grid211 35.0 14.0 9.0 9.0"
                             Coord conversion is automatic on input.""",
                      metavar="coordinateConversionString")   
    options = parser.parse_args()
    options.parmIds = []
    
    # check that we have the required arguments for either output or input
    if options.outputFile is not None:
        # for output: hostname, RPC port number, database id are required
        if options.databaseIds is None:
            parser.error("The database id argument is missing.")
        
        # if no start time specified, set it to 0
        if options.startTime is None:
            options.startTime = TimeRange.allTimes().getStart()
            
        if options.endTime is None:
            options.endTime = TimeRange.allTimes().getEnd()
            
        # if parms are specified, append them the parmIds
        if options.parmNames is not None:
            for parm in options.parmNames:
                for dbID in options.databaseIds:
                    pos = parm.find("_")
                    if pos > -1:
                        options.parmIds.append(ParmID(parm[:pos], dbID, parm[pos+1:]))
                    else:
                        options.parmIds.append(ParmID(parm, dbID))
    
    # if no username, assign SITE
    if options.userName is None:
        options.userName = pwd.getpwuid(os.getuid()).pw_name
        
    return options