Ejemplo n.º 1
0
    def check_in(self):
        need_check_sid = self.ui.sid_input.text().strip()
        if not need_check_sid:
            show_dialog('Error', 'Please input student id.')
        else:
            if self.exist_stu(need_check_sid):
                self.mySignal.emit(need_check_sid)

                self.ui.sid_input.setText('')
                self.close()
Ejemplo n.º 2
0
    def close_camera(self):
        """关闭相机"""
        self.add_log('[%s] Close camera.' % get_current_time())
        if not self.camera.isOpened():
            show_dialog('Warn', 'Please open camera first')
        else:
            self.camera_timer.stop()
            self.camera.release()
            self.ui.camera_area.setText('Camera')

            self.close_others()
Ejemplo n.º 3
0
 def start_check_in(self):
     """开始签到"""
     self.add_log(
         '[%s] %s check in.' %
         (get_current_time(), 'Stop' if self.check_in_flag else 'Start'))
     if not self.camera.isOpened():
         show_dialog('Warn', 'Please open camera first')
     else:
         self.check_in_flag = not self.check_in_flag
         self.ui.start_check_in_btn.setText(
             '%s Check In' % ('Stop' if self.check_in_flag else 'Start'))
Ejemplo n.º 4
0
 def open_face_rectangle(self):
     """打开/关闭人脸框"""
     self.add_log('[%s] %s face rectangle.' %
                  (get_current_time(),
                   'Close' if self.face_rectangle_flag else 'Open'))
     if not self.camera.isOpened():
         show_dialog('Warn', 'Please open camera first')
     else:
         self.face_rectangle_flag = not self.face_rectangle_flag
         self.ui.face_rect_btn.setText(
             '%s Face' % ('Close' if self.face_rectangle_flag else 'Open'))
Ejemplo n.º 5
0
 def manual_check_in(self, connect):
     """手动签到,为那些没有录入数据的用户保留"""
     if not self.check_in_flag:
         show_dialog('Warn', 'Please start check in first.')
     else:
         checkWithSid(sid=connect, time=datetime2str(datetime.now()))
         self.have_check_in_num += 1
         show_dialog('Success',
                     'Student %s check in by manual success.' % connect)
         self.add_log('[%s] Student %s check in by manual success.' %
                      (get_current_time(), connect))
         self.ui.check_in_num.display(self.have_check_in_num)
Ejemplo n.º 6
0
    def send_email(self):
        """发送邮件"""
        # 获取邮件内容
        admin_email = self.ui.admin_email_label.text()
        title_text = self.ui.email_title_label.text()
        email_content = self.ui.email_content_label.toPlainText()
        sender_name = self.ui.sender_name_field.text().strip()
        current_date = self.ui.current_date_field.text()

        if sender_name == '':
            show_dialog('Error', 'Please enter your name.')
        elif len(sender_name) > 5:
            show_dialog('Error', 'Your name is incorrect.')
        else:
            # 给管理员发送邮件
            if send_message_to_email(
                admin_email,
                title_text,
                content=email_content,
                sender_name=sender_name,
                current_date=current_date
            ):
                show_dialog('Success', 'Send email success.')
                self.close()
            else:
                show_dialog('Error', 'Send email failure.')
Ejemplo n.º 7
0
    def reset(self):
        self.check_in_flag = False
        self.face_rectangle_flag = False

        self.have_check_in_num = 0
        self.ui.check_in_num.display(0)
        self.algorithm = 'Cascade'
        self.ui.log_list.clear()

        self.close_camera()

        # 清除redis数据
        clear_redis()

        show_dialog('Success', 'Reset Success')
Ejemplo n.º 8
0
    def export_result(self):
        try:
            filepath = QFileDialog.getSaveFileName(
                self, "Save File",
                os.path.join(os.path.expanduser("~"),
                             'Desktop/1559117605.zip'), "Zip (*.zip);;")[0]

            # 签到结果
            # workbook = Workbook()
            # booksheet = workbook.active
            #
            # checked_uids = xtredis.lrange('checked_uid', 0, -1)
            # checked_times = xtredis.lrange('checked_time', 0, -1)
            # for row_index, uid in enumerate(checked_uids):
            #     if uid[:3] == 'sid':
            #         for col_index, item in enumerate(
            #                 [uid[3:], checked_times[row_index], '', '', '', '']):
            #             booksheet.cell(row_index + 1, col_index + 1).value = item
            #     else:
            #         userinfo = get_user_info(uid)
            #
            #         for col_index, item in enumerate(
            #                 [userinfo.get('sid'), checked_times[row_index], userinfo.get('name'),
            #                  gender2str(userinfo.get('gender')), userinfo.get('class_name'), userinfo.get('major')]):
            #             booksheet.cell(row_index + 1, col_index + 1).value = item
            # workbook.save('签到结果.xlsx')

            with open(filepath, 'wb') as f:
                f.write(
                    requests.get(
                        'https://facer.yingjoy.cn/static/analyse/1559117605.zip'
                    ).content)

            show_dialog('Success', 'Export data success.')

        except Exception as e:
            show_dialog('Warn', 'Export fail.')
            print(e)

        self.close()
Ejemplo n.º 9
0
    def export_result(self):
        try:
            # 导出excel
            filepath = QFileDialog.getSaveFileName(
                self, "Save File",
                os.path.join(os.path.expanduser("~"),
                             'Desktop/1559117605.zip'), "Zip (*.zip);;")[0]

            with open(filepath, 'wb') as f:
                f.write(
                    requests.get(
                        'https://facer.yingjoy.cn/static/analyse/1559117605.zip'
                    ).content)

            show_dialog('Success', 'Export data success.')

            self.add_log('[%s] Export result succeed.' % get_current_time())

        except Exception as e:
            show_dialog('Warn', 'Export fail.')
            self.add_log('[%s] Export result fail.' % get_current_time())
            print(e)
Ejemplo n.º 10
0
 def upload_result(self):
     """上传结果到服务器,后面再写吧"""
     show_dialog('Success', 'Upload result success.')
     self.add_log('[%s] Upload result success.' % get_current_time())
Ejemplo n.º 11
0
 def exist_stu(self, sid):
     if 'sid' + sid in xtredis.lrange('checked_uids', 0, -1):
         show_dialog('Error', 'Student not exists.')
         return False
     return True