Esempio n. 1
0
    def _UpdateCrashKeyValues(self):
        """
        This function sits an infinite loop, periodically updating some meta
        data for the crash reporting. It's called from a thread when this service
        starts.
        """
        self.LogInfo('UpdateCrashKeyValues loop starting')
        stats = []
        try:
            serverInfo = login.GetServerInfo()
            blue.SetCrashKeyValues(u'serverName', unicode(serverInfo.name))
            blue.SetCrashKeyValues(u'serverIP', unicode(serverInfo.IP))
        except:
            log.LogException()

        statNames = [
            'Blue/Memory/Malloc', 'Blue/Memory/Python',
            'Blue/Memory/PageFileUsage', 'Blue/Memory/WorkingSet'
        ]
        for each in statNames:
            s = blue.statistics.Find(each)
            if s:
                stats.append(s)

        while self.state == SERVICE_RUNNING:
            for each in stats:
                blue.SetCrashKeyValues(unicode(each.name), unicode(each.value))

            blue.SetCrashKeyValues(u'Trinity_shader_model',
                                   unicode(trinity.GetShaderModel()))
            blue.synchro.SleepWallclock(5000)
Esempio n. 2
0
    def _UpdateCrashKeyValues(self):
        self.LogInfo('UpdateCrashKeyValues loop starting')
        stats = []
        try:
            serverInfo = login.GetServerInfo()
            blue.SetCrashKeyValues(u'serverName', unicode(serverInfo.name))
            blue.SetCrashKeyValues(u'serverIP', unicode(serverInfo.IP))
            blue.SetCrashKeyValues(
                u'IsRunningWithOptionalUpgrade',
                unicode(nasty.IsRunningWithOptionalUpgrade()))
        except:
            log.LogException()

        statNames = [
            'Blue/Memory/Malloc', 'Blue/Memory/Python',
            'Blue/Memory/PageFileUsage', 'Blue/Memory/WorkingSet'
        ]
        for each in statNames:
            s = blue.statistics.Find(each)
            if s:
                stats.append(s)

        while self.state == SERVICE_RUNNING:
            for each in stats:
                blue.SetCrashKeyValues(unicode(each.name), unicode(each.value))

            blue.SetCrashKeyValues(u'Trinity_shader_model',
                                   unicode(trinity.GetShaderModel()))
            blue.synchro.SleepWallclock(5000)
Esempio n. 3
0
 def SampleStats(self, state):
     self.currentState = state
     try:
         uthread.Lock(self, 'sampleStats')
         if self.entries.has_key(state):
             stats = self.entries[state]
         else:
             stats = {}
         lastStageSampleTime = self.lastStageSampleTime
         self.lastStageSampleTime = time.clock()
         stats[STAT_TIME_SINCE_LAST_STATE] = int((self.lastStageSampleTime - lastStageSampleTime) * 1000)
         if state < STATE_GAMEEXITING:
             stats[STAT_MACHONET_AVG_PINGTIME] = self.GetMachoPingTime()
         if len(blue.pyos.cpuUsage) > 0:
             memdata = blue.pyos.cpuUsage[-1][2]
             if len(memdata) >= 2:
                 stats[STAT_PYTHONMEMORY] = memdata[0]
             else:
                 stats[STAT_PYTHONMEMORY] = 0L
         else:
             stats[STAT_PYTHONMEMORY] = 0L
         cpuProcessTime = blue.sysinfo.GetProcessTimes()
         cpuProcessTime = cpuProcessTime.userTime + cpuProcessTime.systemTime
         stats[STAT_CPU] = int(cpuProcessTime * 10000000.0)
         self.entries[state] = stats
         self.stateMask = self.stateMask + state
         if not hasattr(self, 'prevContents'):
             self.Persist()
         blue.SetCrashKeyValues(u'ClientStatsState', unicode(SHORT_STATE_STRINGS.get(state, u'Unknown')))
     except Exception as e:
         log.LogException('Error while sampling clientStats')
         sys.exc_clear()
     finally:
         uthread.UnLock(self, 'sampleStats')
 def _OpenPrimaryView(self, viewInfo, reopen = False, **kwargs):
     """
     takes care of primary view specific functionality that needs to happen when opening
     """
     blue.SetCrashKeyValues(u'ViewState', unicode(viewInfo.name))
     blue.statistics.SetTimelineSectionName(viewInfo.name)
     memorySnapshot.AutoMemorySnapshotIfEnabled(viewInfo.name)
     self._OpenView(viewInfo, reopen=reopen, **kwargs)
Esempio n. 5
0
 def _OpenPrimaryView(self,
                      viewInfo,
                      reopen=False,
                      cameraID=None,
                      **kwargs):
     blue.SetCrashKeyValues(u'ViewState', unicode(viewInfo.name))
     blue.statistics.SetTimelineSectionName(viewInfo.name)
     memorySnapshot.AutoMemorySnapshotIfEnabled(viewInfo.name)
     self._OpenView(viewInfo, reopen=reopen, cameraID=cameraID, **kwargs)
 def SampleStats(self, state):
     """
         Gathers statistics and saves them into the cache, tagged with our current running state
     """
     self.currentState = state
     try:
         uthread.Lock(self, 'sampleStats')
         if self.entries.has_key(state):
             stats = self.entries[state]
         else:
             stats = {}
         lastStageSampleTime = self.lastStageSampleTime
         self.lastStageSampleTime = blue.win32.QueryPerformanceCounter()
         stats[STAT_TIME_SINCE_LAST_STATE] = (self.lastStageSampleTime - lastStageSampleTime) / (blue.win32.QueryPerformanceFrequency() / 1000)
         if state < STATE_GAMEEXITING:
             stats[STAT_MACHONET_AVG_PINGTIME] = self.GetMachoPingTime()
         if len(blue.pyos.cpuUsage) > 0:
             memdata = blue.pyos.cpuUsage[-1][2]
             if len(memdata) >= 2:
                 stats[STAT_PYTHONMEMORY] = memdata[0]
             else:
                 stats[STAT_PYTHONMEMORY] = 0L
         else:
             stats[STAT_PYTHONMEMORY] = 0L
         cpuProcessTime = blue.win32.GetProcessTimes()
         cpuProcessTime = cpuProcessTime[2] + cpuProcessTime[3]
         stats[STAT_CPU] = cpuProcessTime
         self.entries[state] = stats
         self.stateMask = self.stateMask + state
         if not hasattr(self, 'prevContents'):
             self.Persist()
         blue.SetCrashKeyValues(u'ClientStatsState', unicode(SHORT_STATE_STRINGS.get(state, u'Unknown')))
     except Exception as e:
         log.LogException('Error while sampling clientStats')
         sys.exc_clear()
     finally:
         uthread.UnLock(self, 'sampleStats')
Esempio n. 7
0
def _StoreGPUInfoInBreakpadHeaders():
    try:
        adapterInfo = adapters.GetAdapterInfo(adapters.DEFAULT_ADAPTER)
        blue.SetCrashKeyValues(u'GPU_Description', adapterInfo.description)
        blue.SetCrashKeyValues(u'GPU_Driver', unicode(adapterInfo.driver))
        blue.SetCrashKeyValues(u'GPU_VendorId', unicode(adapterInfo.vendorID))
        blue.SetCrashKeyValues(u'GPU_DeviceId', unicode(adapterInfo.deviceID))
        blue.SetCrashKeyValues(u'trinityPlatform', unicode(platform))
        try:
            driverInfo = adapterInfo.GetDriverInfo()
            blue.SetCrashKeyValues(u'GPU_Driver_Version', unicode(driverInfo.driverVersionString))
            blue.SetCrashKeyValues(u'GPU_Driver_Date', unicode(driverInfo.driverDate))
            blue.SetCrashKeyValues(u'GPU_Driver_Vendor', unicode(driverInfo.driverVendor))
            blue.SetCrashKeyValues(u'GPU_Driver_Is_Optimus', u'Yes' if driverInfo.isOptimus else u'No')
            blue.SetCrashKeyValues(u'GPU_Driver_Is_Amd_Switchable', u'Yes' if driverInfo.isAmdDynamicSwitchable else u'No')
        except RuntimeError:
            blue.SetCrashKeyValues(u'GPU_Driver_Version', unicode(adapterInfo.driverVersion))

    except RuntimeError:
        pass
    except SystemError:
        if platform == 'dx11':
            import log
            log.Quit('Video card may not support DX11 - setting preferred platform to DX9')
Esempio n. 8
0
def LogStarted(mode):
    startedat = '%s %s version %s build %s started %s %s' % (
        boot.appname, mode, boot.version, boot.build, blue.os.FormatUTC()[0],
        blue.os.FormatUTC()[2])
    print strx(startedat)
    logmodule.general.Log(startedat, logmodule.LGINFO)
    logmodule.general.Log(startedat, logmodule.LGNOTICE)
    logmodule.general.Log(startedat, logmodule.LGWARN)
    logmodule.general.Log(startedat, logmodule.LGERR)


try:
    blue.SetBreakpadBuildNumber(GetBuildVersionAsInt())
    if blue.sysinfo.isTransgaming:
        blue.SetCrashKeyValues(u'OS', u'Mac')
    elif blue.sysinfo.isWine:
        host = blue.sysinfo.wineHostOs
        if host.startswith('Darwin'):
            platform = u'MacWine'
        else:
            platform = u'Linux'
        blue.SetCrashKeyValues(u'OS', platform)
    else:
        blue.SetCrashKeyValues(u'OS', u'Win')
except RuntimeError:
    pass

logdestination = prefs.ini.GetValue('networkLogging', '')
if logdestination:
    networklogport = prefs.ini.GetValue('networkLoggingPort', 12201)
Esempio n. 9
0
def LogStarted(mode):
    startedat = '%s %s version %s build %s started %s %s' % (
        boot.appname, mode, boot.version, boot.build, blue.os.FormatUTC()[0],
        blue.os.FormatUTC()[2])
    print strx(startedat)
    log.general.Log(startedat, log.LGINFO)
    log.general.Log(startedat, log.LGNOTICE)
    log.general.Log(startedat, log.LGWARN)
    log.general.Log(startedat, log.LGERR)


try:
    blue.SetBreakpadBuildNumber(int(boot.build))
    if blue.win32.IsTransgaming():
        blue.SetCrashKeyValues(u'OS', u'Mac')
    else:
        import ctypes
        try:
            wine = ctypes.windll.ntdll.wine_get_version
            blue.SetCrashKeyValues(u'OS', u'Linux')
        except AttributeError:
            blue.SetCrashKeyValues(u'OS', u'Win')

except RuntimeError:
    pass

if not blue.pyos.packaged:
    import walk
    for root, subdirs, files in walk.walk('resBin:/python'):
        for f in files:
Esempio n. 10
0
        SetRightHanded(True)
        settings.SetValue('geometryResNormalizeOnLoad', True)
        print 'Trinity is using a right-handed coordinate system'
    if hasattr(blue.memoryTracker, 'd3dHeap1'):
        if GetD3DCreatedHeapCount() > 0:
            blue.memoryTracker.d3dHeap1 = GetD3DCreatedHeap(0)
        if GetD3DCreatedHeapCount() > 1:
            blue.memoryTracker.d3dHeap2 = GetD3DCreatedHeap(1)
    return triPlatform


platform = _ImportDll()
adapters = blue.classes.CreateInstance('trinity.Tr2VideoAdapters')
try:
    adapterInfo = adapters.GetAdapterInfo(adapters.DEFAULT_ADAPTER)
    blue.SetCrashKeyValues(u'GPU_Description', adapterInfo.description)
    blue.SetCrashKeyValues(u'GPU_Driver', unicode(adapterInfo.driver))
    blue.SetCrashKeyValues(u'GPU_Driver_Version',
                           unicode(adapterInfo.driverVersion))
    blue.SetCrashKeyValues(u'GPU_VendorId', unicode(adapterInfo.vendorID))
    blue.SetCrashKeyValues(u'GPU_DeviceId', unicode(adapterInfo.deviceID))
except RuntimeError:
    pass
except SystemError:
    if platform == 'dx11':
        _SetPreferredPlatform('dx9')
        log.Quit(
            'Video card may not support DX11 - setting preferred platform to DX9'
        )

device = blue.classes.CreateInstance('trinity.TriDevice')
Esempio n. 11
0
        if arg.startswith('/tools='):
            containsToolParam = True
            break

    if not blue.sysinfo.isTransgaming and '/jessica' not in allArgs and not containsToolParam:
        import devenv
        sys.path.append(
            os.path.join(devenv.SHARED_TOOLS_PYTHONDIR, 'lib27xccp'))
        import packageaddwatcher
        packageaddwatcher.guard_metapath(boot.role)
    from debuggingutils.coverageutils import start_coverage_if_enabled
    start_coverage_if_enabled(prefs, blue, boot.role)
if prefs.ini.GetValue('GOPYCHARM', False):
    GOPYCHARM()
try:
    blue.SetCrashKeyValues(u'role', unicode(boot.role))
    blue.SetCrashKeyValues(u'build', unicode(boot.build))
    orgArgs = blue.pyos.GetArg()
    args = ''
    for each in orgArgs:
        if not each.startswith('/path'):
            args += each
            args += ' '

    blue.SetCrashKeyValues(u'startupArgs', unicode(args))
    bitCount = blue.sysinfo.cpu.bitCount
    computerInfo = {
        'memoryPhysical': blue.os.GlobalMemoryStatus()[1][1] / 1024,
        'cpuArchitecture': blue.pyos.GetEnv().get('PROCESSOR_ARCHITECTURE',
                                                  None),
        'cpuIdentifier': blue.pyos.GetEnv().get('PROCESSOR_IDENTIFIER', None),