Exemple #1
0
def main():
    parser = argparse.ArgumentParser(description='Proces trail on an elite.')
    parser.add_argument('run_id',
                        type=int,
                        help='The run ID to fetch animations for.')
    parser.add_argument('-g',
                        '--generation',
                        type=int,
                        default=None,
                        help='The generation to evaluate elite for.')
    parser.add_argument('--no-shorten',
                        action='store_true',
                        help='Disables URL shortening with Google.')
    parser.add_argument('--debug',
                        action='store_true',
                        help='Enables debug information.')

    args = parser.parse_args()

    # Read the configuration file.
    with open(CONFIG_FILE) as fh:
        config = json.load(fh)

    pgdb = DBUtils(CONFIG_FILE)

    elite = pgdb.get_elite(args.run_id, args.generation)

    run_info = pgdb.get_run_info(args.run_id)

    moves = eval_trail(elite, run_info["moves_limit"], run_info["networks_id"],
                       run_info["trails_id"])

    actual_url = BASE_URL.format(config["base-viewer-url"],
                                 run_info["trails_id"],
                                 "".join([str(x) for x in moves]))

    if args.debug:
        print "DEBUG: Base URL is {0}.".format(actual_url)

    if not args.no_shorten:
        print_url = shorten_url(actual_url, config["url-shorten-key"],
                                args.debug)
    else:
        print_url = actual_url

    print "Animation URL: {0}".format(print_url)
Exemple #2
0
def main():
    parser = argparse.ArgumentParser(
        description='Proces trail on an elite.')
    parser.add_argument('run_id', type=int,
        help='The run ID to fetch animations for.')
    parser.add_argument('-g', '--generation', type=int,
        default=None,
        help='The generation to evaluate elite for.')
    parser.add_argument('--no-shorten', action='store_true',
        help='Disables URL shortening with Google.')
    parser.add_argument('--debug', action='store_true',
        help='Enables debug information.')

    args = parser.parse_args()

    # Read the configuration file.
    with open(CONFIG_FILE) as fh:
        config = json.load(fh)

    pgdb = DBUtils(CONFIG_FILE)

    elite = pgdb.get_elite(args.run_id, args.generation)

    run_info = pgdb.get_run_info(args.run_id)

    moves = eval_trail(elite, run_info["moves_limit"],
        run_info["networks_id"], run_info["trails_id"])

    actual_url = BASE_URL.format(
        config["base-viewer-url"],
        run_info["trails_id"],
        "".join([str(x) for x in moves]))

    if args.debug:
        print "DEBUG: Base URL is {0}.".format(actual_url)

    if not args.no_shorten:
        print_url = shorten_url(actual_url, config["url-shorten-key"],
            args.debug)
    else:
        print_url = actual_url

    print "Animation URL: {0}".format(print_url)