Пример #1
0
 def FlushScannerState(self, reinjectSites=True):
     """
     Flush scanner data
     - probe data
     - results
     - scan meta data
     - moniker to remote object
     
     end by scattering an event to refresh UI
     """
     self.LogInfo(
         'FlushScannerState: resetting state and scattering OnScannerDisconnected'
     )
     self.probeTracker.Refresh()
     self.scanHandler = scanHandler.ScanHandler(self, sm.ScatterEvent,
                                                self.resultFilter)
     if reinjectSites:
         with util.ExceptionEater('Failure Reinjecting Anomalies'):
             self.InjectSitesAsScanResults(
                 sm.GetService(
                     'sensorSuite').probeScannerController.GetAllSites())
     self.remoteObject = None
     sm.StartService('audio').SendUIEvent(
         unicode('wise:/msg_scanner_moving_stop'))
     sm.StartService('audio').SendUIEvent(
         unicode('wise:/msg_scanner_analyzing_stop'))
     sm.ScatterEvent('OnScannerDisconnected')
Пример #2
0
    def DoSimClockRebase(self, times):
        oldSimTime, newSimTime = times
        offset = newSimTime - oldSimTime
        for activation in self.activations.itervalues():
            activation.stamp += offset
            for trigger in activation.triggers:
                with util.ExceptionEater('Adjusting time on an FX trigger'):
                    trigger.stamp += offset
                    if trigger.startTime:
                        trigger.startTime += offset

        for triggerList in self.delayedtriggers.itervalues():
            for trigger in triggerList:
                with util.ExceptionEater('Adjusting time on a delayed FX trigger'):
                    if trigger.startTime:
                        trigger.startTime += offset
Пример #3
0
 def OnClick(self, *args):
     if self.clickFunc:
         if self.clickArgs:
             self.clickFunc(*self.clickArgs)
         else:
             self.clickFunc()
         with util.ExceptionEater('eventLog'):
             sm.ProxySvc('eventLog').LogClientEvent('tutorial', ['templateName', 'functionName'], 'ScreenActionClick', self.currentTemplate.__class__.__name__, self.clickFunc.__name__)
    def CloseByUser(self, *args):
        tutorialSvc = sm.GetService('tutorial')
        tut = tutorialSvc.GetCurrentTutorial()
        if tut is not None:
            if hasattr(self, 'startTime'):
                totaltime = (blue.os.GetWallclockTime() - self.startTime) / const.SEC
            else:
                totaltime = 0
            timeSpentInPage = (blue.os.GetWallclockTime() - tutorialSvc.pageTime) / const.SEC
            try:
                numClicks = uicore.uilib.GetGlobalClickCount() - tutorialSvc.numMouseClicks
                numKeys = uicore.uilib.GetGlobalKeyDownCount() - tutorialSvc.numKeyboardClicks
            except:
                numClicks = numKeys = 0

            if not getattr(self, 'done', 0):
                tutorialSvc.SetSequenceStatus(tut.sequenceID, tut.tutorialID, tut.pageNo, 'aborted')
                with util.ExceptionEater('eventLog'):
                    tutorialSvc.LogTutorialEvent(['tutorialID',
                     'pageNo',
                     'sequenceID',
                     'timeInTutorial',
                     'numMouseClicks',
                     'numKeyboardClicks',
                     'reason',
                     'timeInPage'], 'Closed', tut.tutorialID, tut.pageNo, tut.sequenceID, totaltime, numClicks, numKeys, 'aborted', timeSpentInPage)
            else:
                tutorialSvc.SetSequenceStatus(tut.sequenceID, tut.tutorialID, tut.pageNo, 'done')
                with util.ExceptionEater('eventLog'):
                    tutorialSvc.LogTutorialEvent(['tutorialID',
                     'pageNo',
                     'sequenceID',
                     'timeInTutorial',
                     'numMouseClicks',
                     'numKeyboardClicks',
                     'reason',
                     'timeInPage'], 'Closed', tut.tutorialID, tut.pageNo, tut.sequenceID, totaltime, numClicks, numKeys, 'done', timeSpentInPage)
        tutorialSvc.Cleanup()
        if settings.char.windows.Get('tutorialShouldAutoReszie', 1):
            self.display = False
            cw, currentClipperHeight = self.sr.browser.sr.clipper.GetAbsoluteSize()
            self.ChangeWindowHeight(currentClipperHeight, self.defaultClipperHeight)
            self.RegisterPositionAndSize()
        self.Close()
        if getattr(self, 'showTutorialReminder', True):
            uthread.new(self._TutorialReminder)
Пример #5
0
 def _DelayedStart(self):
     with util.ExceptionEater('JumpTransitionTunnelStart'):
         self.DoCameraLookAnimation()
         self._PlayInitSequence()
         blue.synchro.SleepSim(self.initToStartDelay)
         self.FadeUIOut()
         self._PlayTunnelSequence()
         self._PlayMidTransitionCurves()
Пример #6
0
 def Update(self):
     while True:
         blue.synchro.Yield()
         if self.ship and self.controls and self.callback:
             with util.ExceptionEater('FlightSimulation'):
                 self.AttachBalls()
                 self.ProcessInput()
                 self.UpdateDirection()
                 self.TriggerCallback()
Пример #7
0
    def ExpandGroupBeans(self, compressedGroupBeans):
        if isinstance(compressedGroupBeans, dict):
            return compressedGroupBeans
        res = None
        try:
            res = blue.marshal.Load(zlib.decompress(compressedGroupBeans))
        except (UnmarshalError, zlib.error):
            firstBit = '<error encoding>'
            with util.ExceptionEater('Encoding some badness in the beancounter'):
                firstBit = base64.b64encode(compressedGroupBeans[:1000])
            self.LogError('BeanDelivery recieved a non-standard bean payload, likely not exefile in origin.  Session:', repr(session), 'First 1000char of compressed payload:', firstBit)
            log.LogException('BeanDelivery recieved a non-standard bean payload')
            with util.ExceptionEater('Reporting BeanDelivery error to Alert'):
                message = 'The following session sent us a set of Beans that are probably all attacky:\n%s\n\n' % (repr(session),)
                message += 'The compressed payload follows (base64 encoded):\n%s' % (base64.b64encode(compressedGroupBeans),)
                self.Alert('BeanDelivery', 'Non-standard BeanCounting payload', message)

        return res
Пример #8
0
 def DisableDistrict(self, districtID = None):
     if districtID and self.district and districtID != self.district['districtID']:
         return
     with util.ExceptionEater('DisconnectDistrict'):
         self.DisconnectDistrict()
     if self.brackets:
         self.brackets.Close()
     self.brackets = None
     self.district = None
     self.battle = None
Пример #9
0
    def ValidateInstallJumpClone(self):
        error_labels = self.GetLM().ValidateInstallJumpClone()
        errors = []
        for label in error_labels:
            if isinstance(label, basestring):
                errors.append(localization.GetByLabel(label))
            else:
                with util.ExceptionEater():
                    label, args = label
                    print label, args
                    errors.append(localization.GetByLabel(label, **args))

        return errors
Пример #10
0
 def SetOff(self, reason=''):
     if self.autopilot == 0:
         self.KillTimer()
         return
     sm.ScatterEvent('OnAutoPilotOff')
     self.autopilot = 0
     if reason == '  - waypoint reached':
         eve.Message('AutoPilotWaypointReached')
     elif reason == '  - no destination path set':
         eve.Message('AutoPilotDisabledNoPathSet')
     else:
         eve.Message('AutoPilotDisabled')
     self.LogNotice('Autopilot Disabled', reason)
     with util.ExceptionEater('eventLog'):
         starmapSvc = sm.GetService('starmap')
         numSeconds = (blue.os.GetWallclockTimeNow() -
                       self.enabledTimestamp) / const.SEC
         uthread.new(self.DoLogAutopilotEvent, ['secondsEnabled', 'reason'],
                     'Disabled', numSeconds, reason)
     self.enabledTimestamp = 0
Пример #11
0
 def OnMouseUp(self, button, *args):
     """
         on releasing the mouse we either select the option that has been highlighted
     """
     uicore.uilib.UnclipCursor()
     self.cursorClipped = False
     radialMenuBtn = self.GetRadialMenuButton()
     actionName = 'NoAction'
     rangeValue = 0
     if radialMenuBtn == button and self.selectedBtn:
         with util.ExceptionEater('Radial Menu Action Log'):
             actionName = self.selectedBtn.actionButton.labelPath.split(
                 '/')[-1]
             rangeValue = getattr(self.selectedBtn.actionButton,
                                  'currentRange', 0)
         self.ClickButton(self.selectedBtn)
     else:
         self.CloseWithoutActionCallback(button)
         self.Close()
     spaceRadialMenuFunctions.LogRadialMenuEvent(actionName, rangeValue)
Пример #12
0
 def SetOn(self):
     if self.autopilot == 1:
         return
     if not util.InShip():
         return
     self.autopilot = 1
     if not sm.GetService('machoNet').GetGlobalConfig().get(
             'newAutoNavigationKillSwitch', False):
         self.CancelSystemNavigation()
     else:
         self.AbortApproachAndTryCommand()
         self.AbortWarpAndTryCommand()
     sm.ScatterEvent('OnAutoPilotOn')
     eve.Message('AutoPilotEnabled')
     self.KillTimer()
     self.StartTimer()
     self.LogNotice('Autopilot Enabled')
     self.enabledTimestamp = blue.os.GetWallclockTimeNow()
     with util.ExceptionEater('eventLog'):
         starmapSvc = sm.GetService('starmap')
         waypoints = starmapSvc.GetWaypoints()
         routeData = starmapSvc.GetAutopilotRoute()
         routeData = routeData or []
         solarSystemIDs = ','.join([str(s) for s in routeData])
         routeType = starmapSvc.GetRouteType()
         avoidPodKill = settings.char.ui.Get('pfAvoidPodKill', 0)
         stopAtEachWaypoint = settings.user.ui.Get(
             'autopilot_stop_at_each_waypoint', False)
         avoidSystems = settings.char.ui.Get('pfAvoidSystems', True)
         avoidanceItems = self.clientPathfinderService.GetAvoidanceItems()
         securityPenalty = settings.char.ui.Get('pfPenalty', 50.0)
         uthread.new(self.DoLogAutopilotEvent, [
             'numWaypoints', 'numJumps', 'routeType', 'avoidSystems',
             'avoidanceItems', 'securityPenalty', 'avoidPodKill',
             'stopAtEachWaypoint', 'destinationID', 'celestialID...'
         ], 'Enabled', len(waypoints), len(routeData), routeType,
                     avoidSystems,
                     ','.join([str(i) for i in avoidanceItems]),
                     securityPenalty, avoidPodKill, stopAtEachWaypoint,
                     waypoints[-1], solarSystemIDs)
Пример #13
0
 def Stop(self):
     self.ending = True
     if self.cameraLookAnimation is not None:
         self.cameraLookAnimation.Stop()
     with util.ExceptionEater('JumpTransitionTunnelEnd'):
         if not self.destinationSceneApplied:
             self.transition.ApplyDestinationScene()
         camSvc = sm.GetService('camera')
         anim = camSvc.animationController
         offset = geo2.Vec3Scale(self.normDir, -self.camOffsetEnd)
         anim.Schedule(transitioncam.InExtraTransl(self.endCamDurationS, offset))
         anim.Schedule(transitioncam.InFOV(self.endCamDurationS))
         camSvc.shakeController.DoCameraShake(self.shakeJumpIn)
     if self.startCS is not None:
         self.startCS.Stop()
     if self.mainCS is not None:
         self.mainCS.Stop()
     if self.stopCS is not None:
         self.stopCS.Play()
     self.FadeUIIn()
     uthread.new(self.BlinkSystemName)
     uthread.new(self._DelayedCleanup)
Пример #14
0
    def ClockSyncDaemon(self):
        syncRateMS = 300000
        while self.IsConnected():
            with util.ExceptionEater('Exception during soft clock sync'):
                blue.synchro.SleepWallclock(syncRateMS)
                log.LogInfo('*** Soft Clock Sync Starting ***')
                results = []
                numPings = 5
                blue.os.timeSyncAdjust = 0
                for i in xrange(numPings):
                    myTime = blue.os.GetWallclockTimeNow()
                    serverTime = sm.ProxySvc('machoNet').GetTime()
                    now = blue.os.GetWallclockTimeNow()
                    elaps = now - myTime
                    serverTime += elaps / 2
                    diff = float(now - serverTime)
                    results.append((elaps, diff))
                    log.LogInfo('SoftClock:', elaps, diff)

                averageElaps = sum([x[0] for x in results]) / numPings
                results = filter(lambda x: x[0] < averageElaps * 1.2, results)
                log.LogInfo('SoftClock results:', results)
                avgDiff = sum([x[1] for x in results]) / len(results)
                log.LogInfo('*** Soft Clock Sync adjusting by',
                            -avgDiff / const.SEC, 'seconds')
                blue.os.timeSyncAdjust = long(-avgDiff)
                if abs(avgDiff) > 3 * const.SEC:
                    log.LogError(
                        'Having to adjust more than 3 seconds in a single timesync interval! (%fs per %ds)'
                        % (avgDiff / float(const.SEC), syncRateMS / 1000))
                    syncRateMS = max(60000, syncRateMS - 60000)
                else:
                    syncRateMS = min(300000, syncRateMS + 60000)
                driftFactor = abs(avgDiff) / float(syncRateMS * const.MSEC)
                driftFactor = min(0.95, max(0.02, driftFactor))
                blue.os.timeSyncAdjustFactor = driftFactor
    def LoadTutorial(self, tutorialID = None, pageNo = None, pageID = None, sequenceID = None, force = 0, VID = None, skipCriteria = False, checkBack = 0, diffMouseClicks = 0, diffKeyboardClicks = 0):
        self.sr.browser.scrollEnabled = 0
        self.backBtn.state = uiconst.UI_HIDDEN
        self.nextBtn.state = uiconst.UI_HIDDEN
        self.backBtn.Blink(0)
        self.nextBtn.Blink(0)
        self.sr.text.text = ''
        self.done = 0
        self.reverseBack = 0
        imagePath = None
        pageCount = None
        body = '\n            <html>\n            <head>\n            <LINK REL="stylesheet" TYPE="text/css" HREF="res:/ui/css/tutorial.css">\n            </head>\n            <body>'
        tutData = None
        if VID:
            tutData = sm.RemoteSvc('tutorialSvc').GetTutorialInfo(VID)
        elif tutorialID:
            tutData = sm.GetService('tutorial').GetTutorialInfo(tutorialID)
        if tutData:
            fadeOut = uicore.animations.FadeOut(self.sr.browser.sr.clipper, duration=0.05, loops=1, curveType=2, callback=None, sleep=False)
            if self and self.destroyed:
                return
            pageCount = len(tutData.pages)
            if pageNo == -1:
                pageNo = pageCount
            else:
                pageNo = pageNo or 1
            if pageNo > pageCount:
                log.LogWarn('Open Tutorial Page Failed:, have page %s but max %s pages. falling back to page 1 :: tutorialID: %s, sequenceID: %s, VID: %s' % (pageNo,
                 pageCount,
                 tutorialID,
                 sequenceID,
                 VID))
                pageNo = 1
            with util.ExceptionEater('eventLog'):
                sm.GetService('tutorial').LogTutorialEvent(['tutorialID', 'pageNo', 'openedByUser'], 'OpenTutorial', tutorialID, pageNo, force)
            dispPageNo, dispPageCount = pageNo, pageCount
            pageData = tutData.pages[pageNo - 1]
            caption = self.captionText
            loop = 1
            while 1:
                captionTextParts = localization.GetByMessageID(tutData.tutorial[0].tutorialNameID).split(':')
                if len(captionTextParts) > 1:
                    tutorialNumber = captionTextParts[0]
                    rest = ':'.join(captionTextParts[1:]).strip()
                    captionText = '%s: %s' % (tutorialNumber, rest)
                else:
                    captionText = localization.GetByMessageID(tutData.tutorial[0].tutorialNameID)
                caption.text = captionText
                if pageData and pageData.pageNameID:
                    self.subcaption.text = localization.GetByMessageID(pageData.pageNameID)
                    self.subcaption.state = uiconst.UI_DISABLED
                else:
                    self.subcaption.state = uiconst.UI_HIDDEN
                if caption.textheight < 52 or not loop:
                    break
                caption.fontsize = 13
                caption.letterspace = 0
                caption.last = (0, 0)
                loop = 0

            if sequenceID:
                check = []
                seqTutData = sm.GetService('tutorial').GetTutorialInfo(tutorialID)
                for criteria in seqTutData.criterias:
                    cd = sm.GetService('tutorial').GetCriteria(criteria.criteriaID)
                    if cd is None:
                        continue
                    check.append(criteria)

                closeToEnd = 0
                for criteria in seqTutData.pagecriterias:
                    if criteria.pageID == pageData.pageID:
                        check.append(criteria)
                        closeToEnd = 1
                    elif not closeToEnd:
                        cd = sm.GetService('tutorial').GetCriteria(criteria.criteriaID)
                        if cd is None:
                            continue
                        if not cd.criteriaName.startswith('rookieState'):
                            continue
                        check.append(criteria)

                actionData = seqTutData.actions
                pageActionData = seqTutData.pageactions
            else:
                check = [ c for c in tutData.criterias ]
                for criteria in tutData.pagecriterias:
                    if criteria.pageID == pageData.pageID:
                        check.append(criteria)

                actionData = tutData.actions
                pageActionData = tutData.pageactions
            actions = [ sm.GetService('tutorial').GetAction(action.actionID) for action in actionData ]
            actions += [ sm.GetService('tutorial').GetAction(action.actionID) for action in pageActionData if action.pageID == pageData.pageID ]
            preRookieState = eve.rookieState
            if skipCriteria:
                criteriaCheck = None
            else:
                criteriaCheck = sm.GetService('tutorial').ParseCriterias(check, 'tut', self, tutorialID)
            if not self or getattr(self, 'sr', None) is None:
                return
            if criteriaCheck:
                if preRookieState:
                    eve.SetRookieState(preRookieState)
                body += '<br>' + localization.GetByMessageID(criteriaCheck.messageTextID)
                with util.ExceptionEater('eventLog'):
                    sm.GetService('tutorial').LogTutorialEvent(['tutorialID',
                     'pageNo',
                     'sequenceID',
                     'clickedByUser',
                     'errorMessageID',
                     'numMouseClicks',
                     'numKeyboardClicks'], 'CriteriaNotMet', tutorialID, pageNo, sequenceID, force, criteriaCheck.messageTextID, diffMouseClicks, diffKeyboardClicks)
                if pageNo > 1 or sequenceID and sm.GetService('tutorial').GetNextInSequence(tutorialID, sequenceID, -1):
                    self.backBtn.state = uiconst.UI_NORMAL
                if sm.GetService('tutorial').waitingForWarpConfirm == False:
                    self.nextBtn.state = uiconst.UI_NORMAL
                    self.nextBtn.OnClick = sm.GetService('tutorial').Reload
                    self.Confirm = sm.GetService('tutorial').Reload
                    self.nextBtn.SetLabel(localization.GetByLabel('UI/Commands/Next'))
                    self.sr.text.text = ''
                self.backBtn.OnClick = self.backFunc
                if checkBack:
                    self.reverseBack = 1
            else:
                sm.GetService('tutorial').ParseActions(actions)
                self.sr.text.text = localization.GetByLabel('UI/Tutorial/PageOf', num=dispPageNo, total=dispPageCount)
                if pageNo > 1 or sequenceID and sm.GetService('tutorial').GetNextInSequence(tutorialID, sequenceID, -1):
                    self.backBtn.state = uiconst.UI_NORMAL
                sm.GetService('tutorial').SetCriterias(check)
                if pageData:
                    page = pageData
                    body += '%s' % localization.GetByMessageID(page.textID)
                    self.nextBtn.state = uiconst.UI_NORMAL
                    self.nextBtn.OnClick = self.nextFunc
                    self.Confirm = self.nextFunc
                    self.backBtn.OnClick = self.backFunc
                    if pageNo < pageCount or sequenceID and sm.GetService('tutorial').GetNextInSequence(tutorialID, sequenceID):
                        self.nextBtn.SetLabel(localization.GetByLabel('UI/Commands/Next'))
                    else:
                        self.nextBtn.SetLabel(localization.GetByLabel('UI/Commands/Done'))
                        self.done = 1
                    imagePath = page.imagePath
                else:
                    body += '\n                        Page %s was not found in this tutorial.\n                        ' % pageNo
        else:
            self.captionText.text = localization.GetByLabel('UI/Tutorial/EveTutorials')
            body = '%s %s' % (localization.GetByLabel('UI/Tutorial/UnknownTutorial'), tutorialID)
        body += '</body></html>'
        blue.pyos.synchro.Yield()
        self.CheckTopHeight()
        self.LoadHTML('', newThread=0)
        if self.state == uiconst.UI_HIDDEN:
            self.Maximize()
        if imagePath:
            self.LoadImage(imagePath)
            self.sr.browser.left = self.img.width
        else:
            if self.imgpar.state != uiconst.UI_HIDDEN:
                self.imgpar.state = uiconst.UI_HIDDEN
            self.sr.browser.left = const.defaultPadding
        blue.pyos.synchro.Yield()
        goodies = sm.RemoteSvc('tutorialLocationSvc').GetTutorialGoodies(tutorialID, pageID, pageNo)
        goodieHtml = self.LoadAndGiveGoodies(goodies, tutorialID, pageID, pageNo)
        if goodieHtml:
            body += '<br>%s' % goodieHtml
        self.LoadHTML(body, newThread=0)
        self.SetCaption(localization.GetByLabel('UI/Tutorial/EveTutorials'))
        if not hasattr(self, 'startTime') or not hasattr(self, 'current') or self.current.sequenceID != sequenceID:
            self.startTime = blue.os.GetWallclockTime()
        tutorialPageState = TutorialPageState(tutorialID, pageNo, pageID, pageCount, sequenceID, VID, pageData.pageActionID)
        settings.char.generic.Set('tutorialPageState', tuple(tutorialPageState))
        settings.char.generic.Delete('tutorialCompleted')
        self.current = tutorialPageState
        if sequenceID:
            if self.done:
                sm.GetService('tutorial').SetSequenceStatus(sequenceID, tutorialID, pageNo, 'done')
            else:
                sm.GetService('tutorial').SetSequenceStatus(sequenceID, tutorialID, pageNo)
            if not sm.GetService('tutorial').CheckTutorialDone(sequenceID, tutorialID):
                sm.GetService('tutorial').SetSequenceDoneStatus(sequenceID, tutorialID, pageNo)
        for page in tutData.pages:
            if page.pageID == pageID or page.pageNumber == pageNo:
                if not criteriaCheck:
                    translatedText = localization.GetByMessageID(page.uiPointerTextID)
                    sm.GetService('uipointerSvc').PointTo(page.uiPointerID, translatedText)
                    break

        fadeOut.Stop()
        uicore.animations.FadeIn(self.sr.browser.sr.clipper, endVal=1.0, duration=0.3, loops=1, curveType=2, callback=None, sleep=False)
        self.CheckHeight()
Пример #16
0
 def _LogWindowOpened(self):
     with util.ExceptionEater('eventLog'):
         uthread.new(
             sm.ProxySvc('eventLog').LogClientEvent, 'trial',
             ['origin', 'reason'], 'ShowUpsellWindow', self.origin,
             self.reason)
Пример #17
0
    def LogClientCall(self, session, objectName, method, args, kwargs):
        with util.ExceptionEater('LogClientCall'):

            def CleanKeywordArgs(kwargs):
                cleanKwargs = {}
                if kwargs:
                    cleanKwargs = {
                        k: v
                        for k, v in kwargs.iteritems() if k != 'machoVersion'
                    }
                return cleanKwargs

            excludedMethods = ['GetTime']
            if method in excludedMethods:
                return
            logAll = self.logAllClientCalls
            if logAll is None and prefs.clusterMode == 'LOCAL':
                logAll = 1
            if logAll:
                self.clientCallLogChannel = log.Channel(
                    str(macho.mode), 'ClientCalls')
                callerInfo = 'User %s' % session.userid
                try:
                    callerInfo = 'Char %s (%s)' % (
                        session.charid, cfg.eveowners.Get(session.charid).name)
                except:
                    pass

                kwargsTxt = ''
                if kwargs:
                    kk = CleanKeywordArgs(kwargs)
                    if kk:
                        kwargsTxt = '. kwargs = %s' % repr(kk)
                self.clientCallLogChannel.Log(
                    '%s called %s.%s%s%s' %
                    (callerInfo, objectName, method, repr(args)[:128],
                     kwargsTxt[:128]), log.LGNOTICE)
            if not self.sessionWatchIDs:
                return
            charID = getattr(session, 'charid', None)
            if not charID:
                return
            userID = getattr(session, 'userid', None)
            corpID = getattr(session, 'corpid', None)
            userType = getattr(session, 'userType', None)
            solarSystemID = getattr(session, 'solarsystemid2', None)
            logIt = False
            if userID in self.sessionWatchIDs[0]:
                logIt = True
            elif charID in self.sessionWatchIDs[1]:
                logIt = True
            elif corpID in self.sessionWatchIDs[2]:
                logIt = True
            elif userType in self.sessionWatchIDs[3]:
                logIt = True
            elif session.role & ROLEMASK_ELEVATEDPLAYER:
                logIt = True
            if logIt:
                a = repr(args)
                k = repr(CleanKeywordArgs(kwargs))
                sm.GetService('eventLog').LogOwnerEvent(
                    'ClientCall', charID, solarSystemID, userID, objectName,
                    method, len(a), a[:1024], len(k), k[:1024])
Пример #18
0
 def _LogStoreEvent(self, columnNames, eventName, *args):
     with util.ExceptionEater('eventLog'):
         uthread.new(
             sm.ProxySvc('eventLog').LogClientEvent, 'store', columnNames,
             eventName, *args)
Пример #19
0
    def LogClientCall(self, session, objectName, method, args, kwargs):
        with util.ExceptionEater('LogClientCall'):

            def CleanKeywordArgs(kwargs):
                if not kwargs or 'machoVersion' not in kwargs:
                    return kwargs
                cleanKwargs = kwargs.copy()
                del cleanKwargs['machoVersion']
                return cleanKwargs

            excludedMethods = ['GetTime']
            if method in excludedMethods:
                return
            charID = getattr(session, 'charid', None)
            userID = getattr(session, 'userid', None)
            solarSystemID = getattr(session, 'solarsystemid2', None)
            argString = None
            if self.eventLog.IsChannelOpen('security'):
                argString = repr(args)
                kwargString = repr(CleanKeywordArgs(kwargs))
                self.eventLog.LogOwnerEvent('ClientCall',
                                            charID,
                                            solarSystemID,
                                            userID,
                                            objectName,
                                            method,
                                            len(argString),
                                            argString[:1024],
                                            len(kwargString),
                                            kwargString[:1024],
                                            eventLogChannel='security')
            logAll = self.logAllClientCalls
            if logAll is None and prefs.clusterMode == 'LOCAL':
                logAll = 1
            if logAll:
                self.clientCallLogChannel = log.Channel(
                    str(macho.mode), 'ClientCalls')
                callerInfo = 'User %s' % session.userid
                try:
                    callerInfo = 'Char %s (%s)' % (
                        session.charid, cfg.eveowners.Get(session.charid).name)
                except:
                    pass

                kwargsTxt = ''
                if kwargs:
                    kk = CleanKeywordArgs(kwargs)
                    if kk:
                        kwargsTxt = '. kwargs = %s' % repr(kk)
                self.clientCallLogChannel.Log(
                    '%s called %s.%s%s%s' %
                    (callerInfo, objectName, method, repr(args)[:128],
                     kwargsTxt[:128]), log.LGNOTICE)
            if not self.sessionWatchIDs:
                return
            if not charID:
                return
            corpID = getattr(session, 'corpid', None)
            userType = getattr(session, 'userType', None)
            logIt = False
            if userID in self.sessionWatchIDs[0]:
                logIt = True
            elif charID in self.sessionWatchIDs[1]:
                logIt = True
            elif corpID in self.sessionWatchIDs[2]:
                logIt = True
            elif userType in self.sessionWatchIDs[3]:
                logIt = True
            elif session.role & ROLEMASK_ELEVATEDPLAYER:
                logIt = True
            if logIt:
                if argString is None:
                    argString = repr(args)
                    kwargString = repr(CleanKeywordArgs(kwargs))
                self.eventLog.LogOwnerEvent('ClientCall', charID,
                                            solarSystemID,
                                            userID, objectName, method,
                                            len(argString), argString[:1024],
                                            len(kwargString),
                                            kwargString[:1024])
                self.eventLog.LogOwnerEventJson('ClientCall',
                                                charID,
                                                solarSystemID,
                                                userID=userID,
                                                objectName=objectName,
                                                method=method,
                                                argsLen=len(argString),
                                                args=argString[:1024],
                                                kwargsLen=len(kwargString),
                                                kwargs=kwargString[:1024])
Пример #20
0
 def GetPilotsInSystem(self):
     channelID = (('solarsystemid2', session.solarsystemid2), )
     with util.ExceptionEater(
             'SetDynamicMusicSwitch - Getting channel membercount'):
         return sm.GetService('LSC').GetMemberCount(channelID)
     return 0