def do_POST(self): logging.warning("======= POST STARTED =======") logging.warning(self.headers) if self.path == "/": self.data_string = self.rfile.read(int(self.headers['Content-Length'])) data = json.loads(self.data_string) config.save_settings(data, config.CONFIG_FILE) config.SETTINGS = data if alarm is not None: alarm.set_settings(config.SETTINGS) if radio is not None and "radio" in config.SETTINGS: _radio_settings = config.SETTINGS['radio'] radio.change_country(_radio_settings['country']) if "radio_stations" in _radio_settings and len(_radio_settings['radio_stations']) > 0: radio.radio_channels.extend(_radio_settings['radio_stations']) logging.warning("\n") self.send_response(200) return elif self.path == "/dirble_api_key": data_string = self.rfile.read(int(self.headers['Content-Length'])) data = json.loads(data_string) config.save_settings(data, "radio/private.json") config.DIRBLE_API_KEY = data["dirble_api_key"] logging.warning("\n") self.send_response(200) return else: self.send_error(501, "POST request is not supported with path") return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
def do_POST(self): logging.warning("======= POST STARTED =======") logging.warning(self.headers) if self.path == "/": self.data_string = self.rfile.read( int(self.headers['Content-Length'])) data = json.loads(self.data_string) config.save_settings(data, config.CONFIG_FILE) config.SETTINGS = data if alarm is not None: alarm.set_settings(config.SETTINGS) if radio is not None and "radio" in config.SETTINGS: _radio_settings = config.SETTINGS['radio'] radio.change_country(_radio_settings['country']) if "radio_stations" in _radio_settings and len( _radio_settings['radio_stations']) > 0: radio.radio_channels.extend( _radio_settings['radio_stations']) logging.warning("\n") self.send_response(200) return elif self.path == "/dirble_api_key": data_string = self.rfile.read(int(self.headers['Content-Length'])) data = json.loads(data_string) config.save_settings(data, "radio/private.json") config.DIRBLE_API_KEY = data["dirble_api_key"] logging.warning("\n") self.send_response(200) return else: self.send_error(501, "POST request is not supported with path") return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
def update_settings(self): self.settings[ 'startup_show'] = self.settings_show_on_startup.isChecked() self.settings['full_screen'] = self.settings_fullscreen.isChecked() self.settings['close_on_open'] = self.settings_close_on_open.isChecked( ) self.settings['new_window'] = self.settings_open_new_window.isChecked() config.save_settings(self.settings)
def save_field_map(self): """ Saves the field maps to the config file :return: """ # Save settings config.save_settings(self.ui.txt_fieldMap.toPlainText(), "fields") # Reload Settings self.field_maps = config.load_settings("fields")
def save_settings_button(self): """ Save settings :return: """ settings = { "vcuser": self.ui.vc_api_user.text(), "vcpass": self.ui.vc_api_pass.text(), "vcurl": self.ui.vc_api_url.text(), "adpnetuser": self.ui.lineEdit_adpUsername.text(), "adpnetpass": self.ui.lineEdit_adpPassword.text(), "adpcertpath": self.ui.lineEdit_adpCertificatePEMPath.text(), "adpcertkeypath": self.ui.lineEdit_adpCertificateKeyPath.text(), "adpvccustomfieldname": self.ui.lineEdit_adpVCCustomFieldName.text() } # Save settings config.save_settings(settings, "config") # Reload Settings self.c = config.load_settings("config")
def post(self): enabled_languages = request.form.getlist('languages-enabled') if len(enabled_languages) != 0: TableSettingsLanguages.update({ TableSettingsLanguages.enabled: 0 }).execute() for code in enabled_languages: TableSettingsLanguages.update({ TableSettingsLanguages.enabled: 1 })\ .where(TableSettingsLanguages.code2 == code)\ .execute() event_stream("languages") languages_profiles = request.form.get('languages-profiles') if languages_profiles: existing_ids = TableLanguagesProfiles.select(TableLanguagesProfiles.profileId).dicts() existing_ids = list(existing_ids) existing = [x['profileId'] for x in existing_ids] for item in json.loads(languages_profiles): if item['profileId'] in existing: # Update existing profiles TableLanguagesProfiles.update({ TableLanguagesProfiles.name: item['name'], TableLanguagesProfiles.cutoff: item['cutoff'] if item['cutoff'] != 'null' else None, TableLanguagesProfiles.items: json.dumps(item['items']), TableLanguagesProfiles.mustContain: item['mustContain'], TableLanguagesProfiles.mustNotContain: item['mustNotContain'], })\ .where(TableLanguagesProfiles.profileId == item['profileId'])\ .execute() existing.remove(item['profileId']) else: # Add new profiles TableLanguagesProfiles.insert({ TableLanguagesProfiles.profileId: item['profileId'], TableLanguagesProfiles.name: item['name'], TableLanguagesProfiles.cutoff: item['cutoff'] if item['cutoff'] != 'null' else None, TableLanguagesProfiles.items: json.dumps(item['items']), TableLanguagesProfiles.mustContain: item['mustContain'], TableLanguagesProfiles.mustNotContain: item['mustNotContain'], }).execute() for profileId in existing: # Unassign this profileId from series and movies TableShows.update({ TableShows.profileId: None }).where(TableShows.profileId == profileId).execute() TableMovies.update({ TableMovies.profileId: None }).where(TableMovies.profileId == profileId).execute() # Remove deleted profiles TableLanguagesProfiles.delete().where(TableLanguagesProfiles.profileId == profileId).execute() update_profile_id_list() event_stream("languages") if settings.general.getboolean('use_sonarr'): scheduler.add_job(list_missing_subtitles, kwargs={'send_event': False}) if settings.general.getboolean('use_radarr'): scheduler.add_job(list_missing_subtitles_movies, kwargs={'send_event': False}) # Update Notification notifications = request.form.getlist('notifications-providers') for item in notifications: item = json.loads(item) TableSettingsNotifier.update({ TableSettingsNotifier.enabled: item['enabled'], TableSettingsNotifier.url: item['url'] }).where(TableSettingsNotifier.name == item['name']).execute() save_settings(zip(request.form.keys(), request.form.listvalues())) event_stream("settings") return '', 204