Exemplo n.º 1
0
def HandleCommandlineArguments():
    print("FUDD - BIFF Save File Editor Version " + VersionMgr.ReadVer())

    if sys.version_info < (3, 3):
        print("---- Error: Required Python 3.3 or greater ---")
        return False

    parser = argparse.ArgumentParser(description='FUDD the fearful')

    parser.add_argument("-i",
                        "--input",
                        help='specifies application configuration file file',
                        type=str,
                        required=True)
    parser.add_argument("-o",
                        "--output",
                        help='specifies file to generate',
                        type=str,
                        required=True)
    parser.add_argument("-l",
                        "--logfile",
                        help='specifies log file name',
                        type=str)
    parser.add_argument("-v",
                        "--verbose",
                        help="prints debug information",
                        action="store_true")

    try:
        args = parser.parse_args()

    except:
        return False

    if None != args.logfile:
        Log.setLogfile(args.logfile)

    if False == args.verbose:
        Log.setLevel(logging.ERROR)

    else:
        Log.setLevel(logging.INFO)

    Log.getLogger().info("")

    ReadConfigFile(args.input, args.output)
Exemplo n.º 2
0
def HandleCommandlineArguments():
    parser = argparse.ArgumentParser(description='Oscar the wonderful')

    parser.add_argument("-i","--input",help='specifies application configuration file file',type=str)
    parser.add_argument("-l","--logfile",help='specifies log file name',type=str)
    parser.add_argument("-v","--verbose",help="prints debug information",action="store_true")
    parser.add_argument("-m","--minimize",help='run with GUI minimized',action="store_true")

    exclustionGroup = parser.add_mutually_exclusive_group()

    exclustionGroup.add_argument("-p","--playback",help='specifies file to load and playback',type=str)
    exclustionGroup.add_argument("-r","--record",help='specifies file to record to, used with --time',type=str)

    group_Play = parser.add_argument_group('Playback',"Parameters to be used when you use the --playback option")
    group_Play.add_argument("-s","--speed",help='specifies payback speed',type=float)

    foo = group_Play.add_mutually_exclusive_group()
    foo.add_argument("-ex","--exit",help="exit after playback finished,not valid with repeat or loop",action="store_true")
    foo.add_argument("-rp","--repeat",help="repeat the dataset continously",action="store_true")
    foo.add_argument("-lp","--loop",help="loop from one datalocation to the next repeatedly (use -begin and -end)",action="store_true")

    group_Play.add_argument("-b","--begin",help='start dataset number for mode=loop',default=0,type=int)
    group_Play.add_argument("-e","--end",help='end dataset number for mode=loop',type=int)

    parser.add_argument("-t","--time",help='specifies time (in minutes) to run before automatically exiting, used with Recording and Playback',type=int)
    parser.add_argument("-ng","--nogui",help='run without GUI',action="store_true")
    parser.add_argument("-bc","--batchconvert",help="batch convert biff files to csv",type=str)
    
    try:    
        args = parser.parse_args()

    except:
       return False

    _Verbose = args.verbose

    Alias.AliasMgr.AddEnvironmentVariables()


    if None != args.logfile:
        Configuration.get().SetLogFilename(args.logfile)

    if True == _Verbose:
        Log.setLevel(logging.DEBUG)

    if None != args.batchconvert:
        performBatchConvert(args.batchconvert)
        return False

    conf = Configuration.get()

    if True == args.minimize:
        conf.SetMinimizeGui(True)

    if None != args.input:
        if existFile(args.input):
            conf.SetConfigFilename(args.input)
        else:
            return False

    if None != args.playback:
        if existFile(args.playback):
            conf.SetAutorunFilename(args.playback)
            conf.SetExitAfterAutoPlay(args.exit)
        else:
            return False

    if None != args.time:
        Configuration.get().SetAutorunTime(args.time)
        if None == args.playback and None == args.record:
            print("time option only valid when doing a playback or a recording")
            return false
        
    if None != args.record:
        Configuration.get().SetRecordFilename(args.record)

    if None != args.speed:
        conf.SetPlaybackSpeed(args.speed)

    conf.SetAutrunLocations(args.begin,args.end)

    if args.repeat:
        conf.SetAutoRunMode(RepeatMode.REPEAT)

    elif args.loop:
        conf.SetAutoRunMode(RepeatMode.LOOP)

    elif None != args.playback:
        conf.SetAutoRunMode(RepeatMode.NONE)

    conf.SetUseGUI(not args.nogui)

    return True
Exemplo n.º 3
0
def ShowVersion():
    Log.setLevel(logging.INFO)
    Log.getLogger().info("Minion " + VersionMgr.ReadVer())
Exemplo n.º 4
0
def main():
    parser = argparse.ArgumentParser(description='Minion Data Collector.')
    parser.add_argument("-i",
                        "--input",
                        dest='argFilename',
                        help='specifies input file',
                        type=extant_file,
                        metavar="FILE")
    parser.add_argument("-v",
                        "--verbose",
                        help="prints information, values 0-3",
                        type=int)
    parser.add_argument("-r",
                        "--runonce",
                        help="calls all collectors once and exits",
                        action="store_true")
    parser.add_argument(
        "-a",
        "--aliasfile",
        help="specify an external file that has alias defintions",
        type=str)

    try:
        args = parser.parse_args()
        if None == args.verbose:
            _VerboseLevel = 0
        else:
            _VerboseLevel = args.verbose
        _RunOnce = args.runonce

    except:
        return

    ShowVersion()
    if not VersionCheck.CheckVersion():
        Log.getLogger().error("Invalid version of Python")
        return

    if 3 <= _VerboseLevel:
        Log.setLevel(logging.DEBUG)

    elif 2 == _VerboseLevel:
        Log.setLevel(logging.WARNING)

    elif 1 == _VerboseLevel:
        Log.setLevel(logging.INFO)

    else:
        Log.setLevel(logging.ERROR)

    curr_dir_path = os.path.dirname(os.path.realpath(__file__))
    Alias.AliasMgr.AddAlias("WORKING_DIR", curr_dir_path)

    Alias.AliasMgr.AddEnvironmentVariables()
    if None != args.aliasfile:
        if not Alias.AliasMgr.LoadExternalAliasFile(args.aliasfile):
            return

    signal.signal(
        signal.SIGINT, signal.SIG_IGN
    )  # turn of Ctrl+C signal handler (will get inherted by sub processes

    if not os.path.exists(_ConfigFilename):
        Log.getLogger().error("Config file [" + _ConfigFilename +
                              "] not found!")
        return

    config = Configuration.Configuration(_ConfigFilename, True)

    if None == config or not config.IsValid():
        pass

    else:
        print("Starting Collectors...")
        totalCollectors = 0
        for namespace in config.GetNamespaces():
            totalCollectors += namespace.Begin(_RunOnce)

        signal.signal(signal.SIGINT,
                      signal_handler)  # make my own Ctrl+C handler now

        print(str(totalCollectors) + " Collectors started.")

        if False == _RunOnce:
            print("Press CTRL+C to Exit")
        else:
            print("Running Once")

        if False == _RunOnce:
            while _ThreadActive:
                if 0 == _VerboseLevel:
                    for c in spinning_cursor():
                        countStr = '[' + str(config.GetCollectorCount()) + '] '
                        sys.stdout.write(countStr)
                        sys.stdout.write(c)
                        Sleep.SleepMs(100)
                        sys.stdout.flush()
                        sys.stdout.write('\b')
                        for c in countStr:
                            sys.stdout.write('\b')

                else:
                    Sleep.SleepMs(100)

        print("Shutting down...")
        try:
            ThreadManager.GetThreadManager().StopAllThreads()
        except:
            pass
Exemplo n.º 5
0
def HandleCommandlineArguments():
    print("FUDD - BIFF Save File Editor Version " + VersionMgr.ReadVer())

    if sys.version_info < (3, 3):
        print("---- Error: Required Python 3.3 or greater ---")
        return False

    firstLevelActionNames, firstLevelActions = SetupActions()
    parser = argparse.ArgumentParser(description='FUDD the Elmer',
                                     add_help=False)

    parser.add_argument("-i",
                        "--input",
                        help='specifies input file(s), wildcards allowed',
                        type=str,
                        required=True)
    parser.add_argument(
        "-o",
        "--output",
        help='specifies file to generate, wildcards allowed in most cases',
        type=str,
        required=True)
    parser.add_argument(
        '-a',
        '--action',
        help='action to perform',
        required=True,
        nargs="?",
        choices=firstLevelActionNames,
    )

    parser.add_argument("-y",
                        "--overwrite",
                        help="will not prompt if overwriting target",
                        action="store_true")
    parser.add_argument("-l",
                        "--logfile",
                        help='specifies log file name',
                        type=str)
    parser.add_argument("-v",
                        "--verbose",
                        help="prints debug information",
                        action="store_true")
    parser.add_argument('-h', '--help', action='store_true')

    try:
        global g_args
        g_args, sub_args = parser.parse_known_args()

        # Manually handle help
        if len(sub_args) < 1:
            print(parser.format_help())
            sys.exit(1)
        # Otherwise pass the help option on to the subcommand
        if g_args.help:
            sub_args.append('--help')

    except:
        return False

    if None != g_args.logfile:
        Log.setLogfile(g_args.logfile)

    if False == g_args.verbose:
        Log.setLevel(logging.ERROR)

    else:
        Log.setLevel(logging.INFO)

    parseAndRunAction(g_args.action, firstLevelActions.getActionList(),
                      sub_args)