Exemplo n.º 1
0
async def sell_prepared_lots(api: Tele2Api, lots: list):
    tasks = []
    for lot in lots:
        task = asyncio.ensure_future(api.sell_lot(lot))
        tasks.append(task)
    print('Listing...')
    lots = await asyncio.gather(*tasks)
    print_lot_listing_status(lots)
Exemplo n.º 2
0
async def sell_prepared_lots(api: Tele2Api, lots: list):
    tasks = []
    for lot in lots:
        task = asyncio.ensure_future(api.sell_lot(lot))
        tasks.append(task)
    print('Listing...')
    lots = await asyncio.gather(*tasks)
    if any(lot['meta']['status'] == "bp_err_limDay" for lot in lots):
        print(Fore.MAGENTA +
              'Day listing limit (100) reached. Try again tomorrow.')
    else:
        print(Fore.BLUE + 'Lots have been listed to sell.')
Exemplo n.º 3
0
async def main():
    access_token, date, phone_number = load_config()
    async with Tele2Api(phone_number, access_token) as api:
        colorama_init(autoreset=True)
        await check_auth(api)
        print_token_time(date)
        deleted_lots = await delete_active_lots(api)
        print(Fore.YELLOW + '-----')
        option = await display_menu(len(deleted_lots) > 0)
        if option == 'new':
            await menu_new_action(api)
        elif option == 'again':
            await menu_again_action(api, deleted_lots)
        elif option == 'Exit':
            exit()
Exemplo n.º 4
0
async def delete_active_lots(api: Tele2Api):
    tasks = []
    print('Checking active lots...')
    active_lots = await api.get_active_lots()
    count = len(active_lots)
    if count:
        print(Fore.MAGENTA +
              f'You have {count} active lot{"s" if count > 1 else ""}:')
        for lot in active_lots:
            color = Fore.BLUE if lot['trafficType'] == 'voice' else Fore.GREEN
            print(color + f'\t{lot["volume"]["value"]} {lot["volume"]["uom"]} '
                  f'for {int(lot["cost"]["amount"])} rub')
        for lot in active_lots:
            task = asyncio.ensure_future(api.return_lot(lot['id']))
            tasks.append(task)
        await asyncio.gather(*tasks)
        print('All active lots have been deleted!')
    else:
        print(Fore.MAGENTA + 'You don\'t have any active lots.')
    return active_lots
Exemplo n.º 5
0
async def main():
    access_token, date, phone_number = load_config()
    async with Tele2Api(phone_number, access_token) as api:
        # script initialization:

        colorama_init(False)

        # logic pipeline:

        await check_auth(api)
        print_token_time(date)
        await print_balance(api)
        deleted_lots = await delete_active_lots(api)

        print(Fore.MAGENTA + '-----')

        option = await display_menu(have_lots_returned=len(deleted_lots) > 0)

        if option == 'new':
            await menu_new_action(api)
        elif option == 'again':
            await menu_again_action(api, deleted_lots)
        elif option == 'Exit':
            pass
Exemplo n.º 6
0
async def main():
    colorama_init(autoreset=True)
    phone_number = get_phone_number()
    async with Tele2Api(phone_number) as api:
        access_token = await get_access_token(api, phone_number)
    save_config(phone_number, access_token)