def saveProfileData(self, name): try: with open('profiles/profiles.txt', 'a') as infile: infile.write(name + '\n') profilePath = 'profiles/' + name + '.json' profilePath = profilePath.replace(' ', '').lower() with open(profilePath, 'w+', encoding='utf-8') as outfile: profileData = [self.profileDictionary] json.dump(profileData, outfile, ensure_ascii=False, indent=4) outfile.close() except FileNotFoundError: print("Error while saving profile data") self.__error = '[PF#C5]CRUCIAL_SAVING_ERROR' lg = logger_class.Logger().logError(self.__errorClass, self.__error) if not lg: print("Error has not been logged") del lg except: print("Error while saving profile data") self.__error = '[PF#C6]UNKNOWN_CRUCIAL_JSON_SAVING_ERROR' lg = logger_class.Logger().logError(self.__errorClass, self.__error) if not lg: print("Error has not been logged") del lg
def __isApplicationsListValid(self, appList): if type(appList) is not list: self.__error = '[PF#C2]APP_LIST_DATA_TYPE_ERROR' lg = logger_class.Logger().logError(self.__errorClass, self.__error) if not lg: print("Error has not been logged") del lg return False for app in appList: if type(app) is not dict: self.__error = '[PF#C3]APP_DATA_TYPE_ERROR' lg = logger_class.Logger().logError(self.__errorClass, self.__error) if not lg: print("Error has not been logged") del lg return False appName = app.get('name') appPath = app.get('path') appWindowValue = app.get('vwindow') tempApp = application_class.Application() isValid = tempApp.isApplicationValid(appName, appPath, appWindowValue) if not isValid: self.__error = '[PF#C4]APP_LIST_VALIDATION_ERROR' lg = logger_class.Logger().logError(self.__errorClass, self.__error) if not lg: print("Error has not been logged") del lg return False return True
def __isProfileNameValid(self, name): if type(name) is not str: self.__error = '[PF#C1]PROFILE_NAME_DATA_TYPE_ERROR' lg = logger_class.Logger().logError(self.__errorClass, self.__error) if not lg: print("Error has not been logged") del lg return False if len(name) > 16: self.__error = '[PF#1]PROFILE_NAME_LENGTH_ERROR' lg = logger_class.Logger().logError(self.__errorClass, self.__error) if not lg: print("Error has not been logged") del lg return False return True
def __isVWindowValid(self, vwindow): if type(vwindow) is not int: self.__error = '[AP#C3]WINDOW_TYPE_ERROR' lg = logger_class.Logger().logError(self.__errorClass, self.__error) if not lg: print("Error has not been logged") del lg return False if vwindow > 10: self.__error = '[AP#3]WINDOW_VALUE_ERROR' lg = logger_class.Logger().logError(self.__errorClass, self.__error) if not lg: print("Error has not been logged") del lg return False return True
def __isPathValid(self, path): if type(path) is not str: self.__error = '[AP#C2]PATH_TYPE_ERROR' lg = logger_class.Logger().logError(self.__errorClass, self.__error) if not lg: print("Error has not been logged") del lg return False if len(path) > 128: self.__error = '[AP#2]PATH_LENGTH_ERROR' lg = logger_class.Logger().logError(self.__errorClass, self.__error) if not lg: print("Error has not been logged") del lg return False return True
def initializeMainWindow(self): try: self.createMainWindowGUI() except: print("Main window initialization error") self.__error = '[AP#C1]MAIN_INIT_ERROR' lg = logger_class.Logger().logError(self.__errorClass, self.__error) if not lg: print("Error has not been logged") del lg try: self.createMainWindowButtons() except AttributeError: print("Button function not recognized") self.__error = '[AP#C2]BUTTONS_INIT_ERROR' lg = logger_class.Logger().logError(self.__errorClass, self.__error) if not lg: print("Error has not been logged") del lg try: self.createMainWindowListbox() except AttributeError: print("List box items not found") self.__error = '[AP#C3]LISTBOX_INIT_ERROR' lg = logger_class.Logger().logError(self.__errorClass, self.__error) if not lg: print("Error has not been logged") del lg try: self.loadProfiles() except: print("Error while loading profiles") self.__error = '[AP#C4]PROFILES_LOADING_ERROR' lg = logger_class.Logger().logError(self.__errorClass, self.__error) if not lg: print("Error has not been logged") del lg