mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-13 15:57:14 +03:00
Remove code to enable VerboseLogging
No longer required
This commit is contained in:
parent
291dcbf7dd
commit
a3edf805bb
@ -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()
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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} を再起動してください";
|
||||
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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.";
|
||||
|
||||
|
@ -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}, чтобы использовать сочетание клавиш";
|
||||
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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} для використання ярликів";
|
||||
|
||||
|
97
monitor.py
97
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('<network')
|
||||
end = content.find('</network>')
|
||||
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('<AppConfig>\n\t<Network\n\t\tVerboseLogging="1"\n\t>\n\t</Network>\n</AppConfig>\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('<network')
|
||||
if start >= 0:
|
||||
f.write(content[:start+8] + '\n\t\tVerboseLogging="1"' + content[start+8:])
|
||||
else:
|
||||
start = content.lower().find("</appconfig>")
|
||||
if start >= 0:
|
||||
f.write(content[:start] + '\t<Network\n\t\tVerboseLogging="1"\n\t>\n\t</Network>\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()
|
||||
|
21
prefs.py
21
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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user