def on_save(self): if not parser.has_section('Settings'): parser.add_section('Settings') # update settings values self.update_and_apply_settings() parser.set('Settings', 'debug_log_level', json.dumps(self.settings['debug_log_level'])) parser.set('Settings', 'ssh_client', json.dumps(self.settings['ssh_client'])) parser.set('Settings', 'preload_command', json.dumps(self.settings['preload_command'])) try: config_file_dir = os.path.dirname(config_file_name) if not os.path.exists(config_file_dir): os.makedirs(config_file_dir) with open(config_file_name, 'w') as config_file: parser.write(config_file) except Exception: logger.error( "failed to dump the settings in the configuration file") self.close()
def on_save(self): if not parser.has_section('Settings'): parser.add_section('Settings') # update settings values self.update_and_apply_settings() for k in defaults: parser.set('Settings', k, json.dumps(self.settings[k], indent=4)) try: config_file_dir = os.path.dirname(config_file_name) if not os.path.exists(config_file_dir): os.makedirs(config_file_dir) with open(config_file_name, 'w') as config_file: parser.write(config_file) except Exception: logger.error( "failed to dump the settings in the configuration file") self.close()
def update_config_file(self, session_name): """ Update the config file with the new session name :param session_name: name of the last session inserted by the user :return: """ if not parser.has_section('LoginFields'): parser.add_section('LoginFields') parser.set('LoginFields', 'hostList', json.dumps(list(self.sessions_list))) try: config_file_dir = os.path.dirname(config_file_name) if not os.path.exists(config_file_dir): os.makedirs(config_file_dir) with open(config_file_name, 'w') as config_file: parser.write(config_file) except: logger.error( "failed to dump the session list in the configuration file")
def update_config_file(self): """ Update the config file with the display size list :return: """ if not parser.has_section('DisplaySizeField'): parser.add_section('DisplaySizeField') parser.set('DisplaySizeField', 'displaysizelist', json.dumps(list(self.display_size_list))) try: config_file_dir = os.path.dirname(config_file_name) if not os.path.exists(config_file_dir): os.makedirs(config_file_dir) with open(config_file_name, 'w') as config_file: parser.write(config_file) except: logger.error( "failed to dump the display size list in the configuration file" )