From a3edf805bbf150fd0e6126c158d51fd3514fd4c0 Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Sat, 4 Jun 2016 00:52:10 +0100 Subject: [PATCH] Remove code to enable VerboseLogging No longer required --- EDMarketConnector.py | 5 +-- L10n/cs.strings | 6 --- L10n/de.strings | 6 --- L10n/en.template | 6 --- L10n/es.strings | 6 --- L10n/fr.strings | 6 --- L10n/it.strings | 6 --- L10n/ja.strings | 6 --- L10n/lv.strings | 6 --- L10n/nl.strings | 6 --- L10n/pl.strings | 6 --- L10n/ru.strings | 6 --- L10n/sl.strings | 6 --- L10n/uk.strings | 6 --- monitor.py | 97 -------------------------------------------- prefs.py | 21 ++-------- 16 files changed, 5 insertions(+), 196 deletions(-) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index 13c7b201..7a11339d 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -242,7 +242,6 @@ class AppWindow: monitor.set_callback(self.system_change) edproxy.set_callback(self.system_change) if (config.getint('output') & config.OUT_LOG_AUTO) and (config.getint('output') & (config.OUT_LOG_FILE|config.OUT_LOG_EDSM)): - monitor.enable_logging() monitor.start(self.w) edproxy.start(self.w) @@ -306,9 +305,7 @@ class AppWindow: if not self.status['text']: self.status['text'] = unicode(e) - if not self.status['text'] and monitor.restart_required(): - self.status['text'] = _('Re-start Elite: Dangerous for automatic log entries') # Status bar message on launch - elif not getattr(sys, 'frozen', False): + if not getattr(sys, 'frozen', False): self.updater.checkForUpdates() # Sparkle / WinSparkle does this automatically for packaged apps self.cooldown() diff --git a/L10n/cs.strings b/L10n/cs.strings index 5fd2ad3d..b209a760 100755 --- a/L10n/cs.strings +++ b/L10n/cs.strings @@ -358,12 +358,6 @@ /* Power rank. [stats.py] */ "Rating 5" = "Rating 5"; -/* Status bar message on launch. [EDMarketConnector.py] */ -"Re-start Elite: Dangerous for automatic log entries" = "Restartujte Elite: Dangerous pro aktivaci automatických záznamů"; - -/* Output settings prompt. [prefs.py] */ -"Re-start Elite: Dangerous to use this feature" = "Restartujte Elite: Dangerous pro aktivaci této funkce"; - /* Shortcut settings prompt on OSX. [prefs.py] */ "Re-start {APP} to use shortcuts" = "Restartujte {APP} pro aktivaci klávesových zkratek"; diff --git a/L10n/de.strings b/L10n/de.strings index 186d6a5c..bc6c80a6 100755 --- a/L10n/de.strings +++ b/L10n/de.strings @@ -358,12 +358,6 @@ /* Power rank. [stats.py] */ "Rating 5" = "Wertung 5"; -/* Status bar message on launch. [EDMarketConnector.py] */ -"Re-start Elite: Dangerous for automatic log entries" = "Starte Elite: Dangerous für automatische Logbucheinträge neu"; - -/* Output settings prompt. [prefs.py] */ -"Re-start Elite: Dangerous to use this feature" = "Starte Elite: Dangerous neu um diese Funktion zu nutzen"; - /* Shortcut settings prompt on OSX. [prefs.py] */ "Re-start {APP} to use shortcuts" = "Starte {APP} neu, um den Tastenkürzel nutzen zu können"; diff --git a/L10n/en.template b/L10n/en.template index 3b0ec60c..b6444caf 100644 --- a/L10n/en.template +++ b/L10n/en.template @@ -358,12 +358,6 @@ /* Power rank. [stats.py] */ "Rating 5" = "Rating 5"; -/* Status bar message on launch. [EDMarketConnector.py] */ -"Re-start Elite: Dangerous for automatic log entries" = "Re-start Elite: Dangerous for automatic log entries"; - -/* Output settings prompt. [prefs.py] */ -"Re-start Elite: Dangerous to use this feature" = "Re-start Elite: Dangerous to use this feature"; - /* Shortcut settings prompt on OSX. [prefs.py] */ "Re-start {APP} to use shortcuts" = "Re-start {APP} to use shortcuts"; diff --git a/L10n/es.strings b/L10n/es.strings index 42ca1196..de80b8c1 100755 --- a/L10n/es.strings +++ b/L10n/es.strings @@ -358,12 +358,6 @@ /* Power rank. [stats.py] */ "Rating 5" = "Nivel 5"; -/* Status bar message on launch. [EDMarketConnector.py] */ -"Re-start Elite: Dangerous for automatic log entries" = "Reinicie Elite: Dangerous para automatizar entradas en el registro"; - -/* Output settings prompt. [prefs.py] */ -"Re-start Elite: Dangerous to use this feature" = "Reinicie Elite: Dangerous para usar esta característica"; - /* Shortcut settings prompt on OSX. [prefs.py] */ "Re-start {APP} to use shortcuts" = "Reinicie {APP} para usar los accesos directos de teclado"; diff --git a/L10n/fr.strings b/L10n/fr.strings index d08b7ad2..bce85012 100755 --- a/L10n/fr.strings +++ b/L10n/fr.strings @@ -358,12 +358,6 @@ /* Power rank. [stats.py] */ "Rating 5" = "Rang 5"; -/* Status bar message on launch. [EDMarketConnector.py] */ -"Re-start Elite: Dangerous for automatic log entries" = "Redémarrez Elite: Dangerous pour les entrées de journal automatiques"; - -/* Output settings prompt. [prefs.py] */ -"Re-start Elite: Dangerous to use this feature" = "Redémarrez Elite: Dangerous pour utiliser cette fonctionnalité"; - /* Shortcut settings prompt on OSX. [prefs.py] */ "Re-start {APP} to use shortcuts" = "Rédémarrez {APP} pour utiliser les raccourcis"; diff --git a/L10n/it.strings b/L10n/it.strings index 9703b29a..4c87d07d 100755 --- a/L10n/it.strings +++ b/L10n/it.strings @@ -358,12 +358,6 @@ /* Power rank. [stats.py] */ "Rating 5" = "Rating 5"; -/* Status bar message on launch. [EDMarketConnector.py] */ -"Re-start Elite: Dangerous for automatic log entries" = "Riavviare Elite: Dangerous per una log entry automatica"; - -/* Output settings prompt. [prefs.py] */ -"Re-start Elite: Dangerous to use this feature" = "Riavviare Elite: Dangerous per usare questa funzione"; - /* Shortcut settings prompt on OSX. [prefs.py] */ "Re-start {APP} to use shortcuts" = "Riavvia {APP} per usare le scorciatoie"; diff --git a/L10n/ja.strings b/L10n/ja.strings index 5ef8a347..5518112f 100644 --- a/L10n/ja.strings +++ b/L10n/ja.strings @@ -358,12 +358,6 @@ /* Power rank. [stats.py] */ "Rating 5" = "Rating 5"; -/* Status bar message on launch. [EDMarketConnector.py] */ -"Re-start Elite: Dangerous for automatic log entries" = "自動的にログを記録するにはElite: Dangerousを再起動してください"; - -/* Output settings prompt. [prefs.py] */ -"Re-start Elite: Dangerous to use this feature" = "この機能を利用するにはElite: Dangerousを再起動してください"; - /* Shortcut settings prompt on OSX. [prefs.py] */ "Re-start {APP} to use shortcuts" = "ショートカットを利用するには {APP} を再起動してください"; diff --git a/L10n/lv.strings b/L10n/lv.strings index 03af8896..4569e60b 100755 --- a/L10n/lv.strings +++ b/L10n/lv.strings @@ -358,12 +358,6 @@ /* Power rank. [stats.py] */ "Rating 5" = "Rating 5"; -/* Status bar message on launch. [EDMarketConnector.py] */ -"Re-start Elite: Dangerous for automatic log entries" = "Restartējiet Elite: Dangerous priekš automātiskas datu iegūšanas"; - -/* Output settings prompt. [prefs.py] */ -"Re-start Elite: Dangerous to use this feature" = "Restartējiet Elite: Dangerous lai izmantotu šo iespēju"; - /* Shortcut settings prompt on OSX. [prefs.py] */ "Re-start {APP} to use shortcuts" = "Restartējiet {APP} lai izmantotu īssceļus"; diff --git a/L10n/nl.strings b/L10n/nl.strings index 717ad85e..49a879d9 100755 --- a/L10n/nl.strings +++ b/L10n/nl.strings @@ -358,12 +358,6 @@ /* Power rank. [stats.py] */ "Rating 5" = "Rating 5"; -/* Status bar message on launch. [EDMarketConnector.py] */ -"Re-start Elite: Dangerous for automatic log entries" = "Elite: Dangerous heropstarten voor automatisch aanmaken log regels"; - -/* Output settings prompt. [prefs.py] */ -"Re-start Elite: Dangerous to use this feature" = "Elite: Dangerous heropstarten om deze functie te gebruiken"; - /* Shortcut settings prompt on OSX. [prefs.py] */ "Re-start {APP} to use shortcuts" = "{APP} heropstarten om toetscombinaties te gebruiken"; diff --git a/L10n/pl.strings b/L10n/pl.strings index 429dd5cc..7774560b 100755 --- a/L10n/pl.strings +++ b/L10n/pl.strings @@ -358,12 +358,6 @@ /* Power rank. [stats.py] */ "Rating 5" = "Ocena 5"; -/* Status bar message on launch. [EDMarketConnector.py] */ -"Re-start Elite: Dangerous for automatic log entries" = "Zrestartuj E:D by uruchomić automatyczne logowanie"; - -/* Output settings prompt. [prefs.py] */ -"Re-start Elite: Dangerous to use this feature" = "Zrestartuj Elite: Dangerous by użyć tej funkcji"; - /* Shortcut settings prompt on OSX. [prefs.py] */ "Re-start {APP} to use shortcuts" = "Zrestartuj {APP} by użyć{CR}skrótu klawiszowego."; diff --git a/L10n/ru.strings b/L10n/ru.strings index 8d10db1d..2e187d0f 100755 --- a/L10n/ru.strings +++ b/L10n/ru.strings @@ -358,12 +358,6 @@ /* Power rank. [stats.py] */ "Rating 5" = "Ранг 5"; -/* Status bar message on launch. [EDMarketConnector.py] */ -"Re-start Elite: Dangerous for automatic log entries" = "Перезапустите Elite: Dangerous чтобы автоматически получать журнал полета"; - -/* Output settings prompt. [prefs.py] */ -"Re-start Elite: Dangerous to use this feature" = "Перезапустите Elite: Dangerous чтобы изменения вступили в силу"; - /* Shortcut settings prompt on OSX. [prefs.py] */ "Re-start {APP} to use shortcuts" = "Перезапустите {APP}, чтобы использовать сочетание клавиш"; diff --git a/L10n/sl.strings b/L10n/sl.strings index 66f3e7fb..3349ae1c 100755 --- a/L10n/sl.strings +++ b/L10n/sl.strings @@ -358,12 +358,6 @@ /* Power rank. [stats.py] */ "Rating 5" = "Ocena 5"; -/* Status bar message on launch. [EDMarketConnector.py] */ -"Re-start Elite: Dangerous for automatic log entries" = "Poženi ponovno Elite: Dangerous za vklop avtomatičnih vpisov v dnevnik"; - -/* Output settings prompt. [prefs.py] */ -"Re-start Elite: Dangerous to use this feature" = "Ponovno poženi Elite: Dangerous za uporabo te funkcije"; - /* Shortcut settings prompt on OSX. [prefs.py] */ "Re-start {APP} to use shortcuts" = "Ponovno poženi {APP} za uporabo bližnjic"; diff --git a/L10n/uk.strings b/L10n/uk.strings index 0a6bc465..345021a4 100755 --- a/L10n/uk.strings +++ b/L10n/uk.strings @@ -358,12 +358,6 @@ /* Power rank. [stats.py] */ "Rating 5" = "Рейтинг 5"; -/* Status bar message on launch. [EDMarketConnector.py] */ -"Re-start Elite: Dangerous for automatic log entries" = "Перезапустіть Elite: Dangerous для автоматичного ведення журналу (log)"; - -/* Output settings prompt. [prefs.py] */ -"Re-start Elite: Dangerous to use this feature" = "Необхідно перепустити Elite: Dangerous для використання цієї функції"; - /* Shortcut settings prompt on OSX. [prefs.py] */ "Re-start {APP} to use shortcuts" = "Перезавантажте {APP} для використання ярликів"; diff --git a/monitor.py b/monitor.py index 789e575a..871628ff 100644 --- a/monitor.py +++ b/monitor.py @@ -77,73 +77,11 @@ class EDLogs(FileSystemEventHandler): self.root = None self.logdir = self._logdir() self.logfile = None - self.logging_enabled = self._logging_enabled - self._restart_required = False self.observer = None self.thread = None self.callback = None self.last_event = None # for communicating the Jump event - def enable_logging(self): - if self.logging_enabled(): - return True - elif self._enable_logging(): - self._restart_required = self._ED_is_running() - return True - else: - return False - - def restart_required(self): - if not self._ED_is_running(): - self._restart_required = False - return self._restart_required - - def logging_enabled_in_file(self, appconf): - if not isfile(appconf): - return False - - with open(appconf, 'rU') as f: - content = f.read().lower() - start = content.find('') - if start >= 0 and end >= 0: - return bool(re.search('verboselogging\s*=\s*\"1\"', content[start+8:end])) - else: - return False - - def enable_logging_in_file(self, appconf): - try: - if not exists(appconf): - with open(appconf, 'wt') as f: - f.write('\n\t\n\t\n\n') - return True - - with open(appconf, 'rU') as f: - content = f.read() - f.close() - backup = appconf[:-4] + '_backup.xml' - if exists(backup): - unlink(backup) - rename(appconf, backup) - - with open(appconf, 'wt') as f: - start = content.lower().find('= 0: - f.write(content[:start+8] + '\n\t\tVerboseLogging="1"' + content[start+8:]) - else: - start = content.lower().find("") - if start >= 0: - f.write(content[:start] + '\t\n\t\n' + content[start:]) - else: - f.write(content) # eh ? - return False - - assert self._logging_enabled() - return self.logging_enabled_in_file(appconf) - except: - if __debug__: print_exc() - return False - def set_callback(self, callback): self.callback = callback @@ -232,7 +170,6 @@ class EDLogs(FileSystemEventHandler): coordinates = (float(x), float(y), float(z)) if system: - self._restart_required = False # clearly logging is working # Convert local time string to UTC date and time visited_struct = strptime(visited, '%H:%M:%S') now = localtime() @@ -266,19 +203,6 @@ class EDLogs(FileSystemEventHandler): else: return None - def _logging_enabled(self): - return self.logdir and self.logging_enabled_in_file(join(self.logdir, pardir, 'AppConfigLocal.xml')) - - def _enable_logging(self): - return self.logdir and self.enable_logging_in_file(join(self.logdir, pardir, 'AppConfigLocal.xml')) - - def _ED_is_running(self): - for x in NSWorkspace.sharedWorkspace().runningApplications(): - if x.bundleIdentifier() == 'uk.co.frontier.EliteDangerous': - return True - else: - return False - elif platform=='win32': def _logdir(self): @@ -354,31 +278,10 @@ class EDLogs(FileSystemEventHandler): return None - def _logging_enabled(self): - return self.logdir and (self.logging_enabled_in_file(join(self.logdir, pardir, 'AppConfigLocal.xml')) or - self.logging_enabled_in_file(join(self.logdir, pardir, 'AppConfig.xml'))) - - def _enable_logging(self): - return self.logdir and self.enable_logging_in_file(isfile(join(self.logdir, pardir, 'AppConfigLocal.xml')) and join(self.logdir, pardir, 'AppConfigLocal.xml') or join(self.logdir, pardir, 'AppConfig.xml')) - - def _ED_is_running(self): - retval = DWORD(0) - EnumWindows(EnumWindowsProc, ctypes.addressof(retval)) - return bool(retval) - elif platform=='linux2': def _logdir(self): return None - def _logging_enabled(self): - return False - - def _enable_logging(self): - return False - - def _ED_is_running(self): - return False - # singleton monitor = EDLogs() diff --git a/prefs.py b/prefs.py index d79e59bb..22244752 100644 --- a/prefs.py +++ b/prefs.py @@ -303,24 +303,12 @@ class PreferencesDialog(tk.Toplevel): if monitor.logdir or proxyaddr: log = self.out_log_file.get() self.out_log_auto_button['state'] = log and tk.NORMAL or tk.DISABLED - - if log and self.out_log_auto.get(): - if proxyaddr: - self.out_log_auto_text['text'] = _('Connected to {EDPROXY} at {ADDR}').format(EDPROXY = 'edproxy', ADDR = proxyaddr) # Output settings - elif not monitor.enable_logging(): - self.out_log_auto_text['text'] = "Can't enable automatic logging!" # Shouldn't happen - don't translate - elif monitor.restart_required(): - self.out_log_auto_text['text'] = _('Re-start Elite: Dangerous to use this feature') # Output settings prompt + if log and self.out_log_auto.get() and proxyaddr: + self.out_log_auto_text['text'] = _('Connected to {EDPROXY} at {ADDR}').format(EDPROXY = 'edproxy', ADDR = proxyaddr) # Output settings self.edsm_log_auto_button['state'] = edsm_state - - if self.out_log_edsm.get() and self.out_log_auto.get(): - if proxyaddr: - self.edsm_log_auto_text['text'] = _('Connected to {EDPROXY} at {ADDR}').format(EDPROXY = 'edproxy', ADDR = proxyaddr) # Output settings - elif not monitor.enable_logging(): - self.edsm_log_auto_text['text'] = "Can't enable automatic logging!" # Shouldn't happen - don't translate - elif monitor.restart_required(): - self.edsm_log_auto_text['text'] = _('Re-start Elite: Dangerous to use this feature') # Output settings prompt + if self.out_log_edsm.get() and self.out_log_auto.get() and proxyaddr: + self.edsm_log_auto_text['text'] = _('Connected to {EDPROXY} at {ADDR}').format(EDPROXY = 'edproxy', ADDR = proxyaddr) # Output settings else: self.out_log_auto_button['state'] = tk.DISABLED self.edsm_log_auto_button['state'] = tk.DISABLED @@ -466,7 +454,6 @@ class PreferencesDialog(tk.Toplevel): # Re-enable hotkey and log monitoring before exit hotkeymgr.register(self.parent, config.getint('hotkey_code'), config.getint('hotkey_mods')) if (config.getint('output') & config.OUT_LOG_AUTO) and (config.getint('output') & (config.OUT_LOG_FILE|config.OUT_LOG_EDSM)): - monitor.enable_logging() monitor.start(self.parent) edproxy.start(self.parent) else: