def create(): req_data = request.get_json() data, error = user_schema.load(req_data) if error: return custom_response(error, 400) user_in_db = User.get_by_email(data.get('email')) if user_in_db: message = {'error': 'User already exists'} return custom_response(message, 400) user = User( name=data.get('name'), email=data.get('email'), ) user.set_password(password=data.get('password')) user.save() serialized_data = user_schema.dump(user).data token = Auth.generate_token(serialized_data.get('uid')) return custom_response( { 'jwt_token': token, 'uid': serialized_data.get('uid'), }, 201)
def login(): req_data = request.get_json() data, error = user_schema.load(req_data, partial=True) if error: return custom_response(error, 400) if not data.get('email') or not data.get('password'): return custom_response( {'error': 'you need email and password to sign in'}, 400) user = User.get_by_email(data.get('email')) if not user: return custom_response({'error': 'invalid credentials'}, 400) if not user.check_password(data.get('password')): return custom_response({'error': 'invalid credentials'}, 400) serialized_data = user_schema.dump(user).data token = Auth.generate_token(serialized_data.get('uid')) return custom_response( { 'jwt_token': token, 'uid': serialized_data.get('uid'), }, 200)
from algorithms.bollinger_bands import BollingerBands from algorithms.rsi import * from algorithms.dual_avg_crossover import DualAverageCrossover from algorithms.mfi import MoneyFlowIndex from algorithms import mfi import algorithms.high_speed.rsi_speed as rsi_speed import algorithms.high_speed.bollinger_speed as bollinger_speed from algorithms.longshort import * from authentication import Auth auth = Auth() def begin(): print("Welcome!") auth.execute() handle_mode_command() def handle_mode_command(): while True: print("Enter bot mode: ") print( "0. Exit\n1. Testing\n2. Live Trading\n3. High Speed Trading\n4. Switch to Another Account\n5. Print " "Account Data\n") mode = input("=> ") if mode.isdigit():
def test_get_sig_address_from_event(): auth = Auth(c) addr = auth.get_sig_address_from_event(event_dict) assert addr == "0x1c0b2f7a73ecbf7ce694887020dbcbaaa2e126f7"
def test_sign_event(): auth = Auth(c) signed_event = auth.sign_event(event_dict=event_dict) assert signed_event["_id"] == event_dict["_id"]
def main(): parser = ArgumentParser(description='Process the arguments') parser.add_argument('-ConfigFile', help='Enter the config file name', type=str) args = parser.parse_args() config = ConfigParser() config.read(args.ConfigFile) userName = config['DEFAULT']['username'] password = config['DEFAULT']['password'] siteName = config['sharepoint']['sitename'] baseURL = config['sharepoint']['baseurl'] siteURL = config['sharepoint']['siteurl'] folderPath = config['fileinfo']['folderpath'] fileExtention = config['fileinfo']['fileextention'] indexExtention = config['fileinfo']['indexextention'] sharePointFolder = config['sharepoint']['sharepointfolder'] sharePointCustomeColumnList = ['Dealer Name', 'Date Signed'] hasIndex = config['fileinfo'].getboolean('hasindex') sourceFolder = Path(folderPath) util = Util() indexing = Indexing() # returns True if there are files in the dealer_folder non_empty_dirs = bool({ str(p.parent) for p in sourceFolder.rglob(f'*.{fileExtention}') if p.is_file() }) if non_empty_dirs: #login into sharepoint site login = Auth(userName, password, siteURL, baseURL) #iterate over files in the source folder files = [p for p in sourceFolder.iterdir() if p.is_file()] #if the source folder contains an index file if hasIndex: for file in files: # Find all files in folder match_file_name = file.match(f'*.{indexExtention}') if match_file_name: indexRead = indexing.readIndex(file.name, folderPath) Upload(login.site, folderPath, indexRead[-1], sharePointFolder) customeMetaDict = util.createDict( sharePointCustomeColumnList, indexRead[0:-1]) AddMeta(login.site, indexRead[-1], folderPath, sharePointFolder, customeMetaDict) else: pass else: for file in files: # Find all files in folder match_file_name = file.match(f'*.{fileExtention}') if match_file_name: upload = Upload(login.site, folderPath, file.name, sharePointFolder) keywords = indexing.createKeywords(folderPath, file.name) customeMetaDict = util.createDict( sharePointCustomeColumnList, keywords) AddMeta(login.site, file.name, folderPath, sharePointFolder, customeMetaDict) else: print('Looks like the folder is equal to your heart')
import sys import time from random import randint import click import socketio import config from authentication import Auth from db import Database from model import Staff, Event, MeetingEventType, StartContent, DeeIdLoginSigSigned, Meeting sio = socketio.Client() sio.connect('http://*****:*****@sio.on('room-message') def on_message(data): global ref_event event = json.loads(data) print("Message from Server!") print_event(event)
from scan_item import ip_endpoint, mac_endpoint, host_endpoint, manage_endpoint app = Flask(__name__) api = Api(app) try: with open('config.json') as fs: config = json.load(fs) except: raise client = MongoClient(username=config.get('user'), password=config.get('pwd'), authSource='LanScan') db = client['LanScan'] auth_help = Auth(db, config.get('secret')) api.add_resource(login_endpoint, '/api/1.0/login', resource_class_args=(db, config.get('secret'), auth_help)) api.add_resource(keys_endpoint, '/api/1.0/token', resource_class_args=(db, config.get('secret'), auth_help)) api.add_resource(scan_endpoint, '/api/1.0/scans', resource_class_args=(db, auth_help)) api.add_resource(vlan_endpoint, '/api/1.0/scans/<vlan>', resource_class_args=(db, auth_help)) api.add_resource(ip_endpoint, '/api/1.0/scans/<vlan>/ip/<ip>',