def run(self): """ Runs through the authentication process """ while True: # Prompts and retrieves the users auth choice authAction = self.view.getAuthenticationAction() if authAction == {}: self.view.logMessage("#ERROR: Don't Click on the Options, Try again with keystrokes") continue authAction = authAction['auth method'] if authAction == 'Login with UserId': # Prompts and retrieves the users credentials uid = self.view.getLoginCredentials() # Attempts to login the user with their credentials provided results = self.model.attemptLogin(uid) if len(results) > 0: self.view.displayReport(uid, results) else: self.view.logMessage("No Report for this User: "******"Logged in anonymously") # Moves to the main controller MainController.MainController(self.port).run(-1) else: # Exit break return
def process(): # clean session errors if 'errors' in session: session.pop('errors') userId = request.form['userId'] audio = request.files['audio'] # get the userId in request args and check it's egal to our session['userId] if session['userId'] and str(userId) == str(session['userId']): # initialise main controller processor = MainController(VP, NLP, PF) # dispatch request res = processor.process_audio(audio) if int(res[1]) == 666: # Error # save error message to session session['errors'] = res[0] else: # save result to session session['result'] = res[0] # return result status return dict({'status': res[1]}) else: return dict({'status': 401})
from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from base import Base from controllers import MainController from views import MainView from settings import DB_CONNECTION_STRING engine = create_engine(DB_CONNECTION_STRING) Base.metadata.create_all(engine) Session = sessionmaker(bind=engine) session = Session() main_controller = MainController(session) main_view = MainView(main_controller) main_view.render()
from collections import namedtuple from flask import Flask, request from time import sleep import json from controllers import MainController from measurer import Mode with open('config.json') as f: config = json.load(f, object_hook=lambda d: namedtuple('Config', d.keys())(*d.values())) controller = MainController(config) app = Flask(__name__) @app.route('/application', methods=['POST']) def application(): content = request.get_json() command = content['command'] msg = 'success' code = 200 if command == 'exit': controller.close() elif command == 'reset': pass elif command == 'reserved': pass else:
#!/usr/bin/python3 from controllers import MainController # Run the application. if __name__ == "__main__": MainController().loop()
def run(self): """ Runs through the authenticaiton process """ while (True): # Prompts and retrieves the users auth choice authAction = self.view.getAuthenticationAction() if (authAction == {}): self.view.logMessage( "#ERROR: Don't Click on the Options, Try again with keystrokes" ) continue authAction = authAction['auth method'] if authAction == 'Login': # Prompts and retrieves the users credentials credentials = self.view.getLoginCredentials() # Attempts to login the user with their credentials provided result = self.model.attemptLogin(credentials['uid'], credentials['password']) if result is not None: MainController.MainController(self.pathToDb).run( credentials['uid']) # move to main controller else: self.view.logMessage( "#ERROR: Wrong uid or password, Try again") elif authAction == 'Create Account': # Prompts and retrieves the desired uid uid = self.view.getCreateAccountUid() # Continuously prompts the user for a uid until is is not taken uidIsUnique = self.model.getUserByUid(uid) == None if (len(uid) > 4): self.view.logMessage( '#ERROR: UID \'{}\' is longer than 4 characters.'. format(uid)) self.view.logMessage("Please enter a valid uid") continue while not uidIsUnique: # Outputs an error message if the uid is not unique self.view.logMessage( 'UID \'{}\' is taken, please try again'.format(uid)) # Prompts and retrieves the desired uid uid = self.view.getCreateAccountUid() # Validates that the requested uid is available uidIsUnique = self.model.getUserByUid(uid) == None # Prompts and retrieves the remainder of the users credentials credentials = self.view.getCreateAccountCredentials() name = credentials['name'] city = credentials['city'] password = credentials['password'] # Creates an entry in the users table self.model.createAccount(name, city, uid, password) MainController.MainController(self.pathToDb).run( uid) # move to main controller else: # Exit break return
# -*- coding:UTF-8 -*- __author__ = 'lilei' import tkinter as tk from controllers import MainController if __name__ == '__main__': root = tk.Tk() root.withdraw() app = MainController(root) root.mainloop()