def sync_on_startup_slot(self, state): if state == 2: self.settings['SyncOnStartup'] = 'True' logger.info('All courses will be synced at startup') else: self.settings['SyncOnStartup'] = 'False' logger.info('No course will be synced at startup') filesettings.settingsToFile(self.settings, self.settings_path)
def syncnewslot(self, state): if state == 2: self.settings['SyncNewCourses'] = 'True' logger.info('New courses will now be automatically synced') else: self.settings['SyncNewCourses'] = 'False' logger.info('New courses will NOT be automatically synced') filesettings.settingsToFile(self.settings, self.settings_path)
def test_saveioerror(tmpdir): """a generic IOError, for example we don't have write permission""" f = tmpdir.mkdir('fold').join('sets.ini') f.write('doesntmatter') os.chmod(str(f), 0o444) try: newsettings = { 'UpdateEvery': '20', 'RootFolder': 'finalroot', 'SyncNewCourses': 'True' } settingsToFile(newsettings, str(f)) except IOError: pass
def test_savefileexists(tmpdir, default_settings_dict): f = tmpdir.mkdir('fold').join('sets.ini') conf = RawConfigParser() conf.optionxform = lambda option: option conf['General'] = { 'UpdateEvery': '30', 'RootFolder': 'anotherroot', 'SyncNewCourses': 'False' } with open(str(f), 'w') as setsfile: conf.write(setsfile) newsettings = { 'UpdateEvery': '20', 'RootFolder': 'finalroot', 'SyncNewCourses': 'True' } settingsToFile(newsettings, str(f)) assert settingsFromFile(str(f), default_settings_dict) == newsettings
def chooserootdir(self): currentdir = self.settings['RootFolder'] flags = QFileDialog.DontResolveSymlinks | QFileDialog.ShowDirsOnly newroot = QFileDialog.getExistingDirectory(None, "Open Directory", currentdir, flags) if newroot != "" and str(newroot) != currentdir: self.settings['RootFolder'] = str(newroot) filesettings.settingsToFile(self.settings, self.settings_path) self._window.rootfolder.setText(newroot) # we delete the already present downloadthread and recreate it # because otherwise it uses the old download folder. I don't know # if there's a cleaner approach del self.downloadthread self.downloadthread = DownloadThread(self.user, self.settings['RootFolder'], self) self.downloadthread.dumpuser.sig.connect(self.dumpUser) self.dumpUser()
def rootfolderslot(self, path): self.settings['RootFolder'] = path filesettings.settingsToFile(self.settings, self.settings_path)
def updateminuteslot(self, minutes): self.settings['UpdateEvery'] = str(minutes) filesettings.settingsToFile(self.settings, self.settings_path) self.timer.start(1000 * 60 * int(self.settings['UpdateEvery']))
def syncnewslot(self, state): if state == 2: self.settings['SyncNewCourses'] = 'True' else: self.settings['SyncNewCourses'] = 'False' filesettings.settingsToFile(self.settings, self.settings_path)
def rootfolderslot(self, path): self.settings['RootFolder'] = path filesettings.settingsToFile(self.settings, self.settings_path) logger.info(f'Root folder set to: {path}')
def updateminuteslot(self, minutes): self.settings['UpdateEvery'] = str(minutes) filesettings.settingsToFile(self.settings, self.settings_path) self.timer.start(1000 * 60 * int(self.settings['UpdateEvery'])) logger.info('All courses will be automatically synced every ' f'{self.settings["UpdateEvery"]} minutes')