NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

autoexec_client_core.py (8366B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\carbon\common\lib\autoexec_client_core.py
      2 from eveprefs import prefs, boot
      3 import __builtin__
      4 import os
      5 import platform
      6 import sys
      7 from . import autoexec_common
      8 import blue
      9 import bluepy
     10 from . import builtinmangler
     11 import carbon.common.script.util.numerical as numerical
     12 from . import whitelist
     13 from journey.tracker import reset_journey_id
     14 import logmodule
     15 import trinity
     16 import remotefilecache
     17 import monolithconfig
     18 import monolithhoneycomb
     19 import monolithhoneycomb_events
     20 import stackless_tracing
     21 sentry_io_dsn = os.getenv('EVE_CLIENT_SENTRY_DSN', 'https://56cd429e46214b8988ddae6a88e50ae3@sentry.io/1436728')
     22 INLINE_SERVICES = ('DB2', 'machoNet', 'config', 'objectCaching', 'dataconfig', 'dogmaIM', 'device')
     23 
     24 def Startup(appCacheDirs, userCacheDirs, servicesToRun):
     25     blue.os.sleeptime = 0
     26     InitializeRemoteFileCacheIfNeeded()
     27     args = blue.pyos.GetArg()[1:]
     28     if '/thinclient' in args:
     29         import thinclients, thinclients.clientsetup
     30         if thinclients.HEADLESS in args:
     31             thinclients.clientsetup.patch_all()
     32         elif thinclients.HEADED in args:
     33             thinclients.clientsetup.enable_live_updates()
     34             thinclients.clientsetup.install_commands()
     35         else:
     36             raise RuntimeError('Bad params.')
     37     import monolithsentry
     38     monolithsentry.init(sentry_io_dsn)
     39     monolithsentry.set_geo_tags()
     40     autoexec_common.LogStarting('Client')
     41     builtinmangler.add_system_module_extras()
     42     whitelist.InitWhitelist()
     43     import localization
     44     localization.LoadLanguageData()
     45     errorMsg = {'resetsettings': [localization.GetByLabel('UI/ErrorDialog/CantClearSettings'), localization.GetByLabel('UI/ErrorDialog/CantClearSettingsHeader'), localization.GetByLabel('UI/ErrorDialog/CantClearSettings')],
     46      'clearcache': [localization.GetByLabel('UI/ErrorDialog/CantClearCache'), localization.GetByLabel('UI/ErrorDialog/CantClearCacheHeader'), localization.GetByLabel('UI/ErrorDialog/CantClearCache')]}
     47     if not getattr(prefs, 'disableLogInMemory', 0):
     48         blue.logInMemory.capacity = 4096
     49         blue.logInMemory.Start()
     50     for clearType, clearPath in [('resetsettings', blue.paths.ResolvePath(u'settings:/')), ('clearcache', blue.paths.ResolvePath(u'cache:/'))]:
     51         if getattr(prefs, clearType, 0):
     52             if clearType == 'resetsettings':
     53                 prefs.DeleteValue(clearType)
     54             if os.path.exists(clearPath):
     55                 i = 0
     56                 while 1:
     57                     newDir = clearPath[:-1] + '_backup%s' % i
     58                     if not os.path.isdir(newDir):
     59                         try:
     60                             os.makedirs(newDir)
     61                         except:
     62                             blue.os.ShowErrorMessageBox(errorMsg[clearType][1], errorMsg[clearType][0])
     63                             bluepy.Terminate(1, errorMsg[clearType][2])
     64                             return False
     65 
     66                         break
     67                     i += 1
     68 
     69                 for filename in os.listdir(clearPath):
     70                     if filename != 'Settings':
     71                         try:
     72                             os.rename(clearPath + filename, '%s_backup%s/%s' % (clearPath[:-1], i, filename))
     73                         except:
     74                             blue.os.ShowErrorMessageBox(errorMsg[clearType][1], errorMsg[clearType][0])
     75                             bluepy.Terminate(1, errorMsg[clearType][2])
     76                             return False
     77 
     78                 prefs.DeleteValue(clearType)
     79 
     80     mydocs = blue.sysinfo.GetUserDocumentsDirectory()
     81     try:
     82         os.listdir(mydocs)
     83     except OSError as e:
     84         logmodule.general.Log('Access to {} was denied by the user, certain features may not work'.format(mydocs), logmodule.LGWARN)
     85 
     86     paths = [blue.paths.ResolvePath(u'cache:/')]
     87     for dir in appCacheDirs:
     88         paths.append(blue.paths.ResolvePath(u'cache:/') + dir)
     89 
     90     for dir in userCacheDirs:
     91         paths.append(mydocs + dir)
     92 
     93     for path in paths:
     94         try:
     95             os.makedirs(path)
     96         except OSError as e:
     97             sys.exc_clear()
     98 
     99     from carbon.common.script.sys import basesession
    100     from carbon.common.lib.session import SESSION_TYPE_GAME
    101     session = basesession.CreateSession(None, SESSION_TYPE_GAME)
    102     __builtin__.session = session
    103     __builtin__.charsession = session
    104     basesession.EnableCallTimers(2)
    105     from eve.client.script.sys.eve_exception_handler import handle_exception
    106     blue.pyos.exceptionHandler = handle_exception
    107     autoexec_common.LogStarted('Client')
    108     bluepy.frameClock = numerical.FrameClock()
    109     blue.os.frameClock = bluepy.frameClock
    110     reset_journey_id()
    111     from carbon.common.script.sys.serviceManager import ServiceManager
    112     srvMng = ServiceManager(startInline=INLINE_SERVICES)
    113     if hasattr(prefs, 'http') and prefs.http:
    114         logmodule.general.Log('Running http', logmodule.LGINFO)
    115         srvMng.Run(('http',))
    116     srvMng.Run(servicesToRun)
    117     monolithconfig.set_service_manager(srvMng)
    118     monolithhoneycomb.init(srvMng)
    119     monolithhoneycomb_events.init(srvMng)
    120     stackless_tracing.init()
    121     if boot.region == 'optic' and platform.system() == 'Windows':
    122         srvMng.StartService('eveGuardSvc')
    123     title = '[%s] %s %s %s.%s pid=%s' % (boot.region.upper(),
    124      boot.codename,
    125      boot.role,
    126      boot.version,
    127      boot.build,
    128      blue.os.pid)
    129     blue.os.SetAppTitle(title)
    130     try:
    131         blue.EnableCrashReporting(prefs.GetValue('breakpadUpload', 1) == 1)
    132     except RuntimeError:
    133         pass
    134 
    135     blue.os.frameTimeTimeout = prefs.GetValue('frameTimeTimeout', 30000)
    136     blue.os.sleeptime = 250
    137     if '/skiprun' not in args:
    138         srvMng.GetService('gameui').StartupUI(0)
    139 
    140 
    141 def _SetupClientJWT():
    142     token = None
    143     for arg in blue.pyos.GetArg()[1:]:
    144         if arg.startswith('/ssoToken'):
    145             try:
    146                 _, token = arg.split('=')
    147             finally:
    148                 break
    149 
    150 
    151 def _GetResfileServerAndIndexFromArgs():
    152     if boot.region == 'optic':
    153         resfileServer = 'http://ma79.gdl.netease.com/eve/resources/'
    154     else:
    155         resfileServer = 'https://clientresources.eveonline.com/'
    156     resfileIndices = remotefilecache.get_default_resource_index_file_list()
    157     resfileIndices = [ 'app:/' + indexfile for indexfile in resfileIndices ]
    158     if blue.os.HasStartupArg('resfileserver'):
    159         argValue = blue.os.GetStartupArgValue('resfileserver')
    160         if argValue:
    161             params = argValue.split(',')
    162             resfileServer = params[0]
    163             if len(params) > 1:
    164                 resfilepath = params[1]
    165                 resfileIndices[0] = resfilepath
    166                 split = resfilepath.split('.')
    167                 suffix = remotefilecache.ccp_platform_id()
    168                 platformRespath = split[0] + '_%s.txt' % suffix
    169                 resfileIndices[1] = platformRespath
    170     if resfileServer:
    171         if not resfileServer.startswith('http'):
    172             resfileServer = str('http://%s' % resfileServer)
    173     return (resfileIndices, resfileServer)
    174 
    175 
    176 def _GetSharedCacheFolderFromRegistry():
    177     try:
    178         return blue.win32.RegistryGetValue('HKEY_CURRENT_USER\\SOFTWARE\\CCP\\EVEONLINE', 'CACHEFOLDER', 1)
    179     except (OSError, AttributeError):
    180         return None
    181 
    182 
    183 def _SetRemoteFileCacheFolderFromArgs():
    184     folder = monolithconfig.get_value('remotefilecachefolder')
    185     if not folder:
    186         shared_cache_folder = _GetSharedCacheFolderFromRegistry()
    187         if shared_cache_folder:
    188             folder = os.path.join(shared_cache_folder, 'ResFiles')
    189         else:
    190             folder = remotefilecache.get_default_cache_folder()
    191     remotefilecache.set_cache_folder(folder)
    192 
    193 
    194 def _InitializeRemoteFileCache(resfileServer, resfileIndices):
    195     _SetRemoteFileCacheFolderFromArgs()
    196     remotefilecache.prepare(resfileIndices, resfileServer)
    197 
    198 
    199 def InitializeRemoteFileCacheIfNeeded():
    200     resfileIndices, resfileServer = _GetResfileServerAndIndexFromArgs()
    201     if resfileServer and resfileIndices:
    202         _InitializeRemoteFileCache(resfileServer, resfileIndices)
    203         logmodule.general.Log('Remote file caching enabled', logmodule.LGINFO)
    204 
    205 
    206 def StartClient(appCacheDirs, userCacheDirs, servicesToRun):
    207     t = blue.pyos.CreateTasklet(Startup, (appCacheDirs, userCacheDirs, servicesToRun), {})
    208     t.context = '^boot::autoexec_client'