def main_function(): if os.path.isfile(gl.SCRIPT_ROOT + 'database.ini'): if sqlconns.readsql_connection_timeware_main_6() == 0: f.error_logging(APPNAME, "Error reading database.ini file.", "error_log", "") return -1 elif sqlconns.readsql_connection_timeware_main_6() == 1: test_comms = sqlconns.testsql(gl.SERVER, gl.SQL_LOGIN, gl.PASSWORD, gl.DATABASE) if test_comms == 0: f.error_logging(APPNAME, "Error connecting to SQL server.", "error_log", "") return -1 else: test_pause = inbio_started() if test_pause == -1: f.error_logging( APPNAME, "Main Loop aborted due to error (check sql connection).", "error_log", "") return -1 if test_pause == True: ret = inbio_communicate() if ret == -1: f.error_logging( APPNAME, "Main Loop aborted due to error (check sql connection).", "error_log", "") return -1 else: return else: f.error_logging(APPNAME, "Error reading database.ini file.", "error_log", "") return -1
def set_env(): global ACCESS_TERMINAL global ATTENDANCE_TERMINAL f.error_logging(APPNAME,"error_log","2","") if os.path.isfile(gl.SCRIPT_ROOT + 'database.ini'): if sqlconns.readsql_connection_timeware_main_6() == 0: f.error_logging(APPNAME, "Error reading database.ini file.", "error_log","") return False elif sqlconns.readsql_connection_timeware_main_6() == 1: test_comms = sqlconns.testsql(gl.SERVER, gl.SQL_LOGIN, gl.PASSWORD, gl.DATABASE) if test_comms == 0: f.error_logging(APPNAME, "Error connecting to SQL server.", "error_log","") else: if os.path.isfile(gl.GENERAL_INI): fob=open(gl.GENERAL_INI, "r") listme = fob.readlines() fob.close() else: f.error_logging(APPNAME, "Error reading general.ini file.", "error_log","") return False for index in range(len(listme)): if 'server_port' in listme[index]: gl.server_port = int(str.split(listme[index],'=')[1]) if 'face_to_personnel' in listme[index]: if 'true' in str.split(listme[index],'=')[1]: gl.face_to_personnel = True if "access_terminal" in listme[index]: ACCESS_TERMINAL = int(listme[index].split("=")[1]) if "attendance_terminal" in listme[index]: ATTENDANCE_TERMINAL = int(listme[index].split("=")[1]) return True else: f.error_logging(APPNAME, "Error reading database.ini file.", "error_log","") return False
def leftclick(event): if entry_1.get() == "": tkm.showinfo('User Alert!!','Server is empty...') return if entry_2.get() == "": tkm.showinfo('User Alert!!','SQL login is empty...') return if entry_3.get() == "": tkm.showinfo('User Alert!!','Password is empty...') return if entry_4.get() == "": tkm.tkinter.messagebox.showinfo('User Alert!!','Database is empty...') return gl.SERVER = entry_1.get() gl.SQL_LOGIN =entry_2.get() gl.PASSWORD = entry_3.get() gl.DATABASE = entry_4.get() sqlConnect = sqlconns.testsql(gl.SERVER,gl.SQL_LOGIN,gl.PASSWORD,gl.DATABASE) if sqlConnect == 0: tkm.showinfo('User Information','Cannot connect to Sql database or login denied.') return if sqlConnect == 1: answer = tkm.askquestion('User Information','Database connection successful, do you want to save to connection file.') if answer == 'no': return if answer == 'yes': temp1 = sqlconns.writesql_connection(gl.SERVER,gl.SQL_LOGIN,gl.PASSWORD,gl.DATABASE) if temp1 == 1: tkm.showinfo('User Information','Sql Connection file successfully changed.') root.destroy() if temp1 == 0: tkm.showinfo('User Alert!!!','Error Creating SQL Connection.')
def set_env(): global ATTENDANCE_TERMINALS global ACCESS_TERMINALS path = str.replace(gl.SCRIPT_ROOT, 'iface analyser.exe', '') if os.path.isfile(path + 'database.ini'): if sqlconns.readsql_connection_timeware_main_6() == 0: showdialog('Error connecting to database!!!! ' + path) return False elif sqlconns.readsql_connection_timeware_main_6() == 1: test_comms = sqlconns.testsql(gl.SERVER, gl.SQL_LOGIN, gl.PASSWORD, gl.DATABASE) if test_comms == 0: showdialog('Error connecting to database!!!! ' + path) else: if os.path.isfile(gl.GENERAL_INI): fob = open(gl.GENERAL_INI, "r") listme = fob.readlines() fob.close() else: showdialog('Error reading general.ini file!!!!') return False try: for index in range(len(listme)): if "'" in listme[index]: continue if "access_terminal" in listme[index]: ACCESS_TERMINALS = int(listme[index].split("=")[1]) if "attendance_terminal" in listme[index]: ATTENDANCE_TERMINALS = int( listme[index].split("=")[1]) except Exception as e: return False return True else: showdialog('Error connecting to database!!!! ' + path) return False
def set_env(): global EMPLOYEE_SQL global SQL_TOP global IN_RED global IN_GREEN global IN_BLUE global OUT_RED global OUT_GREEN global OUT_BLUE path = str.replace(gl.SCRIPT_ROOT,'adp.exe','') if os.path.isfile(path + 'database.ini'): if sqlconns.readsql_connection_timeware_main_6() == 0: showdialog('Error connecting to database!!!! ' + path) return False elif sqlconns.readsql_connection_timeware_main_6() == 1: test_comms = sqlconns.testsql(gl.SERVER, gl.SQL_LOGIN, gl.PASSWORD, gl.DATABASE) if test_comms == 0: showdialog('Error connecting to database!!!! ' + path) else: if os.path.isfile(gl.ADP_INI): fob=open(gl.ADP_INI, "r") listme = fob.readlines() fob.close() else: showdialog('Error reading adp.ini file!!!!') return False try: for index in range(len(listme)): if "'" in listme[index]: continue if 'employee_sql' in listme[index]: EMPLOYEE_SQL = str.split(listme[index],'=')[1] if 'top_sql' in listme[index]: SQL_TOP = str.split(listme[index],'=')[1] if 'IN_RED' in listme[index]: IN_RED = int(str.split(listme[index],'=')[1]) if 'IN_GREEN' in listme[index]: IN_GREEN = int(str.split(listme[index], '=')[1]) if 'IN_BLUE' in listme[index]: IN_BLUE = int(str.split(listme[index], '=')[1]) if 'OUT_RED' in listme[index]: OUT_RED = int(str.split(listme[index], '=')[1]) if 'OUT_GREEN' in listme[index]: OUT_GREEN = int(str.split(listme[index], '=')[1]) if 'OUT_BLUE' in listme[index]: OUT_BLUE = int(str.split(listme[index], '=')[1]) except Exception as e: return False return True else: showdialog('Error connecting to database!!!! ' + path) return False
def set_env(): global ATTENDANCE_TERMINALS global ACCESS_TERMINALS maindb = 'timeware_main_6' userdb = 'timeware_user_6' path = str.replace(gl.SCRIPT_ROOT, 'iface analyser.exe', '') f.error_logging("iface analyser", path, "error_log", "") if os.path.isfile(gl.GENERAL_INI): fob = open(gl.GENERAL_INI, "r") listme = fob.readlines() fob.close() else: showdialog('Error reading general.ini file!!!!') return False try: for index in range(len(listme)): if "'" in listme[index]: continue if "access_terminal" in listme[index]: ACCESS_TERMINALS = int(listme[index].split("=")[1]) if "attendance_terminal" in listme[index]: ATTENDANCE_TERMINALS = int(listme[index].split("=")[1]) if "dbmain" in listme[index]: maindb = str.split(listme[index], '=')[1] maindb = maindb.replace("\r", "") maindb = maindb.replace("\n", "") if "dbuser" in listme[index]: userdb = str.split(listme[index], '=')[1] userdb = userdb.replace("\r", "") userdb = userdb.replace("\n", "") except Exception as e: showdialog(e) return False if os.path.isfile(gl.DATABASE_INI): if sqlconns.readsql_connection_timeware_main_6(maindb, userdb) == 0: showdialog('Error on reading database.ini!!!! ' + path) return False elif sqlconns.readsql_connection_timeware_main_6(maindb, userdb) == 1: print(gl.DATABASE) test_comms = sqlconns.testsql(gl.SERVER, gl.SQL_LOGIN, gl.PASSWORD, gl.DATABASE) if test_comms == 0: showdialog('Error connecting to database!!!! ' + path) return False else: showdialog('Error Finding database.ini ' + path) return False return True
def database_connections(): if os.path.isfile(gl.SCRIPT_ROOT + 'database.ini'): if sqlconns.readsql_connection_timeware_main_6() == 0: showdialog() return -1 elif sqlconns.readsql_connection_timeware_main_6() == 1: test_comms = sqlconns.testsql(gl.SERVER, gl.SQL_LOGIN, gl.PASSWORD, gl.DATABASE) if test_comms == 0: showdialog('Error connecting to database!!!!') return -1 else: return else: showdialog() return -1
def set_env(): if os.path.isfile(gl.SCRIPT_ROOT + 'database.ini'): if sqlconns.readsql_connection_timeware_main_6() == 0: f.error_logging(APPNAME, "Error reading database.ini file.", "error_log", "") return False elif sqlconns.readsql_connection_timeware_main_6() == 1: test_comms = sqlconns.testsql(gl.SERVER, gl.SQL_LOGIN, gl.PASSWORD, gl.DATABASE) if test_comms == 0: f.error_logging(APPNAME, "Error connecting to SQL server.", "error_log", "") return False return True else: f.error_logging(APPNAME, "Error reading database.ini file.", "error_log", "") return False
def set_env(): global VERSION global APPSERVER global APPNAME if os.path.isfile('database.ini'): if sqlconns.readsql_connection_timeware_main_6() == 0: print("no ini file") return elif sqlconns.readsql_connection_timeware_main_6() == 1: test_comms = sqlconns.testsql(gl.SERVER, gl.SQL_LOGIN, gl.PASSWORD, gl.DATABASE) if test_comms == 0: print("no connection") return else: APPSERVER = gl.SERVER else: return
def set_env(): global VERSION global APPSERVER global APPNAME global IMAGE_TYPE global FILENAME_FORMAT global EXPORT_PATH global FILENAME_FORMAT if os.path.isfile('export.ini'): fob = open(EXPORT_INI, "r") listme = fob.readlines() fob.close() else: print('export.ini not found') return False for index in range(len(listme)): if "'" in listme[index]: continue if 'image_type' in listme[index]: IMAGE_TYPE = str.split(listme[index], '=')[1] IMAGE_TYPE = str.replace(IMAGE_TYPE, '\n', '') if 'export_path' in listme[index]: EXPORT_PATH = str.split(listme[index], '=')[1] EXPORT_PATH = str.replace(EXPORT_PATH, """\\""", """/""") EXPORT_PATH = str.replace(EXPORT_PATH, '\n', '') if 'filename_format' in listme[index]: FILENAME_FORMAT = str.split(listme[index], '=')[1] FILENAME_FORMAT = str.replace(FILENAME_FORMAT, '\n', '') if os.path.isfile('database.ini'): if sqlconns.readsql_connection_timeware_main_6() == 0: print("no sqlconnection.ini file") return False elif sqlconns.readsql_connection_timeware_main_6() == 1: test_comms = sqlconns.testsql(gl.SERVER, gl.SQL_LOGIN, gl.PASSWORD, gl.DATABASE) if test_comms == 0: print("no connection") return False else: APPSERVER = gl.SERVER else: return False return True
def set_env(): if os.path.isfile(gl.SCRIPT_ROOT + 'database.ini'): if sqlconns.readsql_connection_timeware_main_6() == 0: f.error_logging(APPNAME, "Error reading database.ini file.", "error_log", "") return False elif sqlconns.readsql_connection_timeware_main_6() == 1: test_comms = sqlconns.testsql(gl.SERVER, gl.SQL_LOGIN, gl.PASSWORD, gl.DATABASE) if test_comms == 0: f.error_logging(APPNAME, "Error connecting to SQL server.", "error_log", "") else: if os.path.isfile(gl.GENERAL_INI): fob = open(gl.GENERAL_INI, "r") listme = fob.readlines() fob.close() else: f.error_logging(APPNAME, "Error reading general.ini file.", "error_log", "") return False try: for index in range(len(listme)): if "'" in listme[index]: continue if 'https_port' in listme[index]: gl.https_port = int( str.split(listme[index], '=')[1]) if 'server_port' in listme[index]: gl.server_port = int( str.split(listme[index], '=')[1]) f.error_logging(APPNAME, "Port is now: " + str(gl.https_port), "error_log", "") except Exception as e: return False return True else: f.error_logging(APPNAME, "Error reading database.ini file.", "error_log", "") return False
def set_env(): maindb = 'timeware_main_6' userdb = 'timeware_user_6' if os.path.isfile(gl.GENERAL_INI): fob=open(gl.GENERAL_INI, "r") listme = fob.readlines() fob.close() else: f.error_logging(APPNAME, "Error reading general.ini file.", "error_log","") return False try: for index in range(len(listme)): if "'" in listme[index]: continue if 'server_port' in listme[index]: gl.server_port = int(str.split(listme[index],'=')[1]) if 'https_port' in listme[index]: gl.https_port = int(str.split(listme[index],'=')[1]) if "dbmain" in listme[index]: maindb = str.split(listme[index], '=')[1] maindb = maindb.replace("\r", "") maindb = maindb.replace("\n", "") if "dbuser" in listme[index]: userdb = str.split(listme[index], '=')[1] userdb = userdb.replace("\r", "") userdb = userdb.replace("\n", "") f.error_logging(APPNAME, "Port is now: "+str(gl.server_port), "error_log", "") except Exception as e: f.error_logging(APPNAME, "From SetEnv for loop?:" + e, "error_log", "") return False if sqlconns.readsql_connection_timeware_main_6(maindb,userdb) == 1: test_comms = sqlconns.testsql(gl.SERVER, gl.SQL_LOGIN, gl.PASSWORD, gl.DATABASE) if test_comms == 0: f.error_logging(APPNAME, "Error connecting to SQL server.", "error_log", "") return False return True
def __init__(self, parent, id): global VERSION global APPSERVER global APPNAME wx.Frame.__init__(self, parent, id, APPNAME + " - " + VERSION, size=(800, 600), style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER ^ wx.MAXIMIZE_BOX) wx.Frame.CenterOnScreen(self) if os.path.isfile('database.ini'): if sqlconns.readsql_connection() == 0: sql_messagebox = wx.MessageDialog( None, "Error reading 'database.ini'' file.", "User Alert!!!", wx.OK) sql_messagebox1 = sql_messagebox.ShowModal() sql_messagebox.Destroy() self.Destroy() elif sqlconns.readsql_connection() == 1: test_comms = sqlconns.testsql(gl.SERVER, gl.SQL_LOGIN, gl.PASSWORD, gl.DATABASE) if test_comms == 0: sql_messagebox = wx.MessageDialog( None, "Error connecting to SQL server..", "User Alert!!!", wx.OK) sql_messagebox1 = sql_messagebox.ShowModal() sql_messagebox.Destroy() self.Destroy() else: APPSERVER = gl.SERVER self.SetTitle(APPNAME + " - " + VERSION + " - " + APPSERVER) else: test = wx.MessageDialog(None, "No 'database.ini' file found.", "User Alert!!!", wx.OK) test1 = test.ShowModal() test.Destroy() self.Destroy() panel = wx.Panel(self) icon1 = wx.Icon(gl.small_icon_path, wx.BITMAP_TYPE_ICO) self.SetIcon(icon1) status = self.CreateStatusBar() menubar = wx.MenuBar() personnel_menu = wx.Menu() attendance_menu = wx.Menu() id_personnel_personnel = personnel_menu.Append(wx.NewId(), "Personnel") id_personnel_exit = personnel_menu.Append(wx.NewId(), "Exit") id_attendance_clock_card = attendance_menu.Append( wx.NewId(), "Clock-card") id_attendance_absence_chart = attendance_menu.Append( wx.NewId(), "Absence Chart") menubar.Append(personnel_menu, "Personnel") menubar.Append(attendance_menu, "Adjustments") self.Bind(wx.EVT_MENU, self.personnel_screen, id_personnel_personnel) self.Bind(wx.EVT_MENU, self.closebutton, id_personnel_exit) self.Bind(wx.EVT_CLOSE, self.closewindow) self.SetMenuBar(menubar)
def set_env(): global ACCESS_TERMINAL global ATTENDANCE_TERMINAL global DISTRIBUTOR global OLD_TIME global INBIO_USED global FINGER_DELETION_MINS global FUNCTION_KEYS global IFACE_FUNCTION_KEYS global ORIGINAL_BOOKINGS global CC_FUNCTION_KEYS global MIN_STAMP global MAX_STAMP gl.SERVER = "localhost" gl.SQL_LOGIN = "******" gl.PASSWORD = "******" gl.DATABASE = "timeware_main_6" if os.path.isfile(gl.SCRIPT_ROOT + 'database.ini'): #if sqlconns.readsql_connection_timeware_main_6() == 0: # f.error_logging(APPNAME, "Error reading database.ini file.", "error_log","") # return False if 1 < 0: return elif sqlconns.readsql_connection_timeware_main_6() == 1: gl.SERVER = "localhost" gl.SQL_LOGIN = "******" gl.PASSWORD = "******" gl.DATABASE = "timeware_main_6" test_comms = sqlconns.testsql(gl.SERVER, gl.SQL_LOGIN, gl.PASSWORD, gl.DATABASE) if test_comms == 0: f.error_logging(APPNAME, "Error connecting to SQL server.", "error_log", "") else: if os.path.isfile(gl.GENERAL_INI): fob = open(gl.GENERAL_INI, "r") listme = fob.readlines() fob.close() else: f.error_logging(APPNAME, "Error reading general.ini file.", "error_log", "") return False try: for index in range(len(listme)): if "'" in listme[index]: continue if 'distributor' in listme[index]: DISTRIBUTOR = str.split(listme[index], '=')[1] if 'server_port' in listme[index]: gl.server_port = int( str.split(listme[index], '=')[1]) if 'face_to_personnel' in listme[index]: if 'true' in str.split(listme[index], '=')[1]: gl.face_to_personnel = True if "access_terminal" in listme[index]: ACCESS_TERMINAL = int(listme[index].split("=")[1]) if "attendance_terminal" in listme[index]: ATTENDANCE_TERMINAL = int( listme[index].split("=")[1]) if "fingerprint_deletion" in listme[index]: FINGER_DELETION_MINS = int( listme[index].split("=")[1]) if 'oldtime' in listme[index]: if 'false' in str.split(listme[index], '=')[1]: OLD_TIME = False if "inbio" in listme[index]: if 'true' in str.split(listme[index], '=')[1]: INBIO_USED = True if "s680_function_keys" in listme[index]: if 'true' in str.split(listme[index], '=')[1]: FUNCTION_KEYS = True if "iface_function_keys" in listme[index]: if 'true' in str.split(listme[index], '=')[1]: IFACE_FUNCTION_KEYS = True if "original_bookings" in listme[index]: if 'false' in str.split(listme[index], '=')[1]: ORIGINAL_BOOKINGS = False if "cost_centre_function_keys" in listme[index]: if 'true' in str.split(listme[index], '=')[1]: CC_FUNCTION_KEYS = True if "max_stamp" in listme[index]: MAX_STAMP = str.split(listme[index], '=')[1] if "min_stamp" in listme[index]: MIN_STAMP = str.split(listme[index], '=')[1] except Exception as e: return False return True else: f.error_logging(APPNAME, "Error reading database.ini file.", "error_log", "") return False
def __init__(self): global VERSION global APPSERVER global APPNAME sql_tables = 0 wx.Frame.__init__(self, None, -1, APPNAME + " - " + VERSION, size=(820, 480), style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER ^ wx.MAXIMIZE_BOX) wx.Frame.CenterOnScreen(self) if os.path.isfile('database.ini'): if sqlconns.readsql_connection_timeware_main_6() == 0: sql_messagebox = wx.MessageDialog(None, "Error reading 'database.ini'' file.", "User Alert!!!", wx.OK) sql_messagebox1 = sql_messagebox.ShowModal() sql_messagebox.Destroy() self.Destroy() return elif sqlconns.readsql_connection_timeware_main_6() == 1: test_comms = sqlconns.testsql(gl.SERVER, gl.SQL_LOGIN, gl.PASSWORD, gl.DATABASE) if test_comms == 0: sql_messagebox = wx.MessageDialog(None, "Error connecting to SQL server..", "User Alert!!!", wx.OK) sql_messagebox1 = sql_messagebox.ShowModal() sql_messagebox.Destroy() self.Destroy() return else: APPSERVER = gl.SERVER self.SetTitle(APPNAME + " - " + VERSION + " - " +APPSERVER) else: grr = wx.MessageDialog(None, "No 'database.ini' file found.", "User Alert!!!", wx.OK) grr1 = grr.ShowModal() grr.Destroy() self.Destroy() return top_panel = wx.Panel(self) self.bottom_panel = wx.Panel(self, -1) button_refresh = wx.Button(top_panel,-1,label = 'Refresh',pos=(40,40)) button_refresh.Bind(wx.EVT_BUTTON,self.onbutton_refresh) self.button_start_service = wx.Button(top_panel,-1,label = 'Start Service',pos=(100,40)) self.button_start_service.Bind(wx.EVT_BUTTON,self.onbutton_start_service) self.button_stop_service = wx.Button(top_panel,-1,label = 'Pause Service',pos=(140,40)) self.button_stop_service.Bind(wx.EVT_BUTTON,self.onbutton_stop_service) top_sizer = wx.BoxSizer(wx.HORIZONTAL) top_sizer.AddSpacer(10) top_sizer.Add(button_refresh, flag=wx.EXPAND) top_sizer.Add(self.button_start_service, flag=wx.EXPAND) top_sizer.Add(self.button_stop_service, flag=wx.EXPAND) top_panel.SetSizer(top_sizer) self.inbio_controller_grid=gridlib.Grid(self.bottom_panel,-1,size=(800,300)) bottom_sizer = wx.BoxSizer(wx.VERTICAL) bottom_sizer.Add(self.inbio_controller_grid,1,flag=wx.EXPAND)#,pos=(200,200) upDownSizer = wx.BoxSizer(wx.VERTICAL) upDownSizer.AddSpacer(3) upDownSizer.Add(top_panel, 0, flag=wx.EXPAND) upDownSizer.AddSpacer(3) upDownSizer.Add(self.bottom_panel, 1, flag=wx.EXPAND) sql_tables = test_inbio_sql_tables() if sql_tables==0: warning_panel = wx.Panel(self) self.warning_label = wx.StaticText(warning_panel,ID_WARNING_LABEL,label="Warning Information:") self.warning_label1 = wx.StaticText(warning_panel,ID_WARNING_LABEL1,label="d_inbio tables may need to be created, use Advanced menu option.") #all these probably need to be self. if you want to get at them from abnother func warning_sizer = wx.BoxSizer(wx.VERTICAL) warning_sizer.Add(self.warning_label,0) warning_sizer.AddSpacer(2) warning_sizer.Add(self.warning_label1,0) warning_panel.SetSizer(warning_sizer) upDownSizer.AddSpacer(3) upDownSizer.Add(warning_panel, 2, flag=wx.EXPAND) self.SetSizer(upDownSizer) if sql_tables == 0: self.button_start_service.Enable(False) self.button_stop_service.Enable(False) else: if self.test_service_started() == True: self.button_start_service.Enable(False) else: self.button_stop_service.Enable(False) self.inbio_controller_grid.CreateGrid(0, 8) #self.inbio_controller_grid = inbio_controller_grid self.inbio_controller_grid.SetRowLabelSize(0) self.inbio_controller_grid.EnableEditing(False) self.inbio_controller_grid.GetGridWindow().Bind(wx.EVT_RIGHT_DOWN, self.showPopupMenu) self.inbio_controller_grid.SetColLabelAlignment(wx.HORIZONTAL,wx.ALIGN_LEFT) self.populate_terminal_grid(self.inbio_controller_grid) #self.inbio_controller_grid.AutoSize() self.inbio_controller_grid.ForceRefresh() icon1 = wx.Icon(gl.small_icon_path, wx.BITMAP_TYPE_ICO) self.SetIcon(icon1) #statusbar status=self.CreateStatusBar() #menus menubar = wx.MenuBar() file_menu = wx.Menu() advanced_menu = wx.Menu() id_file_exit = file_menu.Append(wx.NewId(), "Exit") menubar.Append(file_menu, "&File") advanced_menu.Append(ID_SIMPLE, "Create Tables") menubar.Append(advanced_menu,"&Advanced") id_advanced_options = advanced_menu.Append(wx.NewId(),"Options") #file menu bind self.Bind(wx.EVT_MENU, self.closebutton, id_file_exit) #advanced menu bind self.Bind(wx.EVT_MENU, self.create_inbio_sql_tables,id=ID_SIMPLE) self.Bind(wx.EVT_MENU, self.advanced_options_screen,id_advanced_options) #X button to close I think self.Bind(wx.EVT_CLOSE, self.closewindow) #setup bar self.SetMenuBar(menubar) #enable or disable sql creation menus after everything else if sql_tables == 0: menubar.Enable(ID_SIMPLE, True) else: menubar.Enable(ID_SIMPLE,False)
def set_env(): global ACCESS_TERMINAL global ATTENDANCE_TERMINAL global DISTRIBUTOR global OLD_TIME global INBIO_USED global FINGER_DELETION_MINS #this line doesnt do anything I think #f.error_logging(APPNAME,"error_log","2","") if os.path.isfile(gl.SCRIPT_ROOT + 'database.ini'): if sqlconns.readsql_connection_timeware_main_6() == 0: f.error_logging(APPNAME, "Error reading database.ini file.", "error_log", "") return False elif sqlconns.readsql_connection_timeware_main_6() == 1: test_comms = sqlconns.testsql(gl.SERVER, gl.SQL_LOGIN, gl.PASSWORD, gl.DATABASE) if test_comms == 0: f.error_logging(APPNAME, "Error connecting to SQL server.", "error_log", "") else: if os.path.isfile(gl.GENERAL_INI): fob = open(gl.GENERAL_INI, "r") listme = fob.readlines() fob.close() else: f.error_logging(APPNAME, "Error reading general.ini file.", "error_log", "") return False try: for index in range(len(listme)): if "'" in listme[index]: continue if 'distributor' in listme[index]: DISTRIBUTOR = str.split(listme[index], '=')[1] if 'server_port' in listme[index]: gl.server_port = int( str.split(listme[index], '=')[1]) if 'face_to_personnel' in listme[index]: if 'true' in str.split(listme[index], '=')[1]: gl.face_to_personnel = True if "access_terminal" in listme[index]: ACCESS_TERMINAL = int(listme[index].split("=")[1]) if "attendance_terminal" in listme[index]: ATTENDANCE_TERMINAL = int( listme[index].split("=")[1]) if "fingerprint_deletion" in listme[index]: FINGER_DELETION_MINS = int( listme[index].split("=")[1]) if 'oldtime' in listme[index]: if 'false' in str.split(listme[index], '=')[1]: OLD_TIME = False if "inbio" in listme[index]: if 'true' in str.split(listme[index], '=')[1]: INBIO_USED = True print(INBIO_USED) print(FINGER_DELETION_MINS) except Exception as e: print(e) return False return True else: f.error_logging(APPNAME, "Error reading database.ini file.", "error_log", "") return False