예제 #1
0
    def _setup_db(self):
        DB_CONFIG = self.CONFIG['database']
        PROMPT = self.CONFIG['workflow']['prompt']
        DBAPI = DB_CONFIG['db_api']
        USER = DB_CONFIG['user']
        # password_ = input(PROMPT['input']['db_root_password'])
        password_ = self.db_root_passwd
        HOST = DB_CONFIG['host']
        DB_NAME = DB_CONFIG['db_name']
        ARGS = DB_CONFIG['args']

        self.cnx = mysql.connector.connect(user=USER,
                                           password=password_,
                                           host=HOST,
                                           use_pure=True)
        utils.create_database(self.cnx, DB_NAME)
        utils.use_database(self.cnx, DB_NAME)

        # Define the MySQL engine using MySQL Connector/Python
        connect_string = ('{0}://{1}:{2}@{3}/{4}?{5}'.format(
            DBAPI, USER, password_, HOST, DB_NAME, ARGS))
        self.engine = create_engine(connect_string, echo=False)
        # Create table of cwind station
        Base.metadata.create_all(self.engine)
        self.Session = sessionmaker(bind=self.engine)
        self.session = self.Session()
예제 #2
0
def render_cases(choice):
    if choice == 1:
        try:
            utils.create_database()
            utils.create_table()

        except Exception as e:
            print(e)
            print("UNABLE TO CREATE TABLE !!")

        finally:
            utils.input_and_save_user()
            print("Your membership has been created !! ")
            print("Have a nice day !")
            utils.display_main_menu()
            render_cases(int(input()))

    elif choice == 2:
        member_uuid = utils.login_member()
        if member_uuid:
            (book_name, fine) = utils.check_for_pending_books(member_uuid)
            if fine is not None:
                print("You have a pending book ")
                print("Book Name-> ", book_name)
                print("Due -> ", fine)
            utils.display_book_lending_options()
            handle_book_lend_cases(int(input()), member_uuid)

        else:
            print("User not found ! Please try again ")

    elif choice == 3:
        system('cls')
        print("Enter Username: "******"Enter Password: "******"admin"
                and admin_password == "admin") or utils.is_user_admin(
                    admin_username, admin_password):
            system('cls')
            utils.display_admin_options()
            handle_admin_cases(int(input()))
        else:
            print("Invalid Credentials. Try again.")
            utils.display_main_menu()
            render_cases(int(input()))

    elif choice == 4:
        exit(0)

    else:
        print("Invalid Input !!")
예제 #3
0
파일: server.py 프로젝트: tax/snor
def main():
    # Create db and tables if it doesn't exist
    parser = argparse.ArgumentParser()
    parser.add_argument('--port', default=5555, type=int)
    parser.add_argument('--host', default='0.0.0.0')
    parser.add_argument('--debug', action='store_true')
    args = parser.parse_args()

    utils.create_database()
    utils.start_background_tasks(args.host, args.port)
    # Start webserver
    app.secret_key = str(settings.secret_key)
    app.run(host=args.host,
            port=args.port,
            debug=args.debug,
            use_reloader=False)
예제 #4
0
파일: server.py 프로젝트: tax/snor
def main():
    # Create db and tables if it doesn't exist
    parser = argparse.ArgumentParser()
    parser.add_argument('--port', default=5555, type=int)
    parser.add_argument('--host', default='0.0.0.0')
    parser.add_argument('--debug', action='store_true')
    args = parser.parse_args()

    utils.create_database()
    utils.start_background_tasks(args.host, args.port)
    # Start webserver
    app.secret_key = str(settings.secret_key)
    app.run(
        host=args.host,
        port=args.port,
        debug=args.debug,
        use_reloader=False
    )
예제 #5
0
    def run(self, app, args):
        loop = asyncio.get_event_loop()
        test_config = get_test_config()
        loop.run_until_complete(create_database(test_config))
        run_command = './tests'

        if args.test_file:
            run_command += '/' + args.test_file

        pytest.main(['-x', '-s', run_command])

        loop.run_until_complete(drop_database(test_config))
예제 #6
0
import socket
from pathlib import Path
from utils import create_database, extract_route, load_data, read_file, build_response
from views import index, error_page

CUR_DIR = Path(__file__).parent
SERVER_HOST = '0.0.0.0'
SERVER_PORT = 8080

server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server_socket.bind((SERVER_HOST, SERVER_PORT))
server_socket.listen()

create_database()

print(
    f'Servidor escutando em (ctrl+click): http://{SERVER_HOST}:{SERVER_PORT}')

while True:
    client_connection, client_address = server_socket.accept()

    request = client_connection.recv(1024).decode()

    route = extract_route(request)
    filepath = CUR_DIR / route
    if filepath.is_file():
        response = build_response() + read_file(filepath)
    elif route == '':
        response = index(request)
    else:
예제 #7
0
 def run(self, app, args):
     loop = asyncio.get_event_loop()
     loop.run_until_complete(create_database(config))
예제 #8
0
import imutils
import dlib
import face_recognition
import mouth_detection
import datetime
import detector_utils
import threading
import sys

# initialize dlib's face detector (HOG-based) and then create the facial landmark predictor
detector = dlib.get_frontal_face_detector()
predictor_path = './shape_predictor_68_face_landmarks.dat'
predictor = dlib.shape_predictor(predictor_path)

# create database
known_names, known_faces_encoding = utils.create_database('../Images/database/group3')
known_names.append('unknown')

os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"

# construct the argument parse and parse the arguments
tf.app.flags.DEFINE_string('test_data_path', '/tmp/ch4_test_images/images/', '')
tf.app.flags.DEFINE_string('expected', '0', '')
tf.app.flags.DEFINE_string('name', '0', '')
FLAGS = tf.app.flags.FLAGS

gpu_list = '0'
box_padding = 0.12

checkpoint_path = '../extra/model/east_icdar2015_resnet_v1_50_rbox'
예제 #9
0
                help="path to input video file")
ap.add_argument("-d",
                "--database",
                required=True,
                help="path to input images file")
ap.add_argument("-n", "--name", required=True, help="patient's name")

args = vars(ap.parse_args())

# initialize dlib's face detector (HOG-based) and then create the facial landmark predictor
detector = dlib.get_frontal_face_detector()
predictor_path = './shape_predictor_68_face_landmarks.dat'
predictor = dlib.shape_predictor(predictor_path)

# create database
known_names, known_faces_encoding = utils.create_database(args["database"])
known_names.append('unknown')


def thread_video(input):
    # Dedicated thread for grabbing video frames with VideoGet object.
    # Main thread shows video frames.
    video_getter = VideoGet(input).start()

    nb_total = 0
    nb_fr = 0
    nb_pill = 0

    while True:
        if video_getter.stopped:
            video_getter.stop()
예제 #10
0
import utils
import mouth_detection
import os

# create database
known_names, known_faces_encoding = utils.create_database(
    '../Images/database/group1')

# load images to test
unknown_names, unknown_faces_encoding = utils.create_database(
    '../Images/test_face/group1')
known_names.append('unknown')

index = [
    utils.recognize_face(unknown_face_encoding, known_faces_encoding)
    for unknown_face_encoding in unknown_faces_encoding
]
names = [known_names[i] for i in index]
utils.compare_result(unknown_names, names)

# results :
# test only group 1 : Result : 1 error out of 18. Accuracy: 0.94
# test only group 2 : Result : 0 error out of 8. Accuracy: 1
# test group 3 (all photos) : Result : 1 error out of 26. Accuracy: 0.96

filepath = '../Images/test_mouth/'
predictor_path = './shape_predictor_68_face_landmarks.dat'

paths = utils.load_paths(filepath)
image_paths = [os.path.join(filepath, f) for f in paths]