Exemplo n.º 1
0
	def add_user(self, user_id, username):
		if not user_id in self.users.keys():
			self.users[user_id] = User(user_id, self.db, self.bot_controller_factory)
			return self.db.add_user(user_id, username)
Exemplo n.º 2
0
# 1.用户存币
# 2.用户提币
# 3.用户买币
# 4.用户卖币

if __name__ == '__main__':
    time_duration = 1

    thread = threading.Thread(target=run)
    thread.start()

    time.sleep(time_duration)

    for i in range(1, 10):
        user = User('TestUser%d' % i)
        for s in symbols:
            s = regex_utils.whole2hyphen(s)
            user.AmountDict[s] = 0.0
        users.append(user)

    symbol = 'eth-btc'
    new_symbol_dict = regex_utils.get_symbol_by_hyphen(symbol)
    currency = new_symbol_dict['coin']
    base = new_symbol_dict['base']
    we = We(users, exchanges)
    exchange_avg_price = we.get_exchange_avg_price_by_exchange(symbol)
    print('%s显示价格:%f' % (symbol, exchange_avg_price))
    we.user_depot('TestUser1', 100, currency)
    # excellent_e = we.get_excellent_exchange_by_symbol('eth-btc')
Exemplo n.º 3
0
 def setUp(self) -> None:
     self.bank = Bank()
     self.user = User()
     self.address = Address()
Exemplo n.º 4
0
        for block in self.chain:
            for transaction in block.transactions:
                if transaction.transaction_id == option:
                    user.purchases.append(transaction)
                    break


if __name__ == "__main__":
    dynamodb = boto3.resource('dynamodb', 'us-east-2')

    blockchain = Blockchain()

    table1_name = "Forum"
    table2_name = "ProductCatalog"

    user1 = User()
    user2 = User()

    print("Adding Transaction 1 ........")
    blockchain.add_data(table1_name,
                        "This table describes the features of some forums.",
                        60, user1)
    print(
        "***************************************************************************"
    )
    print("Mining block....")
    blockchain.mine_pending_transactions(user1)
    print("Finished mining.")
    print(
        "***************************************************************************"
    )
Exemplo n.º 5
0
 def add_user(self, firstName, lastName, email, password, dob, bio):
     user = User(firstName, lastName, email, password, dob, bio, "", "", "")
     self.usersList.append(user)
     return user
Exemplo n.º 6
0
 def test_create_with_pswd(self):
     user = User('user1', password='******')
     self.assertTrue(hasattr(user, 'pass_hash'))
     self.assertEqual(user.pass_hash, md5(b'QAZWSX!@').hexdigest())
Exemplo n.º 7
0
 def test_set_attr(self):
     user = User('user1', password='******')
Exemplo n.º 8
0
def create_account(user_name, password):
    '''
        Function to create a new account
        '''
    new_account = User(user_name, password)
    return new_account
Exemplo n.º 9
0
from lib.Component import Component
from lib.Adapter import Adapter
from User import User
from Main import Main
from MainView import MainView
from Game import Game
from PlayersManager import PlayersManager
from Board import Board

sys = Component('sys')
sys.attach(Main())
sys.attach(User())
game = sys.attach(Adapter(['game-start'], ['game-stopped']))

game.attach(Game())
game.attach(PlayersManager())
game.attach(Board())

sys.start()
Exemplo n.º 10
0
from Background import Background
from Beam import Beam
from Magnet import Magnet
from Speedup import Speedup
from os import system
from time import sleep
import termios
import sys
import select
import tty


sc = Gamescreen()
bg = Background()

u = User()
c = Coin()
bl = Bullet()

while sc.get_trip() < 2:

    b = []
    m = None
    sp = None

    sc.init_field()
    sc.init_trash()

    sc.set_nxt(0)
    sc.set_timer(0)
    sc.set_no(0)
Exemplo n.º 11
0
# import User class from User file
from User import User
from User import Admin

# create user object from User class
user = User("unai", "usainzg", "unai1808")

# call sayHello() method from created object
user.sayHello()

# call User class method, equals to static method call on java
User.classMethod(6)

# call to __str__ method
print(user)

# test __eq__ overrided method
uObj = User("unai", "usainzg", "123456")
print(user == uObj)

# inheritanced class object
admin = Admin("admin", "admin", "admin123", "idAdmin")
admin.printId()
def mainMenu():
    logo = ''' ******************* WELCOME TO VATICINATION - vaticination.ga ****************
               
       *************** Heart Disease Prediction System  ***********
            
          ************* MAKE SURE THAT INTERNET IS WORKING *********** '''

    print(logo)
    choice = -1
    current_user = -1

    while choice != '4':
        print('\n')
        print('1.Sign Up')
        print('2.Login Up')
        print('3.Quit')

        choice = input('Enter your choice: ')

        if choice == '1':
            first_name = input('First Name: ').upper()
            last_name = input('Last Name: ').upper()
            user_id = input('User id (Case-Sensitive): ')
            while True:
                password = input('Password (Min. 6-12 Digit): ')
                if 6 <= len(password) < 12:
                    break
                print("")
                print('The password must be between 6 and 12 characters.\n')
            address = input('Enter Address: ').upper()
            city = input('City: ').upper()
            state = input('State: ').upper()
            pincode = int(input('Pincode: '))
            phone = int(input('Phone No.: '))
            new_user = User(first_name, last_name, user_id, password, address,
                            city, state, pincode, phone)

            if new_user.save():
                print("")
                print('Thanks for signing up!')
                current_user = user_id
                accountMenu(current_user)
            else:
                print('Cannot create an account for you')

        elif choice == '2':
            attempts = 1
            while attempts <= 3:
                print("")
                print("Attempt %d: " % (attempts))
                user_id = input('User id (Case-Sensitive): ')
                password = input('Password: '******'Invalid credentials!')
                attempts += 1
            else:
                print('Max sign in attempts reached')
        elif choice == '3':
            exit()
        else:
            print('Invalid option!')
Exemplo n.º 13
0
 def createUser(self):
     username = self.getUsername()
     password = self.getUserPassword()
     email = self.getUserEmail()
     user = User(username, password, email)
     return user
Exemplo n.º 14
0
 def __init__(self, video_save_dir):
     self.user = User(video_save_dir)
     self.upload = Upload(self.user)
Exemplo n.º 15
0
from car import Car
from account import Account
from UberX import UberX
from Driver import Driver
from User import User

if __name__ == "__main__":
    print("Hola Mundo")
    '''
    car = Car("AMS234", Account("Andres Herrera", "ANDA876"))
    print(vars(car))
    print(vars(car.driver))

    uberX = UberX("AMS234", Account("Andres Herrera", "ANDA876"), "chev", "stm")
    print(vars(uberX))
    '''
    user1 = User(1, "Alejandro", "1803524534", "*****@*****.**", "pass")
    print(vars(user1))
Exemplo n.º 16
0
 def setUp(self):
     self.db = TEST_DB
     self.app = app.test_client()
     self.user = User(email='test_user', password='******')
Exemplo n.º 17
0
 def test_skip_optional(self):
     u = User('user2',
              'ashgdhsfv',
              email='*****@*****.**',
              fax='+380671412')
     self.assertFalse(hasattr(u, 'fax'))
Exemplo n.º 18
0
#!/usr/bin/python
from SilvairServer import Server
from Hooks import *
from User import User
import Core
from Logging import log, Level
import hashlib

Core.setup()

log(Level.INFO, "Starting server...")
mainserv = Server(None, 8001)
mainserv.listen()
log(Level.INFO, "Done")

s = hashlib.sha512()
s.update("test")
passw = s.hexdigest()

serv = {"host": "localhost", "port": 6667, "pass": None}
user = {
    "name": "Kilobyte",
    "pass": passw,
    "server": serv,
    "nick": "Kilo2",
    "realname": "Test",
    "ident": "test"
}
User(user)
Exemplo n.º 19
0
 def test_set_password(self):
     user = User('user1', password='******')
     user.password = '******'
     self.assertTrue(hasattr(user, 'pass_hash'))
     self.assertTrue(hasattr(user, 'password'))
Exemplo n.º 20
0
def sso_login():
    try:
        user_token = request.args.get('token')
    except:
        return redirect(url_for("login"))

    if user_token == None:
        print("Error: user_token is expected for login")
        return redirect(url_for("login"))

    try:
        authentication_result = _get_access_token('Token_WindowsAuth')
        authentication_access_token = authentication_result.access_token
        user_data = _get_user_data(authentication_access_token, user_token)
    except:
        logging.error("Unable to get USER DATA")
        return redirect(url_for("login"))

    try:
        membership_result = _get_access_token(
            'Token_WindowsAuth User_Read Authorization')
        membership_access_token = membership_result.access_token
        print("Membership acces token:", membership_access_token)
        user_membership = _get_user_membership(membership_access_token,
                                               user_data)
    except:
        logging.error("Unable to get USER MEMBERSHIP")
        return redirect(url_for("login"))

    print("USER MEMBERSHIPS:", user_membership)
    if GRP_SSDV not in user_membership:
        error_msg = "Please Apply for group 'ssdv' in AGS!"
        form = LoginForm()
        return render_template('login.html',
                               title='login',
                               form=form,
                               error_msg=error_msg)

    session['userInfo'] = {
        'userName': user_data['userName'],
        'displayName': user_data['displayName'],
        'id': user_data['id'],
        'externalId': user_data['externalId'],
        'email': user_data["emails"][0]["value"]
    }
    logging.info(session['userInfo'])

    if session['userInfo']['userName']:
        user_info = session['userInfo']['userName'].split("\\")
        region = user_info[0]
        username = user_info[1]

        # section to add user to database is deleted
        # TODO: looks like some DB will be needed to return user information to Flask login/logout plugins

        user_obj = User(username)
        login_user(user_obj)  # Flask function
        flash("Logged in successfully!", category='success')
        print("Logged in successfully!")
        return redirect(url_for("home"))
    else:
        error_msg = "Cannot get valid username info from Authorization server!"
        form = LoginForm()
        return render_template('login.html',
                               title='login',
                               form=form,
                               error_msg=error_msg)
Exemplo n.º 21
0
 def test_basic(self):
     u = User('user1', 'ashgdhsfv', email='*****@*****.**')
     self.assertEqual(u.username, 'user1')
     self.assertEqual(u.email, '*****@*****.**')
     self.assertNotEqual(u.password, 'ashgdhsfv')
Exemplo n.º 22
0
def load_user(user_id):
    # get the user specs from DB. OR can we get it from IAMWS again? But it will be very slow.
    # this information is required by Flask
    return User(user_id, 'ssdv')
from unittest import TestCase
from Viatge import Viatge
from User import User
steverogers = User("Steve Grant Rogers", "471", "Brooklyn", "*****@*****.**",
                   "983")

v1 = Viatge(steverogers, 4, [])
v2 = Viatge(steverogers, 10, [])
v3 = Viatge(steverogers, 2, [])
v1.afegir_desti("Paris")
v2.afegir_desti("Moscu")
v3.afegir_desti("Tokyo")


#Si se pasan los tests uno por uno, el resultado es bueno
#Si los se ponen todos a la vez, falla y no sabemos porqué
class Test_Viatge_Afegir_Destins(TestCase):
    #Controla que, al afegir destins, la llista de destins sigui la corresponent
    def test_afegir_destins_destins(self):
        assert v1.destins == ['Paris']
        assert v2.destins == ['Moscu']
        assert v3.destins == ['Tokyo']
        v1.afegir_desti("Roma")
        assert v1.destins == ['Paris', 'Roma']

    #Controla que, al afegir destins, la llista de vols sigui la corresponent
    def test_afegir_destins_vols(self):
        assert v1.vols[0].destinacio == "Paris"
        assert v2.vols[0].destinacio == "Moscu"
        assert v3.vols[0].destinacio == "Tokyo"
        v1.afegir_desti("Roma")
from Events import events
from User import User
from Event import Event
from Enforcer import Enforcer

john = User(123, "*****@*****.**", "john", "smith", 5, "ceo")
nick = User(321, "*****@*****.**", "nick", "mann", 1, "cashier")
testingFuncEvent = events["testingFunc"]

johnTestingFuncEnforcer = Enforcer(john, testingFuncEvent, {
    "param1": "abcabcabcabc",
    "param2": "123123123123"
})
johnTestingFuncEnforcer.details()

nickTestingFuncEnforcer = Enforcer(nick, testingFuncEvent, {
    "param1": "cbacbacbacba",
    "param2": "321321321321"
})
nickTestingFuncEnforcer.details()
Exemplo n.º 25
0
from User import User
import re
try:
    regex = '([A-Za-z0-9])([\W]){10-20}'
    name, mob, Username, passw = input("Enter the user details").split(",")
    x = re.search(regex, passw)
    user = User(name, mob, Username, passw)
    user.display()
except:
    print("week password")
Exemplo n.º 26
0
from User import User
from Sellitem import SellItem

owner = User("*****@*****.**", "asd asd", "pas34f.w")
token = input("enter token\n")
User.verify("*****@*****.**", token)

owner.listitems(owner,"qwe","sad")

buyer = User("*****@*****.**", "asd surname", "ppp")
token = input("enter token\n")
User.verify("*****@*****.**", token)

buyer2 = User("*****@*****.**", "asd kfkkf", "ppp2")
token = input("enter token\n")
User.verify("*****@*****.**", token)

User.watch("typ",buyer.notification)

buyer.addBalance(1000)
buyer2.addBalance(5000)

item = SellItem(owner,"title", "typ", "desc", "decrement", 1000, 2.0)
item.watch(buyer2,buyer2.notification)

try:
    item.bid(buyer,750)
except Exception as e:
    print(e)

item.startauction(10)
Exemplo n.º 27
0
 def load_user(sender, data):
     user = User(data["file_name"] + ".db")
     gg.delete_item("Choose User")
     MainGui(user)
Exemplo n.º 28
0
from User import User
from Address import Address
from Bank import Bank
from welcome import Welcome
from Utils import Utils
from DBUtils import DBUtils

welcome = Welcome()
utils = Utils()
address = Address()
user = User()
bank = Bank()
dBUtils = DBUtils()


def addUser():
    account = utils.random()
    user.setUsername(input("请输入用户名"))
    user.setPassword(input("请输入您的密码(6位数字):"))
    print("接下来要输入您的地址信息:")
    address.setCountry(input("请输入国家"))
    address.setProvince(input("请输入省份"))
    address.setStreet(input("请输入街道"))
    address.setDoor(input("请输入门牌号"))
    # 余额不允许第一次输入,需要存钱
    status = bank.bank_addUser(account, user.getUsername(), user.getPassword(),
                               address.getCountry(), address.getProvince(),
                               address.getStreet(), address.getDoor())
    if status == 1:
        print("恭喜开户成功!")
        info = '''
Exemplo n.º 29
0
from flask_login import LoginManager, current_user, login_required, login_user
from passlib.hash import sha256_crypt
from flask import Flask, request
from User import User, getUser

app = Flask(__name__)
app.secret_key = '123124124oihuencjskdbvliuageowl*(@&#HkajO*&BICk&*idwbkacwad'

login_manager = LoginManager()
login_manager.init_app(app)

users = {
    "ajwurts":
    User(
        'ajwurts',
        password=
        '******'
    )
}

cars = {'ajwurts': "Toyota Corolla iM"}


@login_manager.user_loader
def load_user(user_id):
    if user_id in users:
        return users[user_id]
    else:
        return None

Exemplo n.º 30
0
	def update_users(self):
		known_users = self.db.get_known_users()
		for user_id in known_users:
			if not (user_id in self.users.keys()):
				self.users[user_id] = User(user_id, self.db, self.bot_controller_factory)
		return self.users