Ejemplo n.º 1
0
    def remove_action(self):
        try:
            if len(self.ui.New_Item_List.selectedItems()) != 0:
                row = self.ui.New_Item_List.currentRow()
                text = self.ui.New_Item_List.item(row, 0).text()
                if text not in self.RemovedItems:
                    self.RemovedItems.append(text)
                y = [x for x in self.eventEntry if text in x]
                k = [x for x in self.markedList if text in x]
                if len(y) != 0:
                    z = self.eventEntry.index(y[0])
                    del self.eventEntry[z]
                if len(k) != 0:
                    p = self.markedList.index(k[0])
                    del self.markedList[p]

                self.ui.New_Item_List.removeRow(row)
                ETEK_log.info('Remove action pressed.')
            else:
                self.qm.information(self, 'Selection Required',
                                    "Please select an asset to remove first")
                return
        except:
            self.qm.critical(
                self, 'Unexpected error: Exception thrown',
                'An unexpected error has occured, please try again or contact tech support for help'
            )
            ETEK_log.error('Error occurred in function: remove_action')
Ejemplo n.º 2
0
    def clear_lists(self):
        self.ui.New_Item_List.setRowCount(0)
        self.ui.Existing_Item_list.setRowCount(0)
        self.eventEntry.clear()
        self.ui.Employee_ID_Input.setReadOnly(False)
        self.ui.Employee_ID_Input.clear()
        self.ui.Asset_ID_Input.clear()
        self.RemovedItems.clear()
        self.ui.Check_Out_Box.setEnabled(True)
        self.ui.Check_In_Box.setEnabled(True)
        self.ui.Check_In_Box.setAutoExclusive(False)
        self.ui.Check_Out_Box.setAutoExclusive(False)
        self.ui.Check_Out_Box.setChecked(False)
        self.ui.Check_In_Box.setChecked(False)
        self.ui.Check_In_Box.setAutoExclusive(True)
        self.ui.Check_Out_Box.setAutoExclusive(True)
        self.ui.Mark_Button.setEnabled(False)
        self.ui.Admin_Button.setEnabled(False)
        self.markedList.clear()
        self.ui.Employee_ID_Enter.setEnabled(True)
        self.ui.Name_Label.clear()
        self.alreadyCh.clear()
        self.ui.Remove_Button.setEnabled(False)
        self.error_count = 0
        self.ui.Employee_ID_Enter.setStyleSheet(
            "color : rgba(255, 255, 255,255)")
        ETEK_log.info('Clear lists.')

        self.admin.close()
        return
Ejemplo n.º 3
0
 def Employee_enter(self):
     try:
         self.ui.Employee_ID_Enter.setEnabled(False)
         if Permission_Check(self.ui.Employee_ID_Input.text()):
             self.ui.Admin_Button.setEnabled(True)
             self.ui.Admin_Button.clicked.connect(self.adminButtonClicked)
         if Employee_ID_Check(self.ui.Employee_ID_Input.text()):
             self.current_items(self.ui.Employee_ID_Input.text())
             self.ui.Asset_ID_Input.setEnabled(True)
             self.ui.Asset_ID_Input.setFocus()
             self.ui.Employee_ID_Input.setReadOnly(True)
             employeeName = getEmployeeName(
                 self.ui.Employee_ID_Input.text())
             self.ui.Name_Label.setText(str(employeeName))
             self.ui.Employee_ID_Enter.setStyleSheet(
                 "color : rgba(0, 0, 0, 50%)")
             ETEK_log.info('User:(' + self.ui.Employee_ID_Input.text() +
                           ') Logged in successfully.')
         else:
             self.qm.information(
                 self, 'Input Required',
                 "Enter a valid Employee ID before continuing")
             self.ui.Employee_ID_Input.clear()
             return
     except:
         self.qm.critical(
             self, 'Unexpected error: Exception thrown',
             'An unexpected error has occured, please try again or contact tech support for help'
         )
         ETEK_log.error('Error occurred in function: Employee_enter')
Ejemplo n.º 4
0
 def adminButtonClicked(self):
     try:
         print('clicked admin')
         self.admin.openAdmin(server, database,
                              self.ui.Employee_ID_Input.text())
         ETEK_log.info('Clicked admin window button')
     except:
         self.qm.critical(
             self, 'Unexpected error: Exception thrown',
             'An unexpected error has occured, please try again or contact tech support for help'
         )
         ETEK_log.error('Error occurred in function: adminButtonClicked')
Ejemplo n.º 5
0
 def cancel_button_clicked(self):
     try:
         self.ui.Employee_ID_Input.setReadOnly(False)
         self.ui.Employee_ID_Input.clear()
         self.ui.Asset_ID_Input.clear()
         self.ui.Asset_ID_Input.setEnabled(False)
         self.clear_lists()
         ETEK_log.info('Cancel Button Clicked.')
     except:
         self.qm.critical(
             self, 'Unexpected error: Exception thrown',
             'An unexpected error has occured, please try again or contact tech support for help'
         )
         ETEK_log.error('Error occurred in function: cancel_button_clicked')
Ejemplo n.º 6
0
 def help_button(self):
     try:
         self.qm.setFixedSize(3000, 5000)
         self.qm.information(
             self, 'Help',
             '''Welcome to E-TEK! \n\nTo use the application:\n1. Enter Employee ID\n2. Select the action to perform\n3. Confirm items in table\n   (3a) Press 'Mark Broken' to mark item as broken\n   (3b) Press 'Remove Item' to remove item from table\n4. Press 'Done' to complete transaction\n   (4a) Press 'Cancel' to clear the form'''
         )
         ETEK_log.info('Help Button pressed.')
     except:
         self.qm.critical(
             self, 'Unexpected error: Exception thrown',
             'An unexpected error has occured, please try again or contact tech support for help'
         )
         ETEK_log.error('Error occurred in function: help_button')
Ejemplo n.º 7
0
 def handleLogin(self):
     # password is hashed with one way hash function
     password = self.ui.lineEdit.text().encode('utf-8')
     hashpass = hashlib.sha256(password).hexdigest()
     # read the correct hashed password from config file
     config = ConfigParser()
     config.read('config.ini')
     storedPass = config.get('password', 'pass')
     if hashpass == storedPass:  # compare hashed password
         self.accept()
     else:
         QtWidgets.QMessageBox.warning(self, 'Error', 'Bad password')
         ETEK_log.info('Incorrect password entered. Application not run.')
         self.rejected()
Ejemplo n.º 8
0
 def move_action(self):
     try:
         if self.ui.Check_In_Box.isChecked():
             if len(self.ui.Existing_Item_list.selectedItems()) != 0:
                 while len(self.ui.Existing_Item_list.selectedItems()) > 0:
                     targetRow = self.ui.New_Item_List.rowCount()
                     self.ui.New_Item_List.insertRow(targetRow)
                     for column in range(
                             self.ui.Existing_Item_list.columnCount()):
                         row = self.ui.Existing_Item_list.currentRow()
                         item = self.ui.Existing_Item_list.takeItem(
                             row, column)
                         self.eventEntry.append([
                             self.ui.Employee_ID_Input.text(),
                             item.text()
                         ])
                         if item:
                             self.ui.New_Item_List.setItem(
                                 targetRow, column, item)
                         self.ui.Existing_Item_list.removeRow(row)
                 self.ui.Mark_Button.setEnabled(True)
                 ETEK_log.info('Move items arrow pressed.')
             else:
                 self.qm.information(
                     self, 'Selection Required',
                     "Please select an asset to move first")
                 return
         else:
             self.qm.information(
                 self, 'Selection Required',
                 "This button only works when Check-In action selected")
     except:
         self.qm.critical(
             self, 'Unexpected error: Exception thrown',
             'An unexpected error has occured, please try again or contact tech support for help'
         )
         ETEK_log.error('Error occurred in function: move_action')
Ejemplo n.º 9
0
 def mark_assets(self):
     try:
         if len(self.ui.New_Item_List.selectedItems()) != 0:
             row = self.ui.New_Item_List.currentRow()
             text = self.ui.New_Item_List.item(row, 0).text()
             if text not in self.markedList:
                 self.markedList.append(text)
                 y = [x for x in self.eventEntry if text in x]
                 z = self.eventEntry.index(y[0])
                 del self.eventEntry[z]
                 self.ui.New_Item_List.item(row, 0).setBackground(
                     QtGui.QColor(255, 0, 0))
                 self.ui.New_Item_List.clearSelection()
         else:
             self.qm.information(
                 self, 'Selection Required',
                 "Please select an asset to mark as broken first")
             return
     except:
         self.qm.critical(
             self, 'Unexpected error: Exception thrown',
             'An unexpected error has occured, please try again or contact tech support for help'
         )
         ETEK_log.error('Error occurred in function: mark_assets')
Ejemplo n.º 10
0
 def done_button_clicked(self):
     try:
         if self.ui.Check_In_Box.isChecked():
             print('Check IN action')
             self.check_in_action()
             ETEK_log.info('Check IN action pressed')
         elif self.ui.Check_Out_Box.isChecked():
             print('Check OUT action')
             self.check_out_action()
             ETEK_log.info('Check OUT action pressed')
         else:
             self.confirmation_msg([])
         self.clear_lists()
     except:
         self.qm.critical(
             self, 'Unexpected error: Exception thrown',
             'An unexpected error has occured, please try again or contact tech support for help'
         )
         ETEK_log.error('Error occurred in function: done_button_clicked')
Ejemplo n.º 11
0
    def asset_enter_action(self):
        try:
            Asset = self.ui.Asset_ID_Input.text()
            if re.findall(r"\Ae", Asset):
                Asset = str.capitalize(Asset)
            #if not already in the list to check out, continue:
            if [self.ui.Employee_ID_Input.text(), Asset] in self.eventEntry:
                self.qm.information(self, 'Already Selected',
                                    "Asset " + Asset + " is already selected ")
            else:
                if self.ui.Check_In_Box.isChecked(
                ) or self.ui.Check_Out_Box.isChecked():
                    if Asset_Check(Asset):
                        self.ui.Check_Out_Box.setEnabled(False)
                        self.ui.Check_In_Box.setEnabled(False)
                        flag = self.assetState(Asset)
                        if flag == "gtg":
                            if not any(Asset in sublist
                                       for sublist in self.eventEntry):
                                self.insert_into_table(1, Asset)
                                # append the entries into a list
                                self.eventEntry.append(
                                    [self.ui.Employee_ID_Input.text(), Asset])
                                self.ui.Asset_ID_Input.clear()
                        #decided to not check out an already checked out item
                        elif flag == "discard":
                            self.ui.Asset_ID_Input.clear()
                        #broken
                        elif flag == "broken":
                            self.qm.critical(
                                self, 'Critical Issue',
                                "Asset " + Asset + " is broken. Do NOT use.")
                            self.ui.Asset_ID_Input.clear()
                        elif flag == "brokenCheckIn":
                            if not any(Asset in sublist
                                       for sublist in self.eventEntry):
                                self.insert_into_table(1, Asset)
                                # append the entries into a list
                                self.markedList.append(Asset)
                                row = self.ui.New_Item_List.rowCount() - 1
                                self.ui.New_Item_List.item(
                                    row,
                                    0).setBackground(QtGui.QColor(255, 0, 0))
                                self.ui.Asset_ID_Input.clear()
                        #if 'in repair', do not allow check out
                        elif flag == "InRepair":
                            self.qm.critical(
                                self, 'Critical Issue', "Asset " + Asset +
                                " is in Repair. Do NOT use.")
                            self.ui.Asset_ID_Input.clear()
                        #if 'in repair' and someone is returning
                        elif flag == "RepairCheckIn":
                            self.qm.critical(
                                self, 'Critical Issue',
                                "Please contact the admin, this Asset " +
                                Asset + " is in Repair. Do NOT use.")
                            self.ui.Asset_ID_Input.clear()
                        #if 'retired' and someone is returning
                        elif flag == "RetiredCheckIn":
                            self.qm.critical(
                                self, 'Critical Issue',
                                "Please contact the admin, this Asset " +
                                Asset + " is retired from field. Do NOT use.")
                            self.ui.Asset_ID_Input.clear()
                        #if 'retired, do not allow check out
                        elif flag == "Retired":
                            self.qm.critical(
                                self, 'Critical Issue',
                                "Asset " + Asset + " is Retired. Do NOT use.")
                            self.ui.Asset_ID_Input.clear()

                    else:
                        self.qm.warning(
                            self, 'Check Asset', "Asset " + Asset +
                            " is not configured for use or does not exist \n\n Please Check your Asset ID and try again or Enter a valid Asset ID"
                        )
                        self.ui.Asset_ID_Input.clear()
                else:
                    self.qm.information(
                        self, 'Input Required',
                        "Please select an action to perform (Check-In or Check-Out"
                    )
                return
        except:
            self.qm.critical(
                self, 'Unexpected error: Exception thrown',
                'An unexpected error has occured, please try again or contact tech support for help'
            )
            ETEK_log.error('Error occurred in function: asset_enter_action')
Ejemplo n.º 12
0
            print(state)
            if state[0] == self.ui.Employee_ID_Input.text():
                self.insert_into_table(2, assets[0])
        return

if __name__ == "__main__":

    # print(hashlib.sha256(b"foo").hexdigest())
    app = QtWidgets.QApplication(sys.argv)
    login = passwordWindow()
    # RFID init
    if login.exec_() == QtWidgets.QDialog.Accepted:
        window = mainWindow()
        work = WorkerThread()
        window.show()
        ETEK_log.info('Application login successful.')
        logging.getLogger().setLevel(logging.INFO)
        factory = llrp.LLRPClientFactory(antennas=[1],
                                         start_inventory=True,
                                         session=0,
                                         duration=0.8)
        factory.addTagReportCallback(work.cb)

        #connect to RFID Reader - change this if you change beyond default settings of RFID Reader
        reactor.connectTCP('169.254.10.1', llrp.LLRP_PORT, factory)

        #load information from config file
        server = window.server
        database = window.database

        # define a connection string