def loadDevices( ): #Loads and filters all of the audio devices saved, removes the ones that dont work anymore and adds the new ones au.getXmlData() sdata.allDevices = au.getDeviceList() if os.path.getsize(sdata.headphonesSaveFile) == 0: sdata.speakers = sdata.allDevices[:] fileop.writeListToFile(sdata.speakersFile, sdata.speakers) else: sdata.headphones = fileop.loadListFromFile(sdata.headphonesSaveFile) sdata.speakers = [] if os.path.getsize(sdata.speakersFile) != 0: sdata.speakers = fileop.loadListFromFile(sdata.speakersFile) for device in sdata.headphones: if device not in sdata.allDevices: sdata.headphones.remove(device) for device in sdata.allDevices: if device not in sdata.headphones and device not in sdata.speakers: sdata.speakers.append(device) updateDevices() fileop.writeListToFile(sdata.speakersFile, sdata.speakers) fileop.writeListToFile(sdata.headphonesFile, sdata.headphones)
def loadModes(): #Loads the saved functioning modes if os.path.getsize(sdata.modesFile) > 0: sdata.loadedModes = fileop.loadModesFromFile(sdata.modesFile) else: restoreDefaultModes() if os.path.getsize(sdata.currentModeFile) > 0: sdata.currentMode = int( fileop.loadListFromFile(sdata.currentModeFile)[0]) if sdata.currentMode == -1: sdata.currentMode = 0 else: fileop.writeListToFile(sdata.currentModeFile, [sdata.currentMode]) updateModes() gui.GUI.comboBox.setCurrentIndex(sdata.currentMode)
def loadSettings(self): fileop.checkDataFilesExist() if os.path.getsize(sdata.settingsCheckBoxFile) > 0: boolList = fileop.loadBoolArrayFromFile(sdata.settingsCheckBoxFile) self.endPopup = boolList[3] self.endSwitch = boolList[0] self.endMute = boolList[1] self.endSound = boolList[2] self.limitVolume = boolList[5] self.stopWhenMute = boolList[6] self.loadVolumeLimit() if os.path.getsize(sdata.modesFile) > 0 and os.path.getsize( sdata.currentModeFile): modeIndex = int(fileop.loadListFromFile(sdata.currentModeFile)[0]) self.runMode = self.getWaitTimeInSeconds( fileop.loadModesFromFile(sdata.modesFile)[modeIndex])
def loadSettings(): #Loads the settings print(sdata.settingsCheckBoxesStates) if os.path.getsize(sdata.settingsCheckBoxFile) != 0: sdata.settingsCheckBoxesStates = fileop.loadBoolArrayFromFile( sdata.settingsCheckBoxFile) else: fileop.saveBoolArrayToFile(sdata.settingsCheckBoxFile, sdata.settingsCheckBoxesStates) for setting in sdata.settingsCheckBoxesList: if sdata.settingsCheckBoxesStates[sdata.settingsCheckBoxesList.index( setting)]: setting.setCheckState(2) else: setting.setCheckState(0) pass if os.path.getsize(sdata.volumeLimitFile) != 0: sdata.volumeLimit = fileop.loadListFromFile(sdata.volumeLimitFile)[0] gui.GUI.horizontalSlider.setValue(int(sdata.volumeLimit))
def loadVolumeLimit(self): if os.path.getsize(sdata.volumeLimitFile) > 0: self.limitVolumeValue = int( fileop.loadListFromFile(sdata.volumeLimitFile)[0])
def isHeadphone(self, device): headphones = fileop.loadListFromFile(sdata.headphonesFile) return device in headphones