예제 #1
0
def parseargs(pgm, argv, usage):
    import getopt
    popts = {'file':None, 'eid':None}
    try:
        (opts, args) = getopt.getopt(argv, 'f:e:',
        ['file=', 'eid='])
    except getopt.GetoptError, e:
        stderr(e)
        exit(usage_tail(pgm, usage, 1))
예제 #2
0
         {0:s} [OPTIONS] -f infile 'team_name'
         {0:s} --help

  Team name must be last and quoted if it contains spaces.

  [OPTIONS]
  -f, --file <infile>  Read input from file. Must have one entry per line.
"""
# Let app_main parse all common options
(api, argv) = app_main(pgm, sys.argv[1:], usage)

# Now parse application-specific part of command line
try:
    (popts, args) = parseargs(pgm, argv, usage)
except AppInitError, e:
    stderr(e)
    exit(1)

(eid, infile, team) = (popts['eid'], popts['file'], None)
nargs = len(args)
if nargs != 1:
    stderr("\nNeed team name. Quote if name contains spaces.\n")
    exit(usage_tail(pgm, usage, 1))
else:
    team = args[0]

# Need team name and either user_id or input file
if not (team and (eid or infile)):
    stderr ("\n  ** Need 'team name' and worker_id or input file**.\n")
    exit(usage_tail(pgm, usage, 1))