def markAttendance(prn,
                   classroom,
                   course_name,
                   date_time=datetime.now().strftime("%Y-%m-%d %H:%M:%S")):
    connection = establishConnection()
    cursor = connection.cursor()
    cursor.execute(
        """SELECT course_code FROM course WHERE course_name = '%s'""" %
        (course_name))
    r = cursor.fetchone()
    if not r:
        print(
            f'Error: Course {course_name} does not exist in the database... Check spelling'
        )
        return 'Failed: Unsuccessful in marking attendnace of student...'
    else:
        course_code = r[0]

    cursor.execute("""INSERT INTO attends VALUES(%s, '%s', '%s', %s) ; """ %
                   (prn, date_time, classroom, course_code))

    cursor.close()
    connection.commit()
    connection.close()
    return f"Attendance of student with PRN {prn} for course {course_name} dated on {date_time} in venue {classroom} is succesfully recorded!"
def recordLectureConductedByFaculty(lecture, faculty_name, course_name):
    connection = establishConnection()
    cursor = connection.cursor()
    cursor.execute(
        """ SELECT emp_id FROM faculty WHERE faculty_name = '%s' """ %
        (faculty_name))
    r = cursor.fetchone()
    if not r:
        return 'Error: Faculty name {faculty_name} not found in the database'
    else:
        emp_id = r[0]

    cursor.execute(
        """SELECT course_code FROM course WHERE course_name = '%s' """ %
        (course_name))
    r = cursor.fetchone()
    if not r:
        return 'Error: Course name {course_name} not found in the database'
    else:
        course_code = r[0]

    cursor.execute("""INSERT INTO conducts VALUES('%s', '%s', %s, %s)""" %
                   (lecture[1], lecture[0], emp_id, course_code))
    cursor.close()
    connection.commit()
    connection.close()
    return f"Lecture conducted by faculty {faculty_name} dated {lecture[1]} in classroom {lecture[0]} is recorded in the database."
def recordLecture(classroom,
                  date_time=datetime.now().strftime("%Y-%m-%d %H:%M:%S")):
    connection = establishConnection()
    cursor = connection.cursor()
    cursor.execute("INSERT INTO lecture VALUES('%s', '%s')" %
                   (date_time, classroom))
    lecture = (classroom, date_time)
    cursor.close()
    connection.commit()
    connection.close()
    return lecture
Ejemplo n.º 4
0
                    lh.landmark2id["PINKY_TIP"]].x
                isRight = index_x > pinky_x

                # mediapipe comes with an build in handiness detection, that can be used instead of the custom check
                #hand_label = results.multi_handedness[hand_idx].classification[0].label
                #isRight = True if hand_label == "Right" else False

                handdata.Hand = hd.HandData.HandType.RightHand if isRight else hd.HandData.HandType.LeftHand

                for hand_idx in range(0, 21):
                    landmark = handdata.Landmarks.add()
                    landmark.X = hand_landmarks.landmark[hand_idx].x
                    landmark.Y = hand_landmarks.landmark[hand_idx].y
                    landmark.Z = hand_landmarks.landmark[hand_idx].z
                    landmark.Type = hand_idx

                mp_drawing.draw_landmarks(image, hand_landmarks,
                                          mp_hands.HAND_CONNECTIONS)

            connection.send(message.SerializeToString())

        if SHOW_WINDOW:
            cv2.imshow('MediaPipe Hands', image)
            if cv2.waitKey(5) & 0xFF == 27:
                break

finally:
    hands.close()
    cap.release()
    connection.close()
Ejemplo n.º 5
0
 def close(self):
     self.keep_running = False
     for connection in self.connections:
         connection.close()
     self.sock.close()
     while not self.closed: pass
Ejemplo n.º 6
0
 def __del__(self):
     connection.close()
Ejemplo n.º 7
0
Archivo: main.py Proyecto: misod/kand
        current_time = time.time()

        if(current_time - keepalive_time) > 900:
            logging.add_log(0, "A keepalive was sent")
            connection.keepalive(active_socket_file)
            keepalive_time = current_time

        packet_str = connection.get_message(active_socket_file)

        if -2 is helpers.main_func(libfap, glider_id_array, towingplane_id_array, active_database_connection, packet_str):
            break



    except KeyboardInterrupt:
        logging.add_log(0, "KeyboardInterrupt detected -> Quiting")
        break
# <----- while break ------>


# Close libfap.py to avoid memory leak
libfap.fap_cleanup()
connection.close(active_socket)
database.logout(active_database_connection)

now = time.strftime("%c")
logging.add_log(0, ("------------------- Stop  ------- %s --------------------------------" % now) )
logging.add_log(1, ("------------------- Stop  ------- %s --------------------------------" % now) )
logging.add_log(2, ("------------------- Stop  ------- %s --------------------------------" % now) )
logging.log_packet ("------------------- Stop  ------- %s --------------------------------" % now)
Ejemplo n.º 8
0
def disconnect(connection):
    if (connection.is_connected()):
        connection.close()
        print("MySQL connection is closed")
    else:
        print("Not connected to the database")
Ejemplo n.º 9
0
def close_connection(connection):
    connection.close()
 def close(self, reason):
     if not self.persist:
         self.queue.clear()
     connection.close(self.server)