Esempio n. 1
0
def main(module, config, logger=None, verbose=False):
    if logger == None:
        logger = Logger("runner_main.log", "runner.py > main", autosave=True)
    else:
        logger.context = "runner.py > main()"
    classes = utils.get_classes(module)
    errors = utils.parse_config(config, classes)
    for i in errors:
        if type(i) == ConfigError:
            logger.error("ConfigError: " + str(i), True)
        elif type(i) == PropertyError:
            logger.warning("PropertyError: " + str(i), True)
    w = World(initial_food=config.get("World").get("initial_food", 100),
              food_function=config.get("World").get("food_function",
                                                    functions.base))
    for ccllss in classes:
        w.creatures[ccllss.__name__] = []
        n_of_class = config.get("World",
                                {}).get("initial",
                                        {}).get("n_" + ccllss.__name__, 1)
        for i in range(n_of_class):
            c = ccllss(name=ccllss.__name__,
                       species=ccllss.__name__,
                       reproduction_chance=config.get("Creatures", {}).get(
                           ccllss.__name__, {}).get("reproduction_chance",
                                                    0.1),
                       death_chance=config.get("Creatures", {}).get(
                           ccllss.__name__, {}).get("death_chance", 0.1),
                       speed=config.get("Creatures",
                                        {}).get(ccllss.__name__,
                                                {}).get("speed", 1),
                       death_age=config.get("Creatures",
                                            {}).get(ccllss.__name__,
                                                    {}).get("death_age", 100),
                       age_increments=config.get("Creatures", {}).get(
                           ccllss.__name__, {}).get("age_increments", 0.1),
                       energy=config.get("Creatures",
                                         {}).get(ccllss.__name__,
                                                 {}).get("energy", 100))
            w.creatures[ccllss.__name__].append(c)
        logger.debug(
            "Added " + str(n_of_class) + " instances of " + ccllss.__name__ +
            " to the world", verbose)
    data = do_iterations(w, config.get("iterations"), logger, config)
    logger.save()
    display_data(data)
Esempio n. 2
0
arguments = parser.parse_args()
args = vars(arguments)
VERBOSE = args.get("verbose", False)

log = Logger("workflow.log", "workflow.py", True, True)
utils.log_header(log, DESCRIPTION, VERBOSE)

try:
    log.debug("Debug mode activated.", VERBOSE)
    log.debug("Args: ", VERBOSE)
    for i in args:
        log.debug(i + ": " + str(args[i]), VERBOSE)
    if not args.get("test", False):
        download.main(args, logger=log)
    if args.get("facerec", None) != None and not args.get("test", False):
        if "all" in args.get("facerec", []):
            # pass all videos from utils.getVideos() to facerec
            facerec.main({"files": utils.getVideos()})
        else:
            # pass all videos from args to facerec
            facerec.main({"files": args.get("facerec", [])})
    if not args.get("test", False):
        convert.main(args, log)
    if not args.get("test", False):
        transfer.main(args, log)
    log.success("Workflow routine finished!", not args.get("silent", False))
except KeyboardInterrupt:
    log.context = "workflow.py"
    log.warning("exiting...", True)
    exit(0)
Esempio n. 3
0
               action="store_true",
               help="Plot % of active cases of population")
args = p.parse_args()

if args.all:
    args.active = True
    args.recovered = True
    args.deaths = True
    args.population_percent = True

logger = Logger("log", autosave=True)

if not args.summary and not args.summary_only and not (
        args.active or args.recovered or args.deaths
        or args.population_percent):
    logger.warning(
        "No output specified (active/recovered etc.). Use the -h option to get more information."
    )
    exit(0)

manager = DataManager(logger, args.countries, True)

if args.summary_only:
    manager.load_summary()
    print_summary()
    exit(0)
elif args.summary:
    manager.load_summary()
    print_summary()

present_history(args.countries)