def Reconstruct(self, animate = False): uthread.Lock(self) try: self.ConstructTopIcons() if animate: uicore.animations.FadeOut(self.mainCont, sleep=True, duration=0.3) self.ConstructInfoPanels() uicore.animations.FadeIn(self.mainCont, duration=0.6) finally: uthread.UnLock(self)
def GetDogmaLocation(self, charBrain=None, *args): uthread.Lock('GetDogmaLocation') try: if self.dogmaLocation is None: self.dogmaLocation = DogmaLocation(self, charBrain) self.LogInfo('Created client dogmaLocation', id(self.dogmaLocation)) finally: uthread.UnLock('GetDogmaLocation') return self.dogmaLocation
def GetMyPaperDollData(self, charID): currentCharsPaperDollData = self.currentCharsPaperDollData.get(charID, None) if currentCharsPaperDollData is not None: return currentCharsPaperDollData uthread.Lock(self) try: if self.currentCharsPaperDollData.get(charID, None) is None: self.currentCharsPaperDollData[charID] = sm.RemoteSvc('paperDollServer').GetMyPaperDollData(charID) return self.currentCharsPaperDollData.get(charID, None) finally: uthread.UnLock(self)
def LoadWorldSpaceInstance(self, instanceID, worldSpaceTypeID = None): uthread.Lock(self, 'Worldspace', instanceID) try: self.LogInfo('Loading WorldSpaceInstance') if instanceID not in self.instances: if worldSpaceTypeID is None: worldSpaceTypeID = self.GetWorldSpaceTypeIDFromWorldSpaceID(instanceID) newWorldSpace = self._LoadWorldSpaceFromServer(instanceID, worldSpaceTypeID) finally: self.LogInfo('Done loading WorldSpaceInstance') uthread.UnLock(self, 'Worldspace', instanceID)
def GetMultiJumpCounts(self, solarSystemPairs): uthread.Lock(self, 'JumpCalculation') try: ret = {} self.PrepareCache() for fromID, toID in solarSystemPairs: self.Refresh(fromID, toID) ret[fromID, toID] = self.cache[self.routeType][toID][0] return ret finally: uthread.UnLock(self, 'JumpCalculation')
def GetRecentlyChangedSkills(self): if self._recentlyChangedSkills is not None: return self._recentlyChangedSkills uthread.Lock(self, 'GetRecentlyChangedSkills') try: if self._recentlyChangedSkills is None: self._recentlyChangedSkills = sm.GetService( 'skills').GetRecentlyTrainedSkills() finally: uthread.UnLock(self, 'GetRecentlyChangedSkills') return self._recentlyChangedSkills
def ResetWindow(self, bShowIfVisible=0): uthread.Lock(self) try: self.panels = {} self.votewindows = {} self.ResetPanels() wnd = self.GetWnd() if wnd and not wnd.destroyed: wnd.Close() if bShowIfVisible: self.Show() finally: uthread.UnLock(self)
def GetSecurityStatus(self, solarSystemID, getColor=False): if self.securityInfo is None: uthread.Lock(self) try: self.securityInfo = {} for systemID, each in cfg.mapSystemCache.iteritems(): self.securityInfo[systemID] = each.pseudoSecurity finally: uthread.UnLock(self) return util.FmtSystemSecStatus( self.securityInfo.get(solarSystemID, 0.0), getColor)
def GetFittingDogmaLocation(self, force=False, *args): uthread.Lock('GetFittingDogmaLocation') try: if self.fittingDogmaLocation is None or force: from eve.client.script.ui.shared.fittingGhost.fittingDogmaLocation import FittingDogmaLocation charBrain = self._GetBrainForGhostFitting() self.fittingDogmaLocation = FittingDogmaLocation( self, charBrain=charBrain) self.LogInfo('Created client fittingDogmaLocation', id(self.fittingDogmaLocation)) finally: uthread.UnLock('GetFittingDogmaLocation') return self.fittingDogmaLocation
def OnDblClick(self, *args): if eve.rookieState and eve.rookieState < 22: return self.sr.clicktime = None solarsystemID = eve.session.solarsystemid uthread.Lock(self) try: if solarsystemID != eve.session.solarsystemid: return if self.notdbl: return if uicore.uilib.Key(uiconst.VK_SHIFT ) and eve.session.role & service.ROLE_CONTENT: return x, y = uicore.uilib.x, uicore.uilib.y if uicore.uilib.rightbtn or uicore.uilib.mouseTravel > 6: return cameraSvc = sm.GetService('camera') if cameraSvc.dungeonHack.IsFreeLook(): picktype, pickobject = self.GetPick() if pickobject: cameraSvc.LookAt(pickobject.translationCurve.id) return scene = sm.GetService('sceneManager').GetRegisteredScene('default') camera = sm.GetService('sceneManager').GetRegisteredCamera( 'default') if camera is not None: proj = camera.projectionMatrix.transform view = camera.viewMatrix.transform pickDir = scene.PickInfinity(uicore.ScaleDpi(x), uicore.ScaleDpi(y), proj, view) if pickDir: bp = sm.GetService('michelle').GetRemotePark() if bp is not None: if solarsystemID != eve.session.solarsystemid: return try: bp.CmdGotoDirection(pickDir[0], pickDir[1], pickDir[2]) sm.ScatterEvent( 'OnClientEvent_MoveWithDoubleClick') sm.GetService('menu').ClearAlignTargets() sm.GetService('flightPredictionSvc').GotoDirection( pickDir) except RuntimeError as what: if what.args[0] != 'MonikerSessionCheckFailure': raise what finally: uthread.UnLock(self)
def Index(self, colname): if self in self.__immutable__: uthread.Lock(self, '__immutable__', colname) try: if colname not in self.__immutable__[self][0]: ret = IndexRowset(self.header, self.lines, colname) self.__immutable__[self][0][colname] = ret ret.MakeImmutable() return self.__immutable__[self][0][colname] finally: uthread.UnLock(self, '__immutable__', colname) else: return IndexRowset(self.header, self.lines, colname)
def GetSecurityStatus(self, solarSystemID): if self.securityInfo is None: uthread.Lock(self) try: self.securityInfo = {} for each in cfg.solarsystems: self.securityInfo[each.solarSystemID] = each.pseudoSecurity finally: uthread.UnLock(self) if solarSystemID in self.securityInfo: return util.FmtSystemSecStatus(self.securityInfo[solarSystemID]) return 0.0
def UnloadWorldSpaceInstance(self, instanceID): if self.IsInstanceLoaded(instanceID): uthread.Lock(self, 'Worldspace', instanceID) try: if self.IsInstanceLoaded(instanceID) and (session.worldspaceid is None or session.worldspaceid and session.worldspaceid != instanceID): self.LogInfo('Unloading worldspace instance', instanceID) instance = self.instances[instanceID] proximity = sm.GetService('proximity') proximity.UnloadInstance(instance) sm.ChainEvent('ProcessWorldSpaceUnloading', instanceID) BaseWorldSpaceService.UnloadWorldSpaceInstance(self, instanceID) sm.ScatterEvent('OnWorldSpaceUnloaded', instanceID) finally: self.LogInfo('Unloaded worldspace instance', instanceID) uthread.UnLock(self, 'Worldspace', instanceID)
def Filter(self, colname, colname2 = None): if self in self.__immutable__: k = (colname, colname2) uthread.Lock(self, '__immutable__', k) try: if k not in self.__immutable__[self][1]: ret = FilterRowset(self.header, self.lines, colname, idName2=colname2) ret.MakeImmutable() self.__immutable__[self][1][k] = ret return self.__immutable__[self][1][k] finally: uthread.UnLock(self, '__immutable__', k) else: return FilterRowset(self.header, self.lines, colname, idName2=colname2)
def CryptoAPI_GetCryptoContext(): global cryptoAPI_cryptoContext if cryptoAPI_cryptoContext is not None: return cryptoAPI_cryptoContext uthread.Lock('CryptoAPI_GetCryptoContext') try: if cryptoAPI_cryptoContext is not None: return cryptoAPI_cryptoContext cryptoAPI_cryptoContext = blue.crypto.CryptAcquireContext( None, cryptoAPI_cryptoProvider, cryptoAPI_PROV_cryptoProviderType, blue.crypto.CRYPT_VERIFYCONTEXT | blue.crypto.CRYPT_SILENT) finally: uthread.UnLock('CryptoAPI_GetCryptoContext') return cryptoAPI_cryptoContext
def GetCharCreationInfo(self): if self.charCreationInfo is None: uthread.Lock(self) try: if self.charCreationInfo is None: o = uiutil.Bunch() o.update( sm.RemoteSvc('charUnboundMgr').GetCharCreationInfo()) o.update( sm.RemoteSvc( 'charUnboundMgr').GetCharNewExtraCreationInfo()) self.charCreationInfo = o finally: uthread.UnLock(self) return self.charCreationInfo
def Get(self, key, flush=0): key = int(key) if flush or not self.data.has_key(key): if boot.role != 'server': self.Prime([key]) else: uthread.Lock(self, key) try: if flush or not self.data.has_key(key): self.__LoadData(key) finally: uthread.UnLock(self, key) if self.data.has_key(key): return self.rowclass(self, key) raise KeyError('RecordNotFound', key)
def GetDogmaLocation(self, *args): """ We currently just have one dogmaLocation which is the one where you handle the ship you are in. In the future I hope to have more dogmaLocations, at least one to handle virtual ships you are not in. """ uthread.Lock('GetDogmaLocation') try: if self.dogmaLocation is None: self.dogmaLocation = dogmax.DogmaLocation(self) self.LogInfo('Created client dogmaLocation', id(self.dogmaLocation)) finally: uthread.UnLock('GetDogmaLocation') return self.dogmaLocation
def SendContentsToServer(self, contents = None): """ Transmits any data loaded in from a saved clientStats.dat file to the server. This is called shortly after authentication during the login process. """ try: if not sm.services['machoNet'].IsConnected(): return except: sys.exc_clear() return if contents is None: contents = self.prevContents if contents is None or contents[0] != self.version: contents = {} else: contents = contents[1] build = boot.GetValue('build', None) contentType = CONTENT_TYPE_PREMIUM operatingSystem = PLATFORM_WINDOWS if blue.win32.IsTransgaming(): operatingSystem = PLATFORM_MACOS blendedContents = self.entries blendedStateMask = self.stateMask self.entries = dict() self.stateMask = 0 if contents.has_key(STATE_DISCONNECT): blendedContents[STATE_DISCONNECT] = contents[STATE_DISCONNECT] blendedStateMask += STATE_DISCONNECT if contents.has_key(STATE_GAMESHUTDOWN): blendedContents[STATE_GAMESHUTDOWN] = contents[STATE_GAMESHUTDOWN] blendedStateMask += STATE_GAMESHUTDOWN header = (self.version, blendedStateMask, build, operatingSystem, contentType) data = (header, blendedContents) try: uthread.Lock(self, 'sendContents') sm.RemoteSvc('clientStatsMgr').SubmitStats(data) if hasattr(self, 'prevContents'): delattr(self, 'prevContents') return True finally: uthread.UnLock(self, 'sendContents')
def Write(self, message): if self.transport: MachoTransport.Write(self, message) try: uthread.Lock(self, 'httpReaders') if len( self.readers ) > 0 and message.command == const.cluster.MACHONETMSG_TYPE_NOTIFICATION: with bluepy.Timer( 'machoNet::StreamingHTTPMachoTransport::Write::MPT-Megahack' ): sent = False try: data = message.__getstate__() if data[0] == 12: if data[2].__getstate__()[1] == '__MultiEvent': self.LogInfo( 'Splitting __MultiEvent into multiple chunks' ) jsonMessage = json.loads( httpUtil.ToComplexJSON(data)) innerMessages = jsonMessage[4][0][1][1][1] innerMessage = (12, None, [[], None], None, [[0, [0, [1, None]]]]) with bluepy.Timer( 'machoNet::StreamingHTTPMachoTransport::Write::MPT-Megahack::Multiplex' ): for msg in innerMessages: innerMessage[2][1] = msg[0] innerMessage[4][0][1][1][1] = msg[1] for reader in self.readers: reader.write(innerMessage) sent = True except: self.LogError('MultiEvent exception', message) log.LogException() with bluepy.Timer( 'machoNet::StreamingHTTPMachoTransport::Write::Multiplex' ): if not sent: for reader in self.readers.copy(): reader.write(message) finally: uthread.UnLock(self, 'httpReaders')
def GetJumpCountFromCurrent(self, toID, locationID=None): uthread.Lock(self, 'JumpCalculation') try: self.PrepareCache() if locationID is None: locationID = eve.session.solarsystemid2 if type(toID) == types.ListType: ret = [] for systemID in toID: self.Refresh(locationID, systemID) ret.append(self.cache[self.routeType][systemID][0]) return ret self.Refresh(locationID, toID) return self.cache[self.routeType][toID][0] finally: uthread.UnLock(self, 'JumpCalculation')
def GetSecurityStatus(self, solarSystemID, getColor = False): """ returns 'pseudo' security for 'solarSystemID' in the following format: Rounds the security to the nearest one digit precision with the following exeption: 0.0 < sec < 0.05 is rounded up to 0.1 but not down to 0.0 example: 0.08 -> 0.1, -0.22 -> -0.2, 0.451 -> 0.5, 0.449 -> 0.4, -0.26 -> -0.3 """ if self.securityInfo is None: uthread.Lock(self) try: self.securityInfo = {} for systemID, each in cfg.mapSystemCache.iteritems(): self.securityInfo[systemID] = each.pseudoSecurity finally: uthread.UnLock(self) return util.FmtSystemSecStatus(self.securityInfo.get(solarSystemID, 0.0), getColor)
def GetStaticHeader(self): """ Return a bunch of information in the response header about the server if he has not authenticated yet. The reason this is only returned into the header when you are not authenticated is that this is quite a lot of data that we don't want to be shoveling out with every request. The proxy only returns a subset of the data while the server returns the whole thing. Nothing is returned on the client Most of the information here is fetched once and then stored but online user count is fetched every 5 minutes. """ uthread.Lock('http.GetStaticHeader') try: if self.staticHeader is None: self.staticHeader = {} self.staticHeader['CCP-codename'] = boot.codename self.staticHeader['CCP-version'] = boot.version self.staticHeader['CCP-build'] = boot.build self.staticHeader['CCP-sync'] = boot.sync self.staticHeader['CCP-clustermode'] = prefs.GetValue('clusterMode', 'n/a') if boot.role == 'server': product = sm.GetService('cache').Setting('zsystem', 'Product') ebsVersion = sm.GetService('DB2').CallProc('zsystem.Versions_Select', product)[0].version bsdChangeList = sm.GetService('DB2').SQLInt('TOP 1 changeID', 'zstatic.changes', 'submitDate IS NOT NULL', 'submitDate DESC', 'branchID', sm.GetService('BSD').Setting(1)) self.staticHeader['CCP-product'] = product self.staticHeader['CCP-EBS'] = ebsVersion self.staticHeader['CCP-StaticBranch'] = sm.GetService('BSD').BranchName() if len(bsdChangeList) > 0: self.staticHeader['CCP-StaticCL'] = bsdChangeList[0].changeID if boot.role == 'proxy': machoNet = sm.GetService('machoNet') onlineCountEve = machoNet.GetClusterSessionCounts('EVE:Online')[0] onlineCountDust = machoNet.GetClusterSessionCounts('DUST:Online')[0] acl = machoNet.CheckACL(None, espCheck=True) vipMode = machoNet.vipMode self.staticHeader['CCP-onlineCount'] = onlineCountEve + onlineCountDust self.staticHeader['CCP-onlineCountEve'] = onlineCountEve self.staticHeader['CCP-onlineCountDust'] = onlineCountDust self.staticHeader['CCP-ACL'] = acl[1] if acl else None self.staticHeader['CCP-VIP'] = machoNet.vipMode except Exception: self.staticHeader = {'BADHEADER': ''} log.LogException() finally: uthread.UnLock('http.GetStaticHeader') return self.staticHeader
def PrimeVoucherNames(self, voucherIDs): uthread.Lock(self, 'PrimeVoucherNames') try: unprimed = [] for voucherID in voucherIDs: if voucherID not in self.names: unprimed.append(voucherID) if unprimed: vouchers = self.GetVoucherSvc().GetNames(unprimed) for voucher in vouchers: unprimed.remove(voucher.voucherID) self.names[voucher.voucherID] = voucher.text for voucherID in unprimed: self.names[voucherID] = localization.GetByLabel('UI/Common/Bookmark') finally: uthread.UnLock(self, 'PrimeVoucherNames')
def SendContentsToServer(self, contents = None): try: if not sm.services['machoNet'].IsConnected(): return except: sys.exc_clear() return if contents is None: contents = self.prevContents if contents is None or contents[0] != self.version: contents = {} else: contents = contents[1] build = boot.GetValue('build', None) contentType = CONTENT_TYPE_PREMIUM operatingSystem = PLATFORM_WINDOWS if blue.sysinfo.isTransgaming: operatingSystem = PLATFORM_MACOS blendedContents = self.entries blendedStateMask = self.stateMask self.entries = dict() self.stateMask = 0 if contents.has_key(STATE_DISCONNECT): blendedContents[STATE_DISCONNECT] = contents[STATE_DISCONNECT] blendedStateMask += STATE_DISCONNECT if contents.has_key(STATE_GAMESHUTDOWN): blendedContents[STATE_GAMESHUTDOWN] = contents[STATE_GAMESHUTDOWN] blendedStateMask += STATE_GAMESHUTDOWN header = (self.version, blendedStateMask, build, operatingSystem, contentType) data = (header, blendedContents) try: uthread.Lock(self, 'sendContents') if hasattr(self, 'prevContents'): delattr(self, 'prevContents') return True finally: uthread.UnLock(self, 'sendContents')
def GetShortestJumpCountFromCurrent(self, toID): uthread.Lock(self, 'JumpCalculation') try: tempPrev = self.routeType self.routeType = 'shortest' self.PrepareCache() locationID = eve.session.solarsystemid2 self.Refresh(locationID, toID) if type(toID) == types.ListType: ret = [] for systemID in toID: ret.append(self.cache[self.routeType][systemID][0]) self.routeType = tempPrev return ret ret = self.cache[self.routeType][toID][0] self.routeType = tempPrev return ret finally: uthread.UnLock(self, 'JumpCalculation')
def Get(self, key, flush = 0): """ Get a record from the recordset with a given key value If the record is not in the local cache, or 'flush' is true, the record is fetched from the server. """ key = int(key) if flush or not self.data.has_key(key): if boot.role != 'server': self.Prime([key]) else: uthread.Lock(self, key) try: if flush or not self.data.has_key(key): self.__LoadData(key) finally: uthread.UnLock(self, key) if self.data.has_key(key): return self.rowclass(self, key) raise KeyError('RecordNotFound', key)
def GetItemConnections(self, id, reg=0, con=0, sol=0, cel=0, _c=0): if not isinstance(id, (int, long)): log.LogError( 'GetItemConnections supports only interger types, not', id.__class__.__name__, id) return retVal = None uthread.Lock('map_GetItemConnections') try: key = '%s_%s_%s_%s_%s_%s' % (id, reg, con, sol, cel, _c) cache = self.GetMapConnectionCache() if key not in cache: rec = sm.RemoteSvc('config').GetMapConnections( id, reg, con, sol, cel, _c) cache[key] = rec settings.user.ui.Set('map_cacheconnectionsfile', cache) retVal = cache[key] finally: uthread.UnLock('map_GetItemConnections') return retVal
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 = 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')
def GetOffice(self, corpID = None): if not session.stationid2: return uthread.Lock(self, 'populatingItemIDOfficeFolderIDByCorporationID') try: if self.itemIDOfficeFolderIDByCorporationID is None: corpStationMgr = self.GetCorpStationManager() corpStationMgr.Bind() offices = corpStationMgr.GetCorporateStationOffice() self.itemIDOfficeFolderIDByCorporationID = IndexRowset(['corporationID', 'itemID', 'officeFolderID', 'stationID'], [], 'corporationID') for office in offices: self.itemIDOfficeFolderIDByCorporationID[office.corporationID] = [office.corporationID, office.itemID, office.officeFolderID] finally: uthread.UnLock(self, 'populatingItemIDOfficeFolderIDByCorporationID') if corpID is None: corpID = eve.session.corpid if self.itemIDOfficeFolderIDByCorporationID.has_key(corpID): return self.itemIDOfficeFolderIDByCorporationID[corpID]