def GetDBInitValuesFromValue(value): if type(value) is types.IntType: return util.KeyVal(valueInt=value, valueFloat=None, valueString=None) if type(value) is types.FloatType: return util.KeyVal(valueInt=None, valueFloat=value, valueString=None) if type(value) is not types.StringType: try: value = str(value) except ValueError as e: return util.KeyVal(valueInt=None, valueFloat=None, valueString=None) try: valueInt = int(value) except ValueError as e: valueInt = None if valueInt is not None: valueFloat = None else: try: valueFloat = float(value) except ValueError as e: valueFloat = None if valueInt is not None or valueFloat is not None or value.strip() == '': value = None return util.KeyVal(valueInt=valueInt, valueFloat=valueFloat, valueString=value)
def GetSculptingShapes(self): """Process and cache the sculpting shape information""" if self.sculptingShapesCache is None: self.sculptingShapesCache = {} for row in cfg.paperdollSculptingLocations: if row.weightKeyCategory not in self.sculptingShapesCache: self.sculptingShapesCache[row.weightKeyCategory] = {} for d in AXIS_DIRECTIONS.iterkeys(): if row.weightKeyPrefix in SPECIAL_HANDLE_SHAPES: key = '%sshape' % row.weightKeyPrefix self.sculptingShapesCache[row.weightKeyCategory][key] = util.KeyVal(row=row, axis=SPECIAL_HANDLE_SHAPES[row.weightKeyPrefix]) else: key = '%s_%sshape' % (row.weightKeyPrefix, d) self.sculptingShapesCache[row.weightKeyCategory][key] = util.KeyVal(row=row, axis=AXIS_DIRECTIONS[d]) return self.sculptingShapesCache
def ExtractColorRowsFromDollInfo(self, dollInfo): """Extracts a list of keyvals representing the rows for each color information field. """ colorNames = self.GetColorNames() colorKeys = self.GetColorKeys() typeColors = dollInfo.get('typeColors', {}) typeWeights = dollInfo.get('typeWeights', {}) typeGloss = dollInfo.get('typeSpecularity', {}) fakeColor = util.KeyVal(colorNameID=0) res = [] for colorKey, (colorNameAStr, colorNameBCStr) in typeColors.iteritems(): colorNameA = 0 colorNameBC = 0 weight = 0.0 gloss = 0.0 colorInfo = colorKeys.get(colorKey) if colorInfo is None: self.LogError('Missing color information for ', colorKey, 'skipping extraction') continue colorNameA = colorNames.get(colorNameAStr.lower(), fakeColor).colorNameID if colorNameBCStr is not None and colorInfo.hasSecondary: colorNameBC = colorNames.get(colorNameBCStr.lower(), fakeColor).colorNameID if colorKey in typeWeights and colorInfo.hasWeight: weight = typeWeights[colorKey] if colorKey in typeGloss and colorInfo.hasWeight: gloss = typeGloss[colorKey] res.append(ColorSelectionRow(colorInfo.colorID, colorNameA, colorNameBC, weight, gloss)) return res
def ExtractSculptRowsFromDollInfo(self, dollInfo): """This will produce a list of keyval that are one per row of DB data for the sculpting weights, Proper index and values are stored. Sculpt weights are packed into up/down, left/right, forward/back to reduce the storage rows. """ sculptingShapes = self.GetSculptingShapes() sculptModifiers = {} for categoryName in ['faceModifiers', 'bodyShapes', 'archetypes']: for sculptKey, weight in dollInfo.get(categoryName, {}).iteritems(): sculptInfo = sculptingShapes[categoryName].get(sculptKey, None) if sculptInfo is None: if categoryName != 'utilityShapes': self.LogError('Sculpting information for ', categoryName, ',', sculptKey, 'is missing, skipping!') continue if sculptInfo.row.sculptLocationID not in sculptModifiers: sculptModifiers[sculptInfo.row.sculptLocationID] = util.KeyVal(sculptLocationID=sculptInfo.row.sculptLocationID, weightUpDown=None, weightLeftRight=None, weightForwardBack=None) rowData = sculptModifiers[sculptInfo.row.sculptLocationID] value = weight if not sculptInfo.axis.positive: value = -weight setattr(rowData, sculptInfo.axis.field, value) res = [] for v in sculptModifiers.itervalues(): res.append(SculptingRow(v.sculptLocationID, v.weightUpDown, v.weightLeftRight, v.weightForwardBack)) return res
def ConvertDNAForDB(dollDNA, characterMetadata): """ Convert a raw DNA string into something that can be parsed by the database. Returns a KeyVal of columns """ charInfo = util.KeyVal() charInfo.types = characterMetadata.types charInfo.typeColors = characterMetadata.typeColors charInfo.typeWeights = characterMetadata.typeWeights charInfo.typeSpecularity = characterMetadata.typeSpecularity charInfo.hairDarkness = characterMetadata.hairDarkness charInfo.faceModifiers = {} charInfo.bodyShapes = {} charInfo.utilityShapes = {} charInfo.typeTuck = {} for each in dollDNA: if type(each) is dict: category = each[DNA_STRINGS.CATEGORY] if category == HEAD_CATEGORIES.FACEMODIFIERS: key = each[DNA_STRINGS.PATH].split(SEPERATOR_CHAR)[1] charInfo.faceModifiers[key] = each[DNA_STRINGS.WEIGHT] elif category == DOLL_EXTRA_PARTS.BODYSHAPES: key = each[DNA_STRINGS.PATH].split(SEPERATOR_CHAR)[1] charInfo.bodyShapes[key] = each[DNA_STRINGS.WEIGHT] elif category == DOLL_EXTRA_PARTS.UTILITYSHAPES: key = each[DNA_STRINGS.PATH].split(SEPERATOR_CHAR)[1] charInfo.utilityShapes[key] = each[DNA_STRINGS.WEIGHT] elif category == DOLL_EXTRA_PARTS.DEPENDANTS: if DNA_STRINGS.VARIATION in each: pathParts = each[DNA_STRINGS.PATH].split(SEPERATOR_CHAR) key = '%s%s%s' % (pathParts[0], SEPERATOR_CHAR, pathParts[1]) charInfo.typeTuck[key] = each[DNA_STRINGS.VARIATION] return GetDNAConverter().ConvertDNAForDB(charInfo)
def Deserialize(self, serializedStream, overwrite=True): if overwrite: self.stream = [] for commandID, argTuple in serializedStream: newCommand = util.KeyVal(id=commandID) if commandID == COMMAND_CREATEPIN: newCommand.pinID, newCommand.typeID, newCommand.latitude, newCommand.longitude = argTuple elif commandID == COMMAND_REMOVEPIN: newCommand.pinID, = argTuple elif commandID == COMMAND_CREATELINK: newCommand.endpoint1, newCommand.endpoint2, newCommand.level = argTuple elif commandID == COMMAND_REMOVELINK: newCommand.endpoint1, newCommand.endpoint2 = argTuple elif commandID == COMMAND_SETLINKLEVEL: newCommand.endpoint1, newCommand.endpoint2, newCommand.level = argTuple elif commandID == COMMAND_CREATEROUTE: newCommand.routeID, newCommand.path, newCommand.typeID, newCommand.quantity = argTuple elif commandID == COMMAND_REMOVEROUTE: newCommand.routeID, = argTuple elif commandID == COMMAND_SETSCHEMATIC: newCommand.pinID, newCommand.schematicID = argTuple elif commandID == COMMAND_UPGRADECOMMANDCENTER: newCommand.pinID, newCommand.level = argTuple elif commandID == COMMAND_ADDEXTRACTORHEAD: newCommand.pinID, newCommand.headID, newCommand.latitude, newCommand.longitude = argTuple elif commandID == COMMAND_KILLEXTRACTORHEAD: newCommand.pinID, newCommand.headID = argTuple elif commandID == COMMAND_MOVEEXTRACTORHEAD: newCommand.pinID, newCommand.headID, newCommand.latitude, newCommand.longitude = argTuple elif commandID == COMMAND_INSTALLPROGRAM: newCommand.pinID, newCommand.typeID, newCommand.headRadius = argTuple else: raise RuntimeError( 'Streamed Command not supported by Deserialize!') self.stream.append(newCommand)
def ExtractSculptRowsFromDollInfo(self, dollInfo): sculptingShapes = self.GetSculptingShapes() sculptModifiers = {} for categoryName in ['faceModifiers', 'bodyShapes', 'archetypes']: for sculptKey, weight in dollInfo.get(categoryName, {}).iteritems(): sculptInfo = sculptingShapes[categoryName].get(sculptKey, None) if sculptInfo is None: if categoryName != 'utilityShapes': self.LogError('Sculpting information for ', categoryName, ',', sculptKey, 'is missing, skipping!') continue if sculptInfo.row.sculptLocationID not in sculptModifiers: sculptModifiers[ sculptInfo.row.sculptLocationID] = util.KeyVal( sculptLocationID=sculptInfo.row.sculptLocationID, weightUpDown=None, weightLeftRight=None, weightForwardBack=None) rowData = sculptModifiers[sculptInfo.row.sculptLocationID] value = weight if not sculptInfo.axis.positive: value = -weight setattr(rowData, sculptInfo.axis.field, value) res = [] for v in sculptModifiers.itervalues(): res.append( SculptingRow(v.sculptLocationID, v.weightUpDown, v.weightLeftRight, v.weightForwardBack)) return res
def _TransactionAwareCreate(cls, wordPropertyID, messageID, metaDataValue, transactionBundle=None): """ Perform Create. This particular method currently doesnt care if it runs within transaction or not. But it follows a pattern where Create is split into two methods, for now. returns: can return either row or actionID """ cls._ValidateCreationOfMetaData(wordPropertyID, messageID, metaDataValue, transactionBundle) if transactionBundle: transactionBundle[localizationBSDConst.BUNDLE_METADATA].append( util.KeyVal({ 'wordPropertyID': wordPropertyID, 'messageID': messageID, 'metaDataValue': metaDataValue })) result = bsdWrappers.BaseWrapper._Create(cls, wordPropertyID=wordPropertyID, messageID=messageID, metaDataValue=metaDataValue) if type(result) == int: return {'reservedWordMetaDataID': result} else: return result
def GetBlueInfo(numMinutes=None, isYield=True): if numMinutes: trend = blue.pyos.cpuUsage[-numMinutes * 60 / 10:] else: trend = blue.pyos.cpuUsage[:] mega = 1.0 / 1024.0 / 1024.0 ret = util.KeyVal() ret.memData = [] ret.pymemData = [] ret.bluememData = [] ret.othermemData = [] ret.threadCpuData = [] ret.procCpuData = [] ret.threadKerData = [] ret.procKerData = [] ret.timeData = [] ret.latenessData = [] ret.schedData = [] latenessBase = 100000000.0 if len(trend) >= 1: ret.actualmin = int((trend[-1][0] - trend[0][0]) / 10000000.0 / 60.0) t1 = trend[0][0] benice = blue.pyos.BeNice mem = 0 for t, cpu, mem, sched in trend: if isYield: benice() elap = t - t1 t1 = t p_elap = 100.0 / elap if elap else 0.0 mem, pymem, workingset, pagefaults, bluemem = mem ret.memData.append(mem * mega) ret.pymemData.append(pymem * mega) ret.bluememData.append(bluemem * mega) othermem = (mem - pymem - bluemem) * mega if othermem < 0: othermem = 0 ret.othermemData.append(othermem) thread_u, proc_u = cpu[:2] thread_k, proc_k = cpu[2:4] if len(cpu) >= 4 else (0, 0) thread_cpupct = thread_u * p_elap proc_cpupct = proc_u * p_elap thread_kerpct = thread_k * p_elap proc_kerpct = proc_k * p_elap ret.threadCpuData.append(thread_cpupct) ret.procCpuData.append(proc_cpupct) ret.threadKerData.append(thread_kerpct) ret.procKerData.append(proc_kerpct) ret.schedData.append(sched) ret.timeData.append(t) late = 0.0 if elap: late = (elap - latenessBase) / latenessBase * 100 ret.latenessData.append(late) ret.proc_cpupct = proc_cpupct ret.mem = mem return ret
def ConvertDNAForDB(self, dollInfo): """Do the conversion from DNA to DB format""" dollData = util.KeyVal(appearance=None, sculpts=[], colors=[], modifiers=[]) dollData.appearance = self.ExtractAppearanceRowFromDollInfo(dollInfo) dollData.sculpts = self.ExtractSculptRowsFromDollInfo(dollInfo) dollData.modifiers = self.ExtractModifierRowsFromDollInfo(dollInfo) dollData.colors = self.ExtractColorRowsFromDollInfo(dollInfo) self.LogInfo('Converted DNA to DB. sculpts:', len(dollData.sculpts), ' modifiers:', len(dollData.modifiers), ' colors:', len(dollData.colors)) return dollData
def GetDBInitValuesFromValue(value): """ This method takes a value of some arbitrary type and returns a KeyVal representing the values that should be inserted into the database's zentity.ingredientInitialValues table in the valueInt, valueFloat and valueString columns. If the value is not explicitly an int or float, it will try to coerce the value via a string into those types. Failing that, it will make the value a string and store it as such. Empty/whitespace-only strings will be interpreted as NULLs in all columns. """ if type(value) is types.IntType: return util.KeyVal(valueInt=value, valueFloat=None, valueString=None) if type(value) is types.FloatType: return util.KeyVal(valueInt=None, valueFloat=value, valueString=None) if type(value) is not types.StringType: try: value = str(value) except ValueError as e: return util.KeyVal(valueInt=None, valueFloat=None, valueString=None) try: valueInt = int(value) except ValueError as e: valueInt = None if valueInt is not None: valueFloat = None else: try: valueFloat = float(value) except ValueError as e: valueFloat = None if valueInt is not None or valueFloat is not None or value.strip() == '': value = None return util.KeyVal(valueInt=valueInt, valueFloat=valueFloat, valueString=value)
def GetCameraSettings(self): offset = gfxsettings.Get(gfxsettings.UI_INCARNA_CAMERA_OFFSET) invertY = gfxsettings.Get(gfxsettings.UI_INCARNA_CAMERA_INVERT_Y) mouseLookSpeed = gfxsettings.Get( gfxsettings.UI_INCARNA_CAMERA_MOUSE_LOOK_SPEED) mouseSmooth = True mySettings = util.KeyVal(charOffsetSetting=offset, invertY=invertY, mouseLookSpeed=mouseLookSpeed, mouseSmooth=mouseSmooth) return mySettings
def _TransactionAwareCreate(cls, label, groupID, languageID, text, context, wordTypeID=None, transactionBundle=None): inheritedWordTypeID = Message._GetWordTypeID(groupID) if wordTypeID is None: wordTypeID = inheritedWordTypeID Message._ValidateCreationOfMessage(label, groupID, wordTypeID, transactionBundle=transactionBundle) dbLocaleID = GetNumericLanguageIDFromLanguageID(languageID) if dbLocaleID is None: raise AuthoringValidationError('Didnt find language (%s).' % languageID) reservedActionID = bsdWrappers.BaseWrapper._Create( cls, label=label, groupID=groupID, context=context, wordTypeID=wordTypeID) if transactionBundle: tupleActionID = (reservedActionID, 'messageID') transactionBundle[localizationBSDConst. BUNDLE_MESSAGE][tupleActionID] = util.KeyVal({ 'label': label, 'groupID': groupID, 'context': context, 'wordTypeID': wordTypeID }) messageTextTable = bsdWrappers.GetTable( locMessageText.MessageText.__primaryTable__) messageTextTable.AddRow((reservedActionID, 'messageID'), dbLocaleID, text=text) if type(reservedActionID) == int: return {'reservedMessageID': reservedActionID} raise AuthoringValidationError( 'Unexpected error. Possibly incorrect use of transactions. Expected actionID but instead got : %s ' % str(reservedActionID))
def AddCommand(self, commandID, **kwargs): if commandID not in self.__commands__: raise RuntimeError('Command not recognized') newCommand = util.KeyVal(id=commandID) for identifier in self.__identifiers__[commandID]: if identifier not in kwargs: raise RuntimeError('Missing identifier in kwargs for command') setattr(newCommand, identifier, kwargs[identifier]) for argument in self.__arguments__[commandID]: if argument not in kwargs: raise RuntimeError('Missing argument in kwargs for command') setattr(newCommand, argument, kwargs[argument]) doNotEnqueue = self._RemoveSynonymsAndAntonyms(newCommand) if not doNotEnqueue: self.stream.append(newCommand) self.history.append(newCommand)
def _TransactionAwareCreate(cls, wordPropertyID, messageID, metaDataValue, transactionBundle=None): cls._ValidateCreationOfMetaData(wordPropertyID, messageID, metaDataValue, transactionBundle) if transactionBundle: transactionBundle[localizationBSDConst.BUNDLE_METADATA].append( util.KeyVal({ 'wordPropertyID': wordPropertyID, 'messageID': messageID, 'metaDataValue': metaDataValue })) result = bsdWrappers.BaseWrapper._Create(cls, wordPropertyID=wordPropertyID, messageID=messageID, metaDataValue=metaDataValue) if type(result) == int: return {'reservedWordMetaDataID': result} else: return result
#Embedded file name: talecommon\const.py """ A common module to provide constants for the tale system """ import collections import utillib as util from dogma.const import attributeScanGravimetricStrength from inventorycommon.const import ownerUnknown from eve.common.lib.appConst import securityClassZeroSec, securityClassLowSec, securityClassHighSec templates = util.KeyVal(incursion=2, knownSpace=3, solarSystem=4) actionClass = util.KeyVal(spawnOneDungeonAtEachCelestial=1, spawnManyDungeonsAtLocation=2, disableDjinns=3, addDjinnCommand=4, addSystemEffectBeacon=5, addSystemInfluenceTrigger=6, initializeInfluence=7, setBountySurcharge=8, endTale=9, spawnDungeonAtDeterministicLocation=10, spawnNPCsAtLocation=11) conditionClass = util.KeyVal(checkSolarSystemSecurity=1, checkInitiationChance=2) systemInfluenceAny = 0 systemInfluenceDecline = 1 systemInfluenceRising = 2 Parameter = collections.namedtuple('Parameter', 'name parameterType defaultValue prettyName description') parameterByID = {1: Parameter('dungeonID', int, 0, 'Dungeon ID', 'The ID of the dungeon to spawn'), 2: Parameter('dungeonListID', int, None, 'Dungeon list ID', 'The ID of the list of dungeons to spawn'), 3: Parameter('dungeonRespawnTime', int, 1, 'Dungeon respawn time', 'Dungeon respawn time in minutes'), 4: Parameter('dungeonScanStrength', int, 100, 'Dungeon scan strength', 'Dungeon scan strength for scanning down the dungeon'), 5: Parameter('dungeonSignatureRadius', float, 100.0, 'Dungeon signature radius', 'Dungeon signature radius used for scanning down the dungeon'), 6: Parameter('dungeonScanStrengthAttrib', float, attributeScanGravimetricStrength, 'Dungeon scan attribute', 'Dungeon scan attribute'), 7: Parameter('dungeonSpawnLocation', float, None, 'Dungeon spawn location', 'The locations in space where the dungeon is going to respawn'), 8: Parameter('dungeonSpawnQuantity', int, 1, 'Number of Dungeons', 'The number of dungeons which have to be spawned'), 9: Parameter('triggeredScene', int, None, 'Triggered Scene', 'The scene which is added to the trigger location when activated'), 10: Parameter('triggeredSceneLocation', int, None, 'Trigger Location', 'The location the triggered scene is added when the trigger is activated'), 11: Parameter('solarSystemSecurityMin', float, 1.0, 'Security minimum', 'The security level of the solar system has to be above this before the condition is true'), 12: Parameter('solarSystemSecurityMax', float, 0.0, 'Security maximum', 'The security level of the solar system has to be below this before the condition is true'), 13: Parameter('solarSystemSecurityMinInclusive', bool, True, 'Security minimum inclusive', 'This is whether the minimum should be inclusive or exclusive'), 14: Parameter('solarSystemSecurityMaxInclusive', bool, False, 'Security maximum inclusive', 'This is whether the maximum should be inclusive or exclusive'), 15: Parameter('disableConvoyDjinn', bool, False, 'Disable convoy djinn', 'Disables the convoy djinn during the tale'),
SUN_BLUE = (0.6, 0.95, 1.0, 1.0) SUN_BLUE_BRIGHT = (0.8, 0.98, 1.0, 1.0) SUN_ORANGE = (1.0, 0.8, 0.6, 1.0) SUN_ORANGE_BRIGHT = (1.0, 0.75, 0.65, 1.0) SUN_RED = (1.0, 0.6, 0.6, 1.0) SUN_YELLOW = (1.0, 1.0, 0.5, 1.0) SUN_PINK = (1.0, 0.85, 0.9, 1.0) SUN_SIZE_DWARF = 3 SUN_SIZE_SMALL = 3 SUN_SIZE_MEDIUM = 4 SUN_SIZE_LARGE = 5 SUN_SIZE_GIANT = 6 SUN_DATA = { 3801: util.KeyVal(__doc__='Sun A0 (Blue Small)', color=SUN_BLUE, size=SUN_SIZE_SMALL), 9: util.KeyVal(__doc__='Sun B0 (Blue)', color=SUN_BLUE, size=SUN_SIZE_MEDIUM), 3803: util.KeyVal(__doc__='Sun B5 (White Dwarf)', color=SUN_WHITE, size=SUN_SIZE_DWARF), 10: util.KeyVal(__doc__='Sun F0 (White)', color=SUN_WHITE, size=SUN_SIZE_SMALL), 3799: util.KeyVal(__doc__='Sun G3 ( Pink Small ', color=SUN_PINK, size=SUN_SIZE_SMALL), 3797:
def GetServerInfo(): """ Returns a KeyVal containing information about the server that the client is configured to connect to. This method must be static and we must be careful with service calls since it can be called early in the startup proceedure. """ serverName = utillib.GetServerName() ip = GetServerIP(serverName) servers = [['Tranquility', '87.237.38.200', '87.237.38.201'], ['Multiplicity', '87.237.38.51', '87.237.38.15'], ['Singularity', '87.237.38.50', '87.237.38.24'], ['Duality', '87.237.38.60', '87.237.38.61'], ['Chaos', '87.237.38.55', '87.237.38.71'], ['Buckingham', '87.237.38.69', '87.237.38.14'], ['Adam', 'Adam', 'Adam'], ['localhost', 'localhost', 'localhost']] foundServerInfo = False espUrl = ip for s in servers: if s[1] == ip: espUrl = s[2] serverName = s[0] foundServerInfo = True break if ':' not in espUrl: espUrl += ':50001' isLive = True if boot.region != 'optic' and ip != LIVE_SERVER: isLive = False try: inf = None import __builtin__ if hasattr(__builtin__, 'sm') and 'machoNet' in sm.services: inf = sm.GetService('machoNet').GetGlobalConfig().get('serverInfo') if inf: lst = inf.split(',') if len(lst) != 4: logmodule.general.Log( "Broken Server info in Global Config! It should contain 'serverName,ip,espIP:espPort,isLive'", logmodule.LGERR) else: l = lst[3] if l.lower() == 'false': l = 0 elif l.lower() == 'true': l = 1 isLive = bool(int(l)) serverName = lst[0] ip = lst[1] foundServerInfo = True espUrl = lst[2] if ':' not in espUrl: logmodule.general.Log( "Broken Server info in Global Config! ESP URL missing port. Full config should be 'serverName,ip,espIP:espPort,isLive'. Defaulting to port 50001", logmodule.LGWARN) espUrl += ':50001' logmodule.general.Log( 'Returning Server info from Global Config. serverName = %s, IP = %s, espUrl = %s, live = %s' % (serverName, ip, espUrl, isLive)) elif not foundServerInfo: logmodule.general.Log( 'The server you are connected to, %s, does not supply serverInfo. This can be configured in globalconfig: serverInfo=serverName,ip,espIP:espPort,isLive' % ip) except Exception as e: logmodule.general.Log( 'Could not get server info from server. Info: %s, Error: %s' % (inf, e), logmodule.LGERR) def safeGetEveAttr(attr): try: return getattr(eve, attr) except (NameError, AttributeError): return None serverInfo = utillib.KeyVal(name=serverName, IP=ip, espUrl=espUrl, isLive=isLive, version=safeGetEveAttr('serverVersion'), build=safeGetEveAttr('serverBuild')) return serverInfo
def _TransactionAwareCreate(cls, label, groupID, languageID, text, context, wordTypeID=None, transactionBundle=None): """ Worker function for transaction-aware portion of the create code. parameters: label - label of the message. Must be unique groupID - destination group. Must match the wordType of this message languageID - id for text entry text - text entry context - description for this message entry wordTypeID - type of the message transactionBundle - cache containing entries of messages to be added within transaction. It is required for validations within transactions. See CreateMessageDataBundle() Returns: reserved actionID dictionary for the message, that will be added when transaction is done. The return is formated as: {"reservedMessageID": INTEGER} pre-req: always meant to run in transaction """ inheritedWordTypeID = Message._GetWordTypeID(groupID) if wordTypeID is None: wordTypeID = inheritedWordTypeID Message._ValidateCreationOfMessage(label, groupID, wordTypeID, transactionBundle=transactionBundle) dbLocaleID = GetNumericLanguageIDFromLanguageID(languageID) if dbLocaleID is None: raise AuthoringValidationError('Didnt find language (%s).' % languageID) reservedActionID = bsdWrappers.BaseWrapper._Create( cls, label=label, groupID=groupID, context=context, wordTypeID=wordTypeID) if transactionBundle: tupleActionID = (reservedActionID, 'messageID') transactionBundle[localizationBSDConst. BUNDLE_MESSAGE][tupleActionID] = util.KeyVal({ 'label': label, 'groupID': groupID, 'context': context, 'wordTypeID': wordTypeID }) messageTextTable = bsdWrappers.GetTable( locMessageText.MessageText.__primaryTable__) messageTextTable.AddRow((reservedActionID, 'messageID'), dbLocaleID, text=text) if type(reservedActionID) == int: return {'reservedMessageID': reservedActionID} raise AuthoringValidationError( 'Unexpected error. Possibly incorrect use of transactions. Expected actionID but instead got : %s ' % str(reservedActionID))
MAP_SUFFIX_MASK) GEO_FORMAT_RED = 'red' GEO_FORMAT_GR2 = 'gr2' GEO_FORMATS = cdsuc.EnumList(GEO_FORMAT_RED, GEO_FORMAT_GR2) GEO_SUFFIX_LODA = '_loda' GEO_SUFFIX_LOD0 = '_lod0' GEO_SUFFIX_LOD1 = '_lod1' GEO_SUFFIX_LOD2 = '_lod2' GEO_SUFFIX_LOD3 = '_lod3' GEO_LOD_SUFFIXES = cdsuc.EnumList(GEO_SUFFIX_LODA, GEO_SUFFIX_LOD0, GEO_SUFFIX_LOD1, GEO_SUFFIX_LOD2, GEO_SUFFIX_LOD3) FEMALE_DECAL_BINDPOSE = 'res:/Graphics/Character/Global/Poses/FemaleTattooPose.gr2' MALE_DECAL_BINDPOSE = 'res:/Graphics/Character/Global/Poses/MaleTattooPose.gr2' AXIS_DIRECTIONS = { 'up': util.KeyVal(id='up', field='weightUpDown', positive=True), 'down': util.KeyVal(id='down', field='weightUpDown', positive=False), 'left': util.KeyVal(id='left', field='weightLeftRight', positive=True), 'right': util.KeyVal(id='right', field='weightLeftRight', positive=False), 'forward': util.KeyVal(id='forward', field='weightForwardBack', positive=True), 'back': util.KeyVal(id='back', field='weightForwardBack', positive=False) } SPECIAL_HANDLE_SHAPES = { 'thin': util.KeyVal(field='weightUpDown', positive=True), 'fat': util.KeyVal(field='weightLeftRight', positive=True), 'muscular': util.KeyVal(field='weightForwardBack', positive=True) } SculptingRow = collections.namedtuple( 'SculptingRow',
MAP_SUFFIX_DRGB = '_drgb' MAP_SUFFIX_LRGB = '_lrgb' MAP_SUFFIX_MASK = '_mask' MAP_TYPE_SUFFIXES = cdsuc.EnumList(MAP_SUFFIX_D, MAP_SUFFIX_L, MAP_SUFFIX_M, MAP_SUFFIX_N, MAP_SUFFIX_O, MAP_SUFFIX_S, MAP_SUFFIX_Z, MAP_SUFFIX_AO, MAP_SUFFIX_MN, MAP_SUFFIX_MM, MAP_SUFFIX_TN, MAP_SUFFIX_MASK) GEO_FORMAT_RED = 'red' GEO_FORMAT_GR2 = 'gr2' GEO_FORMATS = cdsuc.EnumList(GEO_FORMAT_RED, GEO_FORMAT_GR2) GEO_SUFFIX_LODA = '_loda' GEO_SUFFIX_LOD0 = '_lod0' GEO_SUFFIX_LOD1 = '_lod1' GEO_SUFFIX_LOD2 = '_lod2' GEO_SUFFIX_LOD3 = '_lod3' GEO_LOD_SUFFIXES = cdsuc.EnumList(GEO_SUFFIX_LODA, GEO_SUFFIX_LOD0, GEO_SUFFIX_LOD1, GEO_SUFFIX_LOD2, GEO_SUFFIX_LOD3) FEMALE_DECAL_BINDPOSE = 'res:/Graphics/Character/Global/Poses/FemaleTattooPose.gr2' MALE_DECAL_BINDPOSE = 'res:/Graphics/Character/Global/Poses/MaleTattooPose.gr2' AXIS_DIRECTIONS = {'up': util.KeyVal(id='up', field='weightUpDown', positive=True), 'down': util.KeyVal(id='down', field='weightUpDown', positive=False), 'left': util.KeyVal(id='left', field='weightLeftRight', positive=True), 'right': util.KeyVal(id='right', field='weightLeftRight', positive=False), 'forward': util.KeyVal(id='forward', field='weightForwardBack', positive=True), 'back': util.KeyVal(id='back', field='weightForwardBack', positive=False)} SPECIAL_HANDLE_SHAPES = {'thin': util.KeyVal(field='weightUpDown', positive=True), 'fat': util.KeyVal(field='weightLeftRight', positive=True), 'muscular': util.KeyVal(field='weightForwardBack', positive=True)} SculptingRow = collections.namedtuple('SculptingRow', 'sculptLocationID weightUpDown weightLeftRight weightForwardBack') ModifierRow = collections.namedtuple('ModifierRow', 'modifierLocationID paperdollResourceID paperdollResourceVaraition') ColorSelectionRow = collections.namedtuple('ColorSelectionRow', 'colorID colorNameA colorNameBC weight gloss') AppearanceRow = collections.namedtuple('AppearanceRow', 'hairDarkness') __dnaConverter__ = None def GetDNAConverter():
def PlayVideoId(cls, videoid): desc = TUTORIAL_VIDEOS_INDEX.get_video_by_id(videoid) if desc: cls.PlayVideo(utillib.KeyVal(desc))
def StructToKeyval(s): import utillib as util d = dict(((k, getattr(s, k)) for k, t in s._fields_)) return util.KeyVal(**d)
def GetServerInfo(): serverName = utillib.GetServerName() ip = GetServerIP(serverName) servers = [[ 'Tranquility', _GetServerIP('tranquility'), _GetServerIP('tranquilityesp') ], [ 'Multiplicity', _GetServerIP('multiplicity'), _GetServerIP('multiplicityesp') ], [ 'Singularity', _GetServerIP('singularity'), _GetServerIP('singularityesp') ], [ 'Duality', _GetServerIP('duality'), _GetServerIP('dualityesp') ], ['Chaos', _GetServerIP('chaos'), _GetServerIP('chaosesp')], [ 'Buckingham', _GetServerIP('buckingham'), _GetServerIP('buckinghamesp') ], ['Adam', 'Adam', 'Adam'], ['localhost', 'localhost', 'localhost']] foundServerInfo = False espUrl = ip for s in servers: if s[1] == ip: espUrl = s[2] serverName = s[0] foundServerInfo = True break if ':' not in espUrl: espUrl += ':50001' isLive = True if boot.region != 'optic' and not IsLiveServer(ip): isLive = False try: inf = None import __builtin__ if hasattr(__builtin__, 'sm') and 'machoNet' in sm.services: inf = sm.GetService('machoNet').GetGlobalConfig().get('serverInfo') if inf: lst = inf.split(',') if len(lst) != 4: logmodule.general.Log( "Broken Server info in Global Config! It should contain 'serverName,ip,espIP:espPort,isLive'", logmodule.LGERR) else: l = lst[3] if l.lower() == 'false': l = 0 elif l.lower() == 'true': l = 1 isLive = bool(int(l)) serverName = lst[0] ip = lst[1] foundServerInfo = True espUrl = lst[2] if ':' not in espUrl: logmodule.general.Log( "Broken Server info in Global Config! ESP URL missing port. Full config should be 'serverName,ip,espIP:espPort,isLive'. Defaulting to port 50001", logmodule.LGWARN) espUrl += ':50001' logmodule.general.Log( 'Returning Server info from Global Config. serverName = %s, IP = %s, espUrl = %s, live = %s' % (serverName, ip, espUrl, isLive)) elif not foundServerInfo: logmodule.general.Log( 'The server you are connected to, %s, does not supply serverInfo. This can be configured in globalconfig: serverInfo=serverName,ip,espIP:espPort,isLive' % ip) except Exception as e: logmodule.general.Log( 'Could not get server info from server. Info: %s, Error: %s' % (inf, e), logmodule.LGERR) def safeGetEveAttr(attr): try: return getattr(eve, attr) except (NameError, AttributeError): return None serverInfo = utillib.KeyVal(name=serverName, IP=ip, espUrl=espUrl, isLive=isLive, version=safeGetEveAttr('serverVersion'), build=safeGetEveAttr('serverBuild')) return serverInfo