def submitted_cases(submitted_by: str):
    query = "select * from submitted_cases where submitted_by='{}'".format(
        submitted_by)
    with PostgresConnection() as conn:
        cursor = conn.cursor()
        cursor.execute(query)
        return cursor.fetchall()
def authenticate_user(username, password, role):
    query = "select * from users where username='******' and password='******'".format(username, password)
    with PostgresConnection() as conn:
        cursor = conn.cursor()
        cursor.execute(query)
        if cursor.rowcount == 1:
            return True
        return False
def get_training_data(submitted_by: str, status: str = None):
    query = "select case_id, face_encoding from submitted_cases where submitted_by='{}'".format(
        submitted_by)
    if status:
        query = query + "and status='NF'"
    with PostgresConnection() as conn:
        cursor = conn.cursor()
        cursor.execute(query)
        return cursor.fetchall()
def authenticate(username: str, password: str, role: Optional[str] = None):
    result = False
    query = "select * from users where username='******' and password='******'".format(
        username, password)
    with PostgresConnection() as conn:
        cursor = conn.cursor()
        cursor.execute(query)
        if cursor.rowcount == 1:
            result = True
    return {"status": result}
Ejemplo n.º 5
0
def create():
    with PostgresConnection() as conn:
        cursor = conn.cursor()
        table_queries = [
            user_submission_table, submitted_cases_table, users_tables,
            admin_user_query
        ]
        for table_query in table_queries:
            try:
                cursor.execute(table_query)
            except psycopg2.IntegrityError as e:
                pass
def submit_user_data(user_submission):
    name = user_submission.name
    location = user_submission.location
    mobile = user_submission.mobile
    image = user_submission.image
    face_encoding = user_submission.face_encoding
    sub_id = user_submission.sub_id
    status = 'NC'
    query = f"insert into user_submissions(id, submitted_by, face_encoding,\
              location, mobile, image, status) values('{sub_id}', '{name}', '{face_encoding}',\
              '{location}', '{mobile}', '{image}', 'NR')"
    with PostgresConnection() as conn:
        cursor = conn.cursor()
        cursor.execute(query)
def submit_case(user_info):
    submitted_by = user_info.submitted_by
    name = user_info.name
    age = user_info.age
    mobile = user_info.mobile
    father_name = user_info.father_name
    face_encoding = user_info.face_encoding
    image = user_info.image
    case_id = user_info.case_id
    query = f"insert into submitted_cases(submitted_by, name, father_name, age,\
             mobile, face_encoding, status, image, case_id) values('{submitted_by}', '{name}', '{father_name}',\
             '{age}', '{mobile}', '{face_encoding}', 'NF', '{image}', '{case_id}')"
    with PostgresConnection() as conn:
        cursor = conn.cursor()
        cursor.execute(query)
Ejemplo n.º 8
0
 def save(self):
     conn = PostgresConnection()
     conn.update_game_data(self.new_rate)
     pass
Ejemplo n.º 9
0
                self.units[i].steps_to_create = unit.steps_to_create
                self.seller[i] = player
                self.time_exist[i] = 5
                break
        player.units.remove(unit)

    # отправляет деньги владельцу юнита
    # обнуляет все данные о юните, расположенном на i-той позиции
    def send_money(self, cost, position):
        self.seller[position].value[self.seller[position].id] += round(
            cost * game.new_rate[self.seller[position].id])
        self.seller[position] = None

    # проверка на уже залежавшиеся юниты
    # если таковые имеются, то они удаляются
    def check(self):
        for i in range(len(self.units)):
            if self.time_exist[i] <= 0:
                self.time_exist[i] = 1
                self.units[i] = None
                self.seller[i] = None


pg_conn = PostgresConnection()
mongo_conn = MongoConnection()

game = Game()

server = TcpServer()
server.run_()
def change_found_status(case_id: str):
    query = f"update submitted_cases set status='F' where case_id={case_id}"
    with PostgresConnection() as conn:
        cursor = conn.cursor()
        cursor.execute(query)
    return {"status": "success"}
def get_confirmed_cases(submitted_by: str):
    query = f"select * from submitted_cases where submitted_by='{submitted_by}' and status='F'"
    with PostgresConnection() as conn:
        cursor = conn.cursor()
        cursor.execute(query)
        return cursor.fetchall()
def user_details(case_id: str):
    query = f"select location, submitted_at, image from user_submissions where id={case_id}"
    with PostgresConnection() as conn:
        cursor = conn.cursor()
        cursor.execute(query)
        return cursor.fetchall()
def case_details(case_id: str):
    query = f"select name, father_name, image, mobile, age from submitted_cases where case_id={case_id}"
    with PostgresConnection() as conn:
        cursor = conn.cursor()
        cursor.execute(query)
        return cursor.fetchall()
def get_usr_submission():
    query = f"select id, face_encoding from user_submissions"
    with PostgresConnection() as conn:
        cursor = conn.cursor()
        cursor.execute(query)
        return cursor.fetchall()