Beispiel #1
0
def parse_options(parser):
    morehelpmap = {
        'hosts': hosts_help,
        'tasks': tasks_help,
        'mode': mode_help,
        'broken': broken_help,
        'log': log_help,
        'timeslot': timeslot_help
    }
    (options, args) = parser.parse_args(sys.argv)
    error = False
    error_msg = []

    if options.morehelp != None:
        try:
            morehelpmap[options.morehelp](sys.argv[0])
            sys.exit(1)
        except KeyError:
            msg.error("No help for '%s'.\n" % options.morehelp)
            msg.write_list(
                [' ', ('*', 'green'), ' List of available full helps :\n   '])
            for k in morehelpmap.keys():
                msg.write('%s, ' % k)
            msg.write('\n')
            sys.exit(1)
    mandatory_options = {'hosts': options.hosts}
    timeslot = read_timeslot(options.timeslot)
    if None in mandatory_options.values():
        opt = [n for n, o in mandatory_options.items() if o == None]
        error_msg.append('missing options : %s' % opt)
        error = True
    if not options.mode in ["dispatch", "repeat", "hie", "hierarchical"]:
        error_msg.append("'%s' : unknown task manager mode." % \
                            options.mode)
        error = True
    if error:
        parser.print_help()
        for m in error_msg:
            msg.error(m)
        sys.exit(1)
    hosts_list = read_hosts(options.hosts)
    if options.tasks:
        tasks_list = read_tasks(options.tasks, options.mode)
    else:
        tasks_list = None
    return options, timeslot, hosts_list, tasks_list
Beispiel #2
0
def parse_options(parser):
    morehelpmap = {'hosts' : hosts_help, 'tasks' : tasks_help,
        'mode' : mode_help, 'broken' : broken_help, 'log' : log_help,
        'timeslot' : timeslot_help}
    (options, args) = parser.parse_args(sys.argv)
    error = False
    error_msg = []

    if options.morehelp != None:
        try:
            morehelpmap[options.morehelp](sys.argv[0])
            sys.exit(1)
        except KeyError:
            msg.error("No help for '%s'.\n" % options.morehelp)
            msg.write_list([' ', ('*', 'green'),
                ' List of available full helps :\n   '])
            for k in morehelpmap.keys(): msg.write('%s, ' % k)
            msg.write('\n')
            sys.exit(1)
    mandatory_options = {'hosts' : options.hosts}
    timeslot = read_timeslot(options.timeslot)
    if None in mandatory_options.values():
        opt = [n for n, o in mandatory_options.items() if o == None]
        error_msg.append('missing options : %s' % opt)
        error = True
    if not options.mode in ["dispatch", "repeat", "hie", "hierarchical"]:
        error_msg.append("'%s' : unknown task manager mode." % \
                            options.mode)
        error = True
    if error:
        parser.print_help()
        for m in error_msg: msg.error(m)
        sys.exit(1)
    hosts_list = read_hosts(options.hosts)
    if options.tasks:
        tasks_list = read_tasks(options.tasks, options.mode)
    else:    tasks_list = None
    return options, timeslot, hosts_list, tasks_list
Beispiel #3
0
 def print_status(self, n, size):
     msg.write_list(['\r ', ('%d' % n, 'red'),
             '/', ('%d' % size, 'red')])
     if n == size: msg.write('\n')
     sys.stdout.flush()
Beispiel #4
0
 def print_status(self, n, size):
     msg.write_list(['\r ', ('%d' % n, 'red'), '/', ('%d' % size, 'red')])
     if n == size: msg.write('\n')
     sys.stdout.flush()