from ir_webstats.client import iRWebStats
from prettytable import PrettyTable
import urllib.parse as url

if __name__ == '__main__':

    parser = ap.ArgumentParser(description="Shell interface for iRWebStats")
    parser.add_argument("-u", "--user", help='iRacing user', required=False)
    parser.add_argument("-p",
                        "--passw",
                        help='iRacing password',
                        required=False)

    args = parser.parse_args()

    irw = iRWebStats()

    if args.user and args.passw:
        irw.login(username=args.user, password=args.passw)
    else:
        print("Check if valid cookie and then try to log in")
        irw.login()  # No login provided, maybe there's a valid cookie

    if not irw.logged:
        print(
            "Couldn't log in to iRacing Membersite. Please check your credentials"
        )
        exit()

    print("Succes login")
Exemplo n.º 2
0
import os
import sys
import urllib
import click
from ir_webstats.client import iRWebStats

irw = iRWebStats()


@click.command()
@click.argument("club")
@click.argument("year", type=int)
@click.option("--quarter", type=int)
@click.option("--tops", default=3, type=int)
@click.option("--user", prompt="Username")
@click.password_option(confirmation_prompt=False)
def ir_clubchamp(club, year, quarter=None, tops=3, user=None, password=None):
    if hasattr(sys, "frozen"):
        os.environ["REQUESTS_CA_BUNDLE"] = os.path.join(os.path.dirname(sys.executable), "cacert.pem")
    irw.login(user, password)
    if not irw.logged:
        click.echo (
            "Couldn't log in to iRacing Membersite. Please check your credentials")
    else:
        champs = acquire_champ_list(club, year, quarter, tops)
        print_champs(champs)


def find_club_id(clubname):
    for club_id in irw.CLUBS:
        shortclubname = urllib.parse.unquote(irw.CLUBS[club_id]["shortclubname"])