Пример #1
0
def test_convert(value, from_unit, to_unit, ex):
    with pytest.raises(ex):
        convert(value, from_unit, to_unit)
Пример #2
0
def ban_from_raw(amount):
    return convert(amount, "raw", "ban")
Пример #3
0
def ban_from_banoshi(amount):
    return convert(amount, "banoshi", "ban")
Пример #4
0
def ban_to_banoshi(amount):
    return convert(amount, "ban", "banoshi")
Пример #5
0
def ban_to_raw(amount):
    return convert(amount, "ban", "raw")
Пример #6
0
async def main():
    source = input("Enter an address to see transaction totals for: ")
    noTrans = input("How many transactions should be retrieved (default 50): ")
    await check_updates()
    if noTrans == "":
        noTrans = 50

    print("Getting the last ", noTrans, " transactions...")
    history = await get_history(source, int(noTrans))
    print("Searching history of account...")
    for transaction in history:
        amount = convert(int(transaction['amount']), "raw", "banano")
        destination = transaction['account']
        if destination not in totals:
            # List is received, sent, Discord name, Twitter name, Telegram name, Exchange
            totals[destination] = [0, 0, "", "", "", ""]

        if transaction['type'] == "receive":
            totals[destination][0] = totals[destination][0] + int(amount)

        if transaction['type'] == "send":
            totals[destination][1] = totals[destination][1] + int(amount)

    print("Reading discord.json file...")
    with open("discord.json", "r") as f:
        discord = json.load(f)

    print("Identifying Discord users...")
    coros = [get_discord(address, discord) for address in totals]
    await asyncio.gather(*coros)

    print("Reading twitter.json file...")
    with open("twitter.json", "r") as f:
        twitter = json.load(f)

    print("Identifying Twitter users...")
    coros = [get_twitter(address, twitter) for address in totals]
    await asyncio.gather(*coros)

    print("Reading telegram.json file...")
    with open("telegram.json", "r", encoding="utf-8") as f:
        telegram = json.load(f)

    print("Identifying Telegram users...")
    coros = [get_telegram(address, telegram) for address in totals]
    await asyncio.gather(*coros)

    print("Reading telegram_old.json file...")
    with open("telegram_old.json", "r", encoding="utf-8") as f:
        telegram_old = json.load(f)

    print("Identifying Telegram_old users...")
    coros = [get_telegram_old(address, telegram_old) for address in totals]
    await asyncio.gather(*coros)

    print("Loading in exchange list...")
    labels = await read_exchanges()

    #print("Searching for intermediaries to exchanges and gambling sites...")
    #inters = [get_inter(address, labels) for address in totals]
    #await asyncio.gather(*inters)
    #print("Please wait 10 seconds...")
    #await asyncio.sleep(10)

    csv_columns = [
        'Address', 'Received', 'Sent', 'Discord', 'Twitter', 'Telegram',
        'Exchange'
    ]

    filename = await set_filename(source, discord, twitter, telegram)

    try:
        print("Writing totals to " + filename)
        with open(filename, 'w', newline='', encoding="utf-8") as csvfile:
            writer = csv.writer(csvfile)
            writer.writerow(csv_columns)
            for address in totals:
                writer.writerow([
                    address, totals[address][0], totals[address][1],
                    totals[address][2], totals[address][3], totals[address][4],
                    totals[address][5]
                ])
    except IOError as e:
        print(e)