1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-06-06 18:33:13 +03:00

Log monitored folder.

Appears in Mac Console or Windows temp log file.
This commit is contained in:
Jonathan Harris 2016-01-09 18:08:52 +00:00
parent 5b6c110872
commit 04cb1d7345

View File

@ -4,6 +4,7 @@ import threading
from os import listdir, pardir, rename, unlink from os import listdir, pardir, rename, unlink
from os.path import basename, exists, isdir, isfile, join from os.path import basename, exists, isdir, isfile, join
from platform import machine from platform import machine
import sys
from sys import platform from sys import platform
from time import strptime, localtime, mktime, sleep, time from time import strptime, localtime, mktime, sleep, time
from datetime import datetime from datetime import datetime
@ -235,6 +236,10 @@ class EDLogs(FileSystemEventHandler):
suffix = join('Frontier Developments', 'Elite Dangerous') suffix = join('Frontier Developments', 'Elite Dangerous')
paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True) paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True)
if len(paths) and isdir(paths[0]) and isfile(join(paths[0], suffix, 'AppNetCfg.xml')) and isdir(join(paths[0], suffix, 'Logs')): if len(paths) and isdir(paths[0]) and isfile(join(paths[0], suffix, 'AppNetCfg.xml')) and isdir(join(paths[0], suffix, 'Logs')):
if __debug__:
print 'Monitoring "%s"' % join(paths[0], suffix, 'Logs')
elif getattr(sys, 'frozen', False):
sys.stderr.write('Monitoring "%s"\n' % join(paths[0], suffix, 'Logs'))
return join(paths[0], suffix, 'Logs') return join(paths[0], suffix, 'Logs')
else: else:
return None return None
@ -267,14 +272,15 @@ class EDLogs(FileSystemEventHandler):
if not RegQueryValueEx(key, 'SteamPath', 0, ctypes.byref(valtype), None, ctypes.byref(valsize)) and valtype.value == REG_SZ: if not RegQueryValueEx(key, 'SteamPath', 0, ctypes.byref(valtype), None, ctypes.byref(valsize)) and valtype.value == REG_SZ:
buf = ctypes.create_unicode_buffer(valsize.value / 2) buf = ctypes.create_unicode_buffer(valsize.value / 2)
if not RegQueryValueEx(key, 'SteamPath', 0, ctypes.byref(valtype), buf, ctypes.byref(valsize)): if not RegQueryValueEx(key, 'SteamPath', 0, ctypes.byref(valtype), buf, ctypes.byref(valsize)):
steamlibs = [buf.value] steampath = buf.value.replace('/', '\\') # For some reason uses POSIX seperators
steamlibs = [steampath]
try: try:
# Simple-minded Valve VDF parser # Simple-minded Valve VDF parser
with open(join(buf.value, 'config', 'config.vdf'), 'rU') as h: with open(join(steampath, 'config', 'config.vdf'), 'rU') as h:
for line in h: for line in h:
vals = line.split() vals = line.split()
if vals and vals[0].startswith('"BaseInstallFolder_'): if vals and vals[0].startswith('"BaseInstallFolder_'):
steamlibs.append(vals[1].strip('"')) steamlibs.append(vals[1].strip('"').replace('\\\\', '\\'))
except: except:
pass pass
for lib in steamlibs: for lib in steamlibs:
@ -323,6 +329,11 @@ class EDLogs(FileSystemEventHandler):
if isdir(base): if isdir(base):
for d in listdir(base): for d in listdir(base):
if d.startswith(game) and isfile(join(base, d, 'AppConfig.xml')) and isdir(join(base, d, 'Logs')): if d.startswith(game) and isfile(join(base, d, 'AppConfig.xml')) and isdir(join(base, d, 'Logs')):
if __debug__:
print 'Monitoring "%s"' % join(base, d, 'Logs')
elif getattr(sys, 'frozen', False):
sys.stderr.write('Monitoring "%s"\n' % join(base, d, 'Logs'))
sys.stderr.flush()
return join(base, d, 'Logs') return join(base, d, 'Logs')
return None return None