Пример #1
0
def get_rider_list():
    mkresults.dbh = sqlite3.connect('race_database.sql3')
    conf = mkresults.config(args.config)
    mkresults.conf = conf
    mkresults.args = namedtuple('Args', 'no_cat debug')(no_cat=False, debug=args.verbose)

    startTime = conf.start_ms / 1000
    retrievalTime = startTime + conf.start_window_ms / 1000
    sleepTime = retrievalTime - time.time()
    while sleepTime > 0:
        print "Sleeping %s seconds" % sleepTime
        time.sleep(sleepTime)
        sleepTime = retrievalTime - time.time()
    conf.load_chalklines()
    R, all_pos = mkresults.get_riders(conf.start_ms - conf.lookback_ms,
            conf.finish_ms)
    return [ r.id for r in R.values() if mkresults.filter_start(r) ]
Пример #2
0
    access_token, refresh_token = login(session, args.user, password)

    if not args.no_profile:
        dbh = sqlite3.connect('rider_names.sql3')
        for id in L:
            updateRider(racedbh if using_mysql else None, dbh, session, access_token, id, args.event_id, args.race_id)
        dbh.commit()
        dbh.close()

    if args.query_strava_athlete_id:
        # query rider's strava athlete id and other details if optionally
        # matching the specified required tag in config
        required_tag = None
        if args.config:
            required_tag = mkresults.config(args.config).required_tag

        dbh = sqlite3.connect('results_history.sql3')
        updateStravaId(racedbh, session, access_token, strava_access_token, L, required_tag)
        dbh.commit()
        dbh.close()

    logout(session, refresh_token)


def open_mysql(args):
    return mysql.connector.connect(user=args.mysql_user, password=args.mysql_password, database=args.mysql_database,
                                   host=args.mysql_host, autocommit=True)


if __name__ == '__main__':
Пример #3
0
    cookies = None

    try:
        opts,args=getopt.getopt(argv[1:], "", ['verbose', 'dont-check-certificates'])
    except getopt.GetoptError, e:
        sys.stderr.write("Unknown option: %s\n" % e.opt)
        usage(argv[0], sys.stderr)
        sys.exit(1)

    if len(args) != 2:
        usage(argv[0], sys.stderr)
        sys.exit(1)

    dbh = sqlite3.connect('race_database.sql3')
    mkresults.dbh = dbh
    conf = mkresults.config(args[1])
    mkresults.conf = conf
    mkresults.args = namedtuple('Args', 'no_cat debug')(no_cat=False, debug=g_verbose)
    user = args[0]

    g_verbose = False
    g_verifyCert = True

    # Post Credentials
    password = getpass.getpass("Password for %s? " % user)
    #test the credentials - token will expire, so we'll log in again after sleeping
    access_token = login(requests.session(), user, password)

    for opt,val in opts:
        if opt == '--verbose':
            g_verbose = True