Ejemplo n.º 1
0
def signup():
    info = request.json
    # check there is a username and password
    if info is None or 'username' not in info or 'password' not in info:
        return jsonify(status=400, result="Missing Fields")
    print(info)
    username = str(info['username'])
    password = str(info['password'])

    # make an account class with the hashed info
    salt = hash_utils.generate_salt()
    digest = hash_utils.hmac_hash(password, salt)
    account = Account(username=username,
                      hashed_password=digest,
                      salt=salt,
                      type="Student")

    # try to save the data
    # if the username is not unique, pymongo will tell us :D
    try:
        student = account.save()
        # Create a student profile
        profile = StudentProfile(student=student).save()
        return jsonify(status=200, result="OK")
    except ValidationError as e:
        print(e)
        return jsonify(status=400, result="Validation Error " + e)
    except NotUniqueError as e:
        print(e)
        return jsonify(status=400, resuls="Username already taken.")
Ejemplo n.º 2
0
def main():
    apikey = fetchKey()
    accounts = []
    acc = Account("xdddd", "123456789", "BRONZE", "I", 65)
    accounts.append(acc)
    #accounts.append(Account("xdddd","123456789","BRONZE", "I", 65))
    acc.save()
    fetchAccounts()
Ejemplo n.º 3
0
def generate_dummy_account():
        firstname = "Rianna"
        lastname = "Johnson"
        account_type = "savings".lower()
        address = "13 Riddlesworth Road"
        year = 2020
        username = "******"
        password = "******"
        
        account = Account(firstname, lastname, account_type, address, year, username, password)
        account.balance = 100
        return account
Ejemplo n.º 4
0
    async def slot(self,
                   ctx,
                   input_string="help",
                   spins="1",
                   multiplier="1",
                   testing="False"):
        if input_string == "help":
            des = []
            for machine in self.bot.slot_machines.keys():
                des.append(self.bot.slot_machines[machine].print())
            des.append(
                "Enter the slot command, followed by the name of the slot machine you'd like to play!"
            )
            await ctx.send(embed=Embed(title="Slot Machine List",
                                       description="\n".join(des)))
        else:
            spins = round(await clean_float(spins))
            multiplier = await clean_float(multiplier)
            try:
                user = self.bot.account_list[ctx.author.id]
            except KeyError:
                self.bot.account_list.update(
                    {ctx.author.id: Account(user_id=ctx.author.id)})
                user = self.bot.account_list[ctx.author.id]
                await ctx.send(
                    "Welcome to the bot! We've given you 1000 credits to get started!"
                )
            try:
                machine = self.bot.slot_machines[input_string.lower()]
            except KeyError:
                return await ctx.send(
                    'Machine Not Recognized! Please reissue command.')

            cost_to_play = machine.cost * multiplier * spins
            if cost_to_play <= user.balance:
                user.balance -= cost_to_play
                user.balance += await machine.spin(ctx, spins, multiplier,
                                                   testing)
                output = f'Spun {spins:,} times at {machine.cost * multiplier} per spin.' \
                         f'\nCoins In: {machine.coins_in:,}' \
                         f'\nCoins Out: {machine.coins_out:,}' \
                         f'\nProfit: {machine.coins_in - machine.coins_out:,}' \
                         f'\nPayout: {machine.coins_out * 100 / machine.coins_in:,.2f}%'
                msg = await ctx.send(output)

                if machine.coins_out * 100 / machine.coins_in > 97:
                    await msg.edit(content=f'{msg.content}\n'
                                   f'<:redAlarm:683018770461360147> '
                                   f'<:redAlarm:683018770461360147> '
                                   f'<:redAlarm:683018770461360147> '
                                   f'<:redAlarm:683018770461360147>')

            else:
                await ctx.send(
                    'You do not have enough points!\nMaybe try to use the daily command!'
                )
            return
Ejemplo n.º 5
0
def delete_all_students():
    if 'username' not in session or session['username'] is None:
        return jsonify(status=400, result="Not Logged In")
    if Account.objects.get(username=session['username']).type != "Admin":
        return jsonify(status=400, result="Unauthorized Access")
    accounts = Account.objects(type='Student')
    for account in accounts:
        account.delete()
    return jsonify(status=200, result="OK")
Ejemplo n.º 6
0
 async def daily(self, ctx):
     try:
         self.bot.account_list[ctx.author.id].balance += 500
         await ctx.send(f'Increased credits by 500!')
     except KeyError:
         self.bot.account_list.update(
             {ctx.author.id: Account(user_id=ctx.author.id)})
         await ctx.send("Welcome to the bot! We've given you 1500 credits!")
         self.bot.account_list[ctx.author.id].balance += 500
Ejemplo n.º 7
0
def dataUctu():
    r = requests.get(
        'https://api.csas.cz/sandbox/webapi/api/v2/transparentAccounts/',
        headers=headers)

    data = json.loads(r.text, "utf8")
    A = []
    for i in range(len(data.get('accounts', []))):
        ucet = Account(data['accounts'][i]['accountNumber'],
                       data['accounts'][i]['name'],
                       str(data['accounts'][i]['bankCode']),
                       float(data['accounts'][i]['balance']),
                       data['accounts'][i].get('currency', None), True)
        A.append(ucet)

    for i in range(len(data['accounts'])):
        cisloUctu = data['accounts'][i]['accountNumber']

        r = requests.get(
            'https://api.csas.cz/sandbox/webapi/api/v2/transparentAccounts/' +
            cisloUctu + '/transactions/',
            headers=headers)
        #print(json.dumps(dataUcet, indent=4, sort_keys=True))
        dataUcet = json.loads(r.text)
        #print(json.dumps(data, indent=4, sort_keys=True))
        for i in range(len(dataUcet.get('transactions', []))):
            tranS = Account(
                str(dataUcet['transactions'][i]['sender'].get(
                    'accountNumber', None)), None,
                dataUcet['transactions'][i]['sender'].get('bankCode', None),
                None, None, False)

            if tranS not in A:
                A.append(tranS)

            tranR = Account(
                str(dataUcet['transactions'][i]['receiver'].get(
                    'accountNumber', None)), None,
                dataUcet['transactions'][i]['receiver'].get('bankCode', None),
                None, None, 0)

            if tranR not in A:
                A.append(tranR)
    return A
Ejemplo n.º 8
0
def _set_account(acc: classes.Account, a_player: classes.ActivePlayer):
    """
    Set player's account.

    :param acc: Account to give.
    :param a_player: Player who will receive the account.
    """
    log.info(
        f"Give account [{acc.id}] to player: id:[{a_player.id}], name:[{a_player.name}]"
    )

    # Put account in the busy dictionary
    del _available_accounts[acc.id]
    _busy_accounts[acc.id] = acc

    # Set account
    acc.a_player = a_player
    acc.add_usage(a_player.id, a_player.match.id)
    a_player.account = acc
Ejemplo n.º 9
0
def marshal_account(row):
    serial_number = row['Serial Number']
    firstname = row['First Name']
    lastname = row['Last Name']
    address = row['Address']
    year = int(row['Year'])
    balance = float(row['Balance'])
    username = row['Username']
    password = row['Password']

    if serial_number[0] == "C":
        account_type = "Current"
    elif serial_number[0] == "S":
        account_type = "Savings"

    account = Account(firstname, lastname, account_type, address, year,
                      username, password)
    account.serial_number = serial_number
    account.balance = balance

    return account
Ejemplo n.º 10
0
 async def points(self, ctx):
     try:
         points = self.bot.account_list[ctx.author.id].balance
         await ctx.send(
             f'{ctx.author.name} currently has {str(points)} points!')
         return points
     except KeyError:
         self.bot.account_list.update(
             {ctx.author.id: Account(user_id=ctx.author.id)})
         points = self.bot.account_list[ctx.author.id].balance
         await ctx.send(
             f'{ctx.author.name} currently has {str(points)} points!')
         return points
Ejemplo n.º 11
0
def admin_init():
    # check if there's an admin
    try:
        admin = Account.objects.get(username="******", type="Admin")
        print("Admin exists")
    except Exception as e:
        password = "******"
        salt = hash_utils.generate_salt()
        digest = hash_utils.hmac_hash(password, salt)
        Account(username="******",
                hashed_password=digest,
                salt=salt,
                type="Admin").save()
        print("Created Admin")
    return
Ejemplo n.º 12
0
from classes import Account

account_list = {
    236287545208602626:
    Account(user_id=236287545208602626,
            lol_account_id="abc123",
            balance=9992.0,
            jackpot_winner=False),
    99620842677243904:
    Account(user_id=99620842677243904,
            lol_account_id="abc123",
            balance=10000,
            jackpot_winner=False),
    228716653318373376:
    Account(user_id=228716653318373376,
            lol_account_id="abc123",
            balance=141401904.6,
            jackpot_winner=False),
    219659295648776203:
    Account(user_id=219659295648776203,
            lol_account_id="PpmKzw_ZAVHHlthEAYlkuKlPP2qJdR8fvybgP2itiUGgqUc",
            balance=1000,
            jackpot_winner=False),
    175457201765351425:
    Account(user_id=175457201765351425,
            lol_account_id="ANtDEHDjQcnTHQ4jifoUmt-QuvRDVjU5PnjhNEPUDCjxnJU",
            balance=1000,
            jackpot_winner=False)
}
Ejemplo n.º 13
0
def writeAccount():
    account = Account()
    account.createAccount()
    writeAccountsFile(account)
Ejemplo n.º 14
0
 def test_show_transaction(self):
     account = Account()
     actual_result = type(account.show_transaction('tester'))
     expected_result = type([])
     self.assertEqual(actual_result, expected_result)
Ejemplo n.º 15
0
 def test_pay_amount(self):
     account = Account()
     actual_result = account.pay_amount('tester', 'Nepal Electricity Board',
                                        500)
     self.assertTrue(actual_result)
Ejemplo n.º 16
0
 def test_load_amount(self):
     account = Account()
     actual_result = account.load_amount('tester', 'Janata Bank', '1234',
                                         30000)
     self.assertTrue(actual_result)
Ejemplo n.º 17
0
def AddAccount():
    accountNumber = int(input('Kontonummer:'))
    account = Account(accountNumber)
    print(account.GetAccountNumber())
Ejemplo n.º 18
0
accounts = []
cryptotweets = []

names = []

name_input = ''

while name_input != 'Done':
    name_input = str(input("Enter names of People to Search on Twitter: "))
    if name_input == 'Done':
        break
    else:
        names.append(name_input)

for name in names:
    accounts.append(Account(name))

for account in accounts:
    account.tweet = driverTool.searchTweets('username', 'password', account.name)

for account in accounts:
    print(account.name)
    print(account.tweet)
    print('\n')
    type = classifier.classify(account.tweet)
    if type is True:
        cryptotweets.append(account)

'''
for tweet in cryptotweets:
    print(tweet.name)
Ejemplo n.º 19
0
y(0.2)

y = Y(1.5)
y(0.2)
print y


def diff(f, x, h=1.0E-10):
    return (f(x + h) - f(x)) / float(h)


y1 = Y(1)
print diff(y1.value, 0, 1)

from classes import Account
a1 = Account('John Olsson', '19371554951', 20000)
a2 = Account('Liz Olsson', '19371564761', 20000)
a1.deposit(1000)
a1.withdraw(4000)
a2.withdraw(10500)
a1.withdraw(3500)
print "a1's balance:", a1.balance
a1.dump()
a2.dump()

a1.no = '19371564764'
a1.balance = 100
a1.dump()

from classes import AccountP as Account
a1 = Account('John Olsson', '19371554951', 20000)
Ejemplo n.º 20
0
y(0.2)

y = Y(1.5)
y(0.2)
print y


def diff(f, x, h=1.0E-10):
    return (f(x+h) - f(x))/float(h)

y1 = Y(1)
print diff(y1.value, 0, 1)


from classes import Account
a1 = Account('John Olsson', '19371554951', 20000)
a2 = Account('Liz Olsson',  '19371564761', 20000)
a1.deposit(1000)
a1.withdraw(4000)
a2.withdraw(10500)
a1.withdraw(3500)
print "a1's balance:", a1.balance
a1.dump()
a2.dump()

a1.no = '19371564764'
a1.balance = 100
a1.dump()

from classes import AccountP as Account
a1 = Account('John Olsson', '19371554951', 20000)
Ejemplo n.º 21
0
from classes import Client, Account

victor = Client('Victor dos Santos Cruz', '11 91234-5678', '****')
marcela = Client('Marcela Santos Azevedo', '11 99876-5432', '****')
print()
print('$$$$$$   >>>  VICTOR <<<   $$$$$$')
print()
print(('Name: %s \n Cell phone: %s') % (victor.name, victor.telephone))
account1 = Account([victor], '1010', 11111, 1)
account1.summary()
print()
print('$$$$$$   >>>  MARCELA <<<   $$$$$$')
print()
print(('Name: %s \n Cell phone: %s.') % (marcela.name, marcela.telephone))
account2 = Account([marcela], '2020', 22222, 2)
account2.summary()
print()

print('CONTA DE UM OUTRO SÓCIO DO BANCO')

wesley = Client('Wesley Estevam', '1234-5678', '******')
print()
print(' $$$$$$ >>>   SEJA BEM VINDO   <<< $$$$$$')
print(('Name: %s \n Cell phone: %s') % (wesley.name, wesley.telephone))

conta = Account([wesley], 3333, 55555, 7, '100k')
conta.sake(50)
conta.summary()
Ejemplo n.º 22
0
lumpy = Lumpy() 
lumpy.make_reference()   # not necessary for class diagrams
y = Y(v0=4)
lumpy.object_diagram()
lumpy.class_diagram()
del y # remove it from the next diagrams

lumpy = Lumpy() 
v = VelocityProfile(beta=0.06, mu0=0.02, n=0.3, R=1)
lumpy.object_diagram()
lumpy.class_diagram()
del v

lumpy = Lumpy() 
v = Account('John Doe', '93351545761', 1000)
lumpy.object_diagram()
lumpy.class_diagram()
del v

lumpy = Lumpy() 
v = AccountP('John Doe', '93351545761', 1000)
lumpy.object_diagram()
lumpy.class_diagram()
del v

lumpy = Lumpy() 
v = Person('John Doe', email='*****@*****.**')
v.add_mobile_phone('18805614211')
lumpy.object_diagram()
lumpy.class_diagram()
Ejemplo n.º 23
0
def delete_student_data():
    Account.objects(type="Student").delete()
Ejemplo n.º 24
0
def thread_import_student_data(lines):
    from scraper import highschool_exists
    index = ['username', 'password', 'state', 'high_school_name',
             'high_school_city', 'high_school_state', 'gpa', 'college_class',
             'major_1', 'major_2', 'sat_math', 'sat_ebrw', 'act_english',
             'act_math', 'act_reading', 'act_science', 'act_composite',
             'sat_lit', 'sat_us', 'sat_world', 'sat_math_1', 'sat_math_2',
             'sat_eco_bio', 'sat_mol_bio', 'sat_chem', 'sat_physics',
             'ap_passed']

    for line in lines:
        username = line[0]
        password = line[1]
        salt = hash_utils.generate_salt()
        digest = hash_utils.hmac_hash(password, salt)
        account = Account(username=username,
                          hashed_password=digest,
                          salt=salt, type="Student")
        try:
            account.save()
        except Exception as e:
            # print(e)
            print("There was an error importing student data: "+username)

    for line in lines:
        username = line[0]
        try:
            account = Account.objects.get(username=username, type="Student")
        except:
            print("Account could not be loaded: "+username)
            continue
        # Make student profile class
        # TODO: Decide on what attributes are optional
        # TODO: Add checks for if this data is not pressent?
        hs_name = line[index.index('high_school_name')].title().replace(".", "")
        hs_city = line[index.index('high_school_city')].title()
        hs_state = line[index.index('high_school_state')]
        if hs_name != '' and hs_city != '' and hs_state != '':
            highschool_exists(hs_name, hs_city, hs_state)
        p = StudentProfile(
            student=account,
            gpa=float(line[index.index('gpa')]),
            residence_state=line[index.index('state')],
            high_school_name=hs_name,
            high_school_city=hs_city,
            high_school_state=hs_state,
            college_class=int(line[index.index('college_class')]))
        for x in range(index.index('major_1'), len(index)):
            info = index[x]
            data = line[x]
            if data != '':  # the field isn't empty
                if info == "major_1":
                    p.major_1 = data
                elif info == "major_2":
                    p.major_2 = data
                else:
                    p.grades[info] = int(data)
        try:
            p.save()
        except Exception as e:
            print(e)
            print("Profile couldn't be loaded: "+username)
            continue