Example #1
0
def login():
    global connection, cursor
    input_id = input("Please enter your pid: ")
    if check_user_id(input_id):  	# if input_id exists
        correct_password = get_stored_password(input_id)
        input_password = input("Please enter your password: "******"Password Correct!\n")
            role = get_role(input_id)
            role_lower = role.lower()
            if role_lower == 'account manager':
                print("Welcome! Account Manager!\n")
                account_manager(input_id,connection, cursor)
            elif role_lower == 'supervisor':
                print("Welcome! Supervisor!\n")
                supervisor(input_id, connection, cursor)
            elif role_lower == 'dispatcher':
                print("Welcome! Dispatcher!\n")
                dispatcher(connection, cursor)
            elif role_lower == 'driver':
                print("Welcome! Driver!\n")
                driver(input_id, connection, cursor)
            else:
                print('Something wrong with your role.\n')
        else:
            print("Password wrong or user does not exist, please restart.\n")
    else:
        print("Your pid does not exist in users table. Please check again, or consider signing up.\n")
Example #2
0
def log_in():

    exit = 0
    exit1 = 0
    while (exit < 3 and exit1 < 3):
        username = input("Please input your username ")
        if check_username(username) is not False:
            username = check_username(username)
            pwd = getpass(prompt="Please input your password: "******"select role from users where login=:username",
                               {"username": username})
                role = cursor.fetchone()
                role = role[0]
                cursor.execute(
                    "select user_id from users where login=:username",
                    {"username": username})
                user_id = cursor.fetchone()
                user_id = user_id[0]
                if re.match(role, "account manager", re.IGNORECASE) != None:
                    account_manager(user_id, connection, cursor)
                    break
                if re.match(role, "supervisor", re.IGNORECASE) != None:
                    supervisor(user_id, connection, cursor)
                    break
                if re.match(role, "dispatcher", re.IGNORECASE) != None:
                    dispatcher(user_id, connection, cursor)
                    break
                if re.match(role, "driver", re.IGNORECASE) != None:
                    driver(user_id, connection, cursor)
                    break
            else:

                exit1 += 1
                if exit1 < 3:
                    print(
                        "The username or password entered is not correct, please input again"
                    )
                continue
        else:

            exit += 1

            if exit < 3:
                print(
                    "The username inputed does not exist, please input again ")
            continue

    if exit == 3 or exit1 == 3:
        print("Your have login failed 3 times, the system has been shutdown")
    def dash_ajax_json(self):
        """ 
            respond to the dash ajax json / react request's 
        """
             
        print(" processing dash_ajax method")
       
        #
        # now hand over to the dispatcher
        #
        retval = dispatcher(self.request, index=False, username="******", session_id=1234, powapp=self.application)
        
        #self.set_header('Content-Type', 'application/json')
        self.write(retval)
    
    # def dash_ajax_assets(self):
    #     """ 
    #         respond to the dash ajax assets/ react request's 
    #     """
             
    #     print(" processing dash_ajax_assets method")
       
    #     #
    #     # now hand over to the dispatcher
    #     #
 
    #     """Handle Dash requests and guess the mimetype. Needed for static files."""
    #     url = request.path.split('?')[0]
    #     content_type, _encoding = mimetypes.guess_type(url)

    #     retval = dispatcher(self.request, index=False, username="******", session_id=1234, powapp=self.application)
        
    #     self.set_header('Content-Type', content_type)
    #     self.write(retval)
Example #4
0
 def __init__(self, remotehost, remoteport, bindport, XMLfiles):
     asyncore.dispatcher.__init__(self)
     self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
     self.there = (remotehost, remoteport)
     self.bind(('', bindport))
     self.listen(1)
     self.pkt_dispatcher = dispatcher(XMLfiles)
     print 'Listening on port %d \n' % (bindport)
    def dash(self, **kwargs):
        """ 
            This is the place where dash is called.
            dispatcher returns the HMTL including title, css, scripts and config via => dash.Dash.index()
            (See: in pow_dash.py => myDash.index)
            You can then insert the returned HTML into your template.
            I do this below in the self.render/self.success call => see base_dash.bs4 template (mustache like syntax)
        """
        print("processing dash method")
        #external_stylesheets = see config.py dash section

        retval = dispatcher(self.request, username="******", session_id=1234, index=True )
        # 
        # this is the render template call which embeds the dash code (dash_block=retval)
        # from dispatcher (see above)
        self.set_header('Content-Type', "text/html")
        self.render("dash_index.tmpl", dash_block=retval)
Example #6
0
    def __init__(self, remotehost, remoteport, bindport, XMLfiles, LOGfile):
        asyncore.dispatcher.__init__(self)

        # Creation of the local logger
        handler = logging.FileHandler(LOGfile)
        handler.setLevel(logging.INFO)
        formatter = logging.Formatter('%(asctime)s %(levelname)-8s %(message)s')
        handler.setFormatter(formatter)
        loggername = os.path.splitext(LOGfile)[0]
        logging.getLogger(loggername).addHandler(handler)
        self.logger = logging.getLogger(loggername)

        # Creation of the Socket
        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.there = (remotehost, remoteport)
        self.bind(('', bindport))
        self.set_reuse_addr()
        self.listen(1)
        self.pkt_dispatcher = dispatcher(XMLfiles)

        self.logger.info('Listening on port %d \n' % (bindport))