Browse Source

Replace _remove_sensitive_data() with _get_options()

doc-issue-template
MrS0m30n3 10 years ago
parent
commit
c8b14dba2a
2 changed files with 13 additions and 11 deletions
  1. 18
      youtube_dl_gui/OptionsHandler.py
  2. 6
      youtube_dl_gui/YoutubeDLGUI.py

18
youtube_dl_gui/OptionsHandler.py

@ -83,8 +83,8 @@ class OptionsHandler(object):
check_path(self.config_path) check_path(self.config_path)
with open(self.settings_file, 'wb') as f: with open(self.settings_file, 'wb') as f:
self._remove_sensitive_data()
json.dump(self.options, f, indent=4, separators=(',', ': '))
options = self._get_options()
json.dump(options, f, indent=4, separators=(',', ': '))
def _settings_are_valid(self, settings_dictionary): def _settings_are_valid(self, settings_dictionary):
''' Check settings.json dictionary and raise WrongSettings Exception ''' ''' Check settings.json dictionary and raise WrongSettings Exception '''
@ -95,10 +95,16 @@ class OptionsHandler(object):
if key not in settings_dictionary: if key not in settings_dictionary:
raise WrongSettings() raise WrongSettings()
def _remove_sensitive_data(self):
''' Remove sensitive data from self.options (passwords, etc) '''
for key in self.SENSITIVE_KEYS:
self.options[key] = ''
def _get_options(self):
''' Return options dictionary without SENSITIVE_KEYS '''
temp_options = {}
for key in self.options:
if key in self.SENSITIVE_KEYS:
temp_options[key] = ''
else:
temp_options[key] = self.options[key]
return temp_options
def _get_settings_file(self): def _get_settings_file(self):
''' Return abs path to settings file ''' ''' Return abs path to settings file '''

6
youtube_dl_gui/YoutubeDLGUI.py

@ -184,12 +184,8 @@ class MainFrame(wx.Frame):
def fin_tasks(self): def fin_tasks(self):
if self.opt_manager.options['shutdown']: if self.opt_manager.options['shutdown']:
''' Store sudo password in a temp variable
because we will call _remove_sensitive_data() in
self.opt_manager.save_to_file() '''
sudo_password = self.opt_manager.options['sudo_password']
self.save_options() self.save_options()
shutdown_sys(sudo_password)
shutdown_sys(self.opt_manager.options['sudo_password'])
else: else:
self.finished_popup() self.finished_popup()
self.open_destination_dir() self.open_destination_dir()

Loading…
Cancel
Save