class BurpExtender(IBurpExtender,IContextMenuFactory,ITab,IBurpExtenderCallbacks): view = None def registerExtenderCallbacks(self, callbacks): self._helpers = callbacks.getHelpers() self._jPanelMain = None ContentData.callbacks = callbacks BurpExtender.ViewMain = ViewMain() self._jPanelMain= BurpExtender.ViewMain.feche_extension() ContentData.callbacks.setExtensionName("Swagger_Spec_Loader") ContentData.callbacks.customizeUiComponent(self._jPanelMain) ContentData.callbacks.addSuiteTab(self) ContentData.callbacks.registerContextMenuFactory(self) return def getTabCaption(self): return 'Swagger_Spec_Loader' def getUiComponent(self): return self._jPanelMain def createMenuItems(self,invocation): httpRequestResponseArray = invocation.getSelectedMessages() ctx = invocation.getInvocationContext() print ctx self.menu_list = LinkedList() self.menu_item_1 = swing.JMenuItem('test1 button') self.menu_item_1.addMouseListener(ResponseContextMenu(self.callbacks, httpRequestResponseArray)) self.menu_list.add(self.menu_item_1) self.menu_item_2 = swing.JMenuItem('test2 button') self.menu_item_2.addMouseListener(ResponseContextMenu(self.callbacks, httpRequestResponseArray)) self.menu_list.add(self.menu_item_2) return self.menu_list
def createMenuItems(self, invocation): responses = invocation.getSelectedMessages(); if responses > 0: ret = LinkedList() requestMenuItem = JMenuItem("Send to PT Manager"); requestMenuItem.addActionListener(handleMenuItems(self,responses[0], "request")) ret.add(requestMenuItem); return(ret); return null;
def createMenuItems(self, invocation): responses = invocation.getSelectedMessages() if responses > 0: ret = LinkedList() requestMenuItem = JMenuItem("[*] Send request to Jaeles Endpoint") requestMenuItem.addActionListener( handleMenuItems(self, responses, "request")) ret.add(requestMenuItem) return ret return None
def createMenuItems(self, invocation): responses = invocation.getSelectedMessages() if responses > 0: ret = LinkedList() affectedMenuItem = JMenuItem("XSSor: Add affected page") affectedMenuItem.addActionListener( handleMenuItems(self, responses[0], "affected")) ret.add(affectedMenuItem) return (ret) return null
def askNot(self, not_, goals, context, theta, cache, renamer, askOne, results, alreadyAsking): """ generated source for method askNot """ notGoals = LinkedList() notGoals.add(not_.getBody()) notResults = HashSet() isConstant = True isConstant &= self.ask(notGoals, context, theta, cache, renamer, True, notResults, alreadyAsking) if len(notResults) == 0: isConstant &= self.ask(goals, context, theta, cache, renamer, askOne, results, alreadyAsking) return isConstant
def p2j(subtree): if type(subtree) == str: return String(subtree) elif type(subtree) == tuple: l = LinkedList() for entry in subtree: l.add(p2j(entry)) return l else: raise ValueError, ("ERROR, bad type in parse tree: " + str(type(subtree)))
def sendGenericMessage(self, msg, sender, recipients): chanList = LinkedList() for recipient in recipients: chanList.add(recipient.getChannel()) senderCh = None if not sender == None: senderCh = sender.getChannel() self._helper.sendGenericMessage(msg, senderCh, chanList)
def ask(self, query, context, askOne): """ generated source for method ask """ goals = LinkedList() goals.add(query) answers = HashSet() alreadyAsking = HashSet() self.ask(goals, KnowledgeBase(context), Substitution(), ProverCache(), VariableRenamer(), askOne, answers, alreadyAsking) results = HashSet() for theta in answers: results.add(Substituter.substitute(query, theta)) return results
def createMenuItems(self, invocation): responses = invocation.getSelectedMessages() if responses > 0: ret = LinkedList() requestMenuItem = JMenuItem("Send request to Trishul") for response in responses: requestMenuItem.addActionListener(handleMenuItems(self,response, "request")) ret.add(requestMenuItem) return ret return None
def createMenuItems(self, invocation): responses = invocation.getSelectedMessages(); if responses > 0: ret = LinkedList() requestMenuItem = JMenuItem("Send request to Autorize"); cookieMenuItem = JMenuItem("Send cookie to Autorize"); requestMenuItem.addActionListener(handleMenuItems(self,responses[0], "request")) cookieMenuItem.addActionListener(handleMenuItems(self, responses[0], "cookie")) ret.add(requestMenuItem); ret.add(cookieMenuItem); return(ret); return null;
def leer_archivo(self): archivo = File("reglas.txt") fr = FileReader(archivo) br = BufferedReader(fr) linea = br.readLine() res = LinkedList() while( linea != None ): res.add(self.crear_regla(linea)) linea = br.readLine() return res
def createMenuItems(self, invocation): self.context = invocation mainMenu = ArrayList() #menu = LinkedList() subMenu = LinkedList() mainMenu = JMenuItem("Generate a UUID string and copy to clipbloard") menuItem1 = JMenuItem("UUID version 1", actionPerformed=self.genUUID) #menuItem2 = JMenuItem("UUID verion 2", actionPerformed=self.genUUID) subMenu.add(menuItem1) #subMenu.add(menuItem2) #mainMenu.add(subMenu) return subMenu
def leer_archivo(self): archivo = File("reglas.txt") fr = FileReader(archivo) br = BufferedReader(fr) linea = br.readLine() res = LinkedList() while (linea != None): res.add(self.crear_regla(linea)) linea = br.readLine() return res
def testJavaUtilList(self): """testing parameterized values in a java.util.List""" c = self.cursor() try: from java.util import LinkedList a = LinkedList() a.add((3,)) c.execute("select * from zxtesting where id = ?", a) f = c.fetchall() assert len(f) == 1, "expected [1], got [%d]" % (len(f)) finally: c.close()
def createMenuItems(self, invocation): responses = invocation.getSelectedMessages() if responses > 0: ret = LinkedList() analyzedMenuItem = JMenuItem("Mark as analyzed") notAnalyzedMenuItem = JMenuItem("Mark as NOT analyzed") for response in responses: analyzedMenuItem.addActionListener(handleMenuItems(self,response, "analyzed")) notAnalyzedMenuItem.addActionListener(handleMenuItems(self, response, "not")) ret.add(analyzedMenuItem) ret.add(notAnalyzedMenuItem) return ret
def createMenuItems(self, invocation): responses = invocation.getSelectedMessages() if responses > 0: ret = LinkedList() requestMenuItem = JMenuItem("Send request to Autorize") cookieMenuItem = JMenuItem("Send cookie to Autorize") requestMenuItem.addActionListener( handleMenuItems(self, responses[0], "request")) cookieMenuItem.addActionListener( handleMenuItems(self, responses[0], "cookie")) ret.add(requestMenuItem) ret.add(cookieMenuItem) return (ret) return null
def createMenuItems(self, invocation): responses = invocation.getSelectedMessages() if responses > 0: ret = LinkedList() requestMenuItem = JMenuItem("Send request to Autorize") cookieMenuItem = JMenuItem("Send cookie to Autorize") for response in responses: requestMenuItem.addActionListener( HandleMenuItems(self._extender, response, "request")) cookieMenuItem.addActionListener( HandleMenuItems(self._extender, response, "cookie")) ret.add(requestMenuItem) ret.add(cookieMenuItem) return ret return None
def getTopologicalOrdering(cls, forms, dependencyGraph): """ generated source for method getTopologicalOrdering """ # We want each form as a key of the dependency graph to # follow all the forms in the dependency graph, except maybe itself queue = LinkedList(forms) ordering = ArrayList(len(forms)) alreadyOrdered = HashSet() while not queue.isEmpty(): # Don't add if there are dependencies for dependency in dependencyGraph.get(curForm): if not dependency == curForm and not alreadyOrdered.contains(dependency): readyToAdd = False break # Add it if readyToAdd: ordering.add(curForm) alreadyOrdered.add(curForm) else: queue.add(curForm) # TODO: Add check for an infinite loop here # Or replace with code that does stratification of loops return ordering
def getTopologicalOrdering(cls, forms, dependencyGraph, usingBase, usingInput): """ generated source for method getTopologicalOrdering """ queue = LinkedList(forms) ordering = ArrayList(len(forms)) alreadyOrdered = HashSet() while not queue.isEmpty(): for dependency in dependencyGraph.get(curForm): if not dependency == curForm and not alreadyOrdered.contains(dependency): readyToAdd = False break if usingBase and (curForm.__name__ == cls.TRUE or curForm.__name__ == cls.NEXT or curForm.__name__ == cls.INIT): if not alreadyOrdered.contains(baseForm): readyToAdd = False if usingInput and (curForm.__name__ == cls.DOES or curForm.__name__ == cls.LEGAL): if not alreadyOrdered.contains(inputForm): readyToAdd = False if readyToAdd: ordering.add(curForm) alreadyOrdered.add(curForm) else: queue.add(curForm) ConcurrencyUtils.checkForInterruption() return ordering
def writePopulationToDatabase(self): # Uncommenting these lines allows testing when there is no web server. #Log.debug("PopulationClass.writePopulationToDatabase entered") statements = LinkedList() # Acquire the lock to copy the recentPopulationNumbers dictionary, # and then release it. try: self.popLock.lock() mostRecentPopulationNumbers = self.recentPopulationNumbers self.recentPopulationNumbers = {} finally: self.popLock.unlock() #Log.debug("PopulationClass.writePopulationToDatabase: " + str(len(mostRecentPopulationNumbers)) + " elements") # Iterate over the recent population changes elements. # If the instanceOid already exists in allPopulationNumbers and # the population is zero, remove the row and remove the element # of allPopulationNumbers; otherwise, create the update statement. # If it's not in allPopulationNumbers, create the insert statement. for accountId, (population, instanceOid) in mostRecentPopulationNumbers.items(): if accountId in self.allPopulationNumbers: if (population == 0): statements.add( "DELETE FROM populations WHERE account_id = " + str(accountId) + ";") del self.allPopulationNumbers[accountId] else: statements.add("UPDATE populations SET population = " + str(population) + " WHERE instance_id = " + str(instanceOid) + ";") else: statements.add( "INSERT INTO populations (account_id, instance_id, population) VALUES (" + str(accountId) + "," + str(instanceOid) + "," + str(population) + ");") self.allPopulationNumbers[accountId] = (population, instanceOid) # If there is nothing to do, return if statements.size() == 0: return else: Engine.getDatabase().executeBatch(statements) if (Log.loggingDebug): batch = "" for i in range(statements.size() - 1): batch += "\n" + statements.get(i) Log.debug( "PopulationClass.writePopulationFields: ran SQL statements " + batch)
def writePopulationToDatabase(self): # Uncommenting these lines allows testing when there is no web server. #Log.debug("PopulationClass.writePopulationToDatabase entered") statements = LinkedList() # Acquire the lock to copy the recentPopulationNumbers dictionary, # and then release it. try: self.popLock.lock() mostRecentPopulationNumbers = self.recentPopulationNumbers self.recentPopulationNumbers = {} finally: self.popLock.unlock() #Log.debug("PopulationClass.writePopulationToDatabase: " + str(len(mostRecentPopulationNumbers)) + " elements") # Iterate over the recent population changes elements. # If the instanceOid already exists in allPopulationNumbers and # the population is zero, remove the row and remove the element # of allPopulationNumbers; otherwise, create the update statement. # If it's not in allPopulationNumbers, create the insert statement. for accountId, (population, instanceOid) in mostRecentPopulationNumbers.items(): if accountId in self.allPopulationNumbers: if (population == 0): statements.add("DELETE FROM populations WHERE account_id = " + str(accountId) + ";") del self.allPopulationNumbers[accountId] else: statements.add("UPDATE populations SET population = " + str(population) + " WHERE instance_id = " + str(instanceOid) + ";") else: statements.add("INSERT INTO populations (account_id, instance_id, population) VALUES (" + str(accountId) + "," + str(instanceOid) + "," + str(population) + ");") self.allPopulationNumbers[accountId] = (population, instanceOid) # If there is nothing to do, return if statements.size() == 0: return else: Engine.getDatabase().executeBatch(statements) if (Log.loggingDebug): batch = "" for i in range(statements.size() - 1): batch += "\n" + statements.get(i) Log.debug("PopulationClass.writePopulationFields: ran SQL statements " + batch)
from Regla import * from java.util import LinkedList res = LinkedList() res.add(Mi_Regla()) res.add(Mi_Regla()) res.add(Mi_Regla()) for a in res: print a tel = {'jack': 'aaaaa', 'sape': 4139} print tel['jack']
def run(cls, description): """ generated source for method run """ # This class is not put together in any "optimal" way, so it's left in # an unpolished state for now. A better version would use estimates of # the impact of breaking apart rules. (It also needs to stop itself from # making multiple new relations with the same meaning.) # This version will be rather advanced. # In particular, it will try to incorporate # 1) More thorough scanning for condensations; # 2) Condensations that are only safe to perform because of mutexes. # TODO: Don't perform condensations on stuff like (add _ _ _)... # In general, don't perform condensations where the headroom is huge? # Better yet... DON'T perform condensations on recursive functions! # As for headroom... maybe make sure that # of vars eliminated > # "kept" # Or make sure none are kept? Use directional connected components? description = GdlCleaner.run(description) description = DeORer.run(description) description = VariableConstrainer.replaceFunctionValuedVariables(description) # How do we define a condensation, and what needs to be true in it? # Definition: A condensation set is a set of conjuncts of a # sentence. # Restrictions: # 1) There must be some variable not in the head of the sentence that # appears exclusively in the condensation set. (This means we can # easily find sets one of which must be a condensation set.) # 2) For any variable appearing in a distinct or not conjunct in the set, # there must be a positive conjunct in the set also containing that # variable. This does apply to variables found in the head. # 3) There must be at least one non-distinct literal outside the # condensation set. # How mutexes work: # Say we have a rule # (<= (r1 ?b) # (r2 ?a ?b ?c) # (r3 ?b ?c) # (r4 ?a) # (r5 ?c)) # If we wanted to factor out ?a, we'd normally have to do # (<= (r6 ?b ?c) # * (r2 ?a ?b ?c) # * (r4 ?a)) # * (<= (r1 ?b) # * (r6 ?b ?c) # * (r3 ?b ?c) # * (r5 ?c)) # * But if we know r2 is a mutex, instead we can do (notice r2 splitting): # * (<= (r6 ?b) # * (r2 ?a ?b ?c) # * (r4 ?a)) # * (<= (r1 ?b) # * (r2 ?a ?b ?c) # * (r6 ?b) # * (r3 ?b ?c) # * (r5 ?c)) # * Which in turn becomes: # * (<= (r6 ?b) # * (r2 ?a ?b ?c) # * (r4 ?a)) # * (<= (r7 ?b) # * (r2 ?a ?b ?c) # * (r3 ?b ?c) # * (r5 ?c)) # * (<= (r1 ?b) # * (r6 ?b) # * (r7 ?b)) # * Both r6 and r7 can be further condensed to ignore ?c and ?a, # * respectively. What just happened? # * 1) The condensation set for ?a included the mutex r2. # * 2) r2 (by itself) would have required ?c to be included as an # * argument passed back to the original rule, which is undesirable. # * Instead, as it's a mutex, we leave a copy in the original rule # * and don't include the ?c. # * # * So, what kind of algorithm can we find to solve this task? # newDescription = ArrayList() rulesToAdd = LinkedList() for gdl in description: if isinstance(gdl, (GdlRule, )): rulesToAdd.add(gdl) else: newDescription.add(gdl) # Don't use the model indiscriminately; it reflects the old description, # not necessarily the new one model = SentenceDomainModelFactory.createWithCartesianDomains(description) model = SentenceDomainModelOptimizer.restrictDomainsToUsefulValues(model) sentenceNameSource = UnusedSentenceNameSource.create(model) constantChecker = ConstantCheckerFactory.createWithForwardChaining(model) constantForms = model.getConstantSentenceForms() ConcurrencyUtils.checkForInterruption() curDescription = Lists.newArrayList(description) while not rulesToAdd.isEmpty(): if isRecursive(curRule): # Don't mess with it! newDescription.add(curRule) continue if SentenceModelUtils.inSentenceFormGroup(curRuleHead, constantForms): newDescription.add(curRule) continue ConcurrencyUtils.checkForInterruption() if condensationSet != None: rulesToAdd.addAll(newRules) # Since we're making only small changes, we can readjust # the model as we go, instead of recomputing it replacementDescription.removeAll(oldRules) replacementDescription.addAll(newRules) curDescription = replacementDescription model = augmentModelWithNewForm(model, newRules) else: newDescription.add(curRule) return newDescription
def createCharacter(self, worldName, uid, properties): ot = Template() name = properties.get("characterName") # check to see that the name is valid # we may also want to check for uniqueness and reject bad words here if not name or name == "": properties.put("errorMessage", "Invalid name") return 0 meshName = None gender = properties.get("sex") if gender == "female": meshName = "human_female.mesh" elif gender == "male": meshName = "human_male.mesh" if meshName: displayContext = DisplayContext(meshName, True) submeshInfo = meshInfo[meshName] for entry in submeshInfo: displayContext.addSubmesh(DisplayContext.Submesh(entry[0], entry[1])) ot.put(WorldManagerClient.NAMESPACE, WorldManagerClient.TEMPL_DISPLAY_CONTEXT, displayContext) statProperties = ["strength","dexterity","wisdom","intelligence", "class"] for statProp in statProperties: if (not properties.get(statProp)): properties.put("errorMessage", "Missing property "+statProp) return 0 # get combat settings strength = int(properties.get("strength")) dexterity = int(properties.get("dexterity")) wisdom = int(properties.get("wisdom")) intelligence = int(properties.get("intelligence")) player_class = str(properties.get("class")) # get default instance oid instanceOid = InstanceClient.getInstanceOid("default") if not instanceOid: Log.error("SampleFactory: no 'default' instance") properties.put("errorMessage", "No default instance") return 0 # set the spawn location spawnMarker = InstanceClient.getMarker(instanceOid, "spawn") spawnMarker.getPoint().setY(0) # override template ot.put(WorldManagerClient.NAMESPACE, WorldManagerClient.TEMPL_NAME, name) ot.put(WorldManagerClient.NAMESPACE, WorldManagerClient.TEMPL_INSTANCE, Long(instanceOid)) ot.put(WorldManagerClient.NAMESPACE, WorldManagerClient.TEMPL_LOC, spawnMarker.getPoint()) ot.put(WorldManagerClient.NAMESPACE, WorldManagerClient.TEMPL_ORIENT, spawnMarker.getOrientation()) restorePoint = InstanceRestorePoint("default", spawnMarker.getPoint()) restorePoint.setFallbackFlag(True) restoreStack = LinkedList() restoreStack.add(restorePoint) ot.put(Namespace.OBJECT_MANAGER, ObjectManagerClient.TEMPL_INSTANCE_RESTORE_STACK, restoreStack) ot.put(Namespace.OBJECT_MANAGER, ObjectManagerClient.TEMPL_CURRENT_INSTANCE_NAME, "default") ot.put(Namespace.OBJECT_MANAGER, ObjectManagerClient.TEMPL_PERSISTENT, Boolean(True)) ot.put(ClassAbilityClient.NAMESPACE, "class", player_class) ot.put(CombatClient.NAMESPACE, "strength", MarsStat("strength", strength)) ot.put(CombatClient.NAMESPACE, "dexterity", MarsStat("dexterity", dexterity)) ot.put(CombatClient.NAMESPACE, "wisdom", MarsStat("wisdom", wisdom)) ot.put(CombatClient.NAMESPACE, "intelligence", MarsStat("intelligence", intelligence)) ot.put(CombatClient.NAMESPACE, "stamina", MarsStat("stamina", int(int(strength)*1.5))) ot.put(CombatClient.NAMESPACE, "stamina-max", MarsStat("stamina-max", int(int(strength)*1.5))) ot.put(CombatClient.NAMESPACE, "mana", MarsStat("mana", int(intelligence)*2)) ot.put(CombatClient.NAMESPACE, "mana-max", MarsStat("mana-max", int(intelligence)* 2)) ot.put(CombatClient.NAMESPACE, "health", MarsStat("health", int(strength) * 2)) ot.put(CombatClient.NAMESPACE, "health-max", MarsStat("health-max", int(strength)*2)) ot.put(CombatClient.NAMESPACE, "experience", MarsStat("experience", 0, 100)) ot.put(CombatClient.NAMESPACE, "level", MarsStat("level", 1, 100)) # generate the object objOid = ObjectManagerClient.generateObject("DefaultPlayer", ot) Log.debug("SampleFactory: generated obj oid=" + str(objOid)) return objOid
def call(self): return IJ.openImage(self.filepath) # Assumes the Google Drive is mounted via rclone --transfers 8 # and that the CPU has at least 8 cores exe = Executors.newFixedThreadPool(8) try: filenames = sorted(filename for filename in os.listdir(src) if filename.endswith(extension)) futures = LinkedList() for filename in filenames: futures.add(exe.submit(Load(os.path.join(src, filename)))) stack = ImageStack() count = 0 impStack = None while not futures.isEmpty(): # if Thread.currentThread().isInterrupted(): print "Interrupted" break # imp = futures.removeFirst().get() stack.addSlice("", imp.getProcessor())
class BuildingInBuilding : BUILDING_INSIDE_BUILDING = 2001; def __init__ (self): self.primitivesToCheck = LinkedList(); self.index = QuadBuckets(); print 'building in building' #super(tr("Building inside building"), tr("Checks for building areas inside of buildings.")); def visitn(self,n) : # print "visitn:" # print n if (n.isUsable() and isBuilding(n)) : if not self.primitivesToCheck.contains(n): # print "adding :" n self.primitivesToCheck.add(n); else: print "duplicate p :" # print n def visitw(self,w) : print "visitw:" # print w if (w.isUsable() and w.isClosed() and isBuilding(w)) : self.primitivesToCheck.add(w) self.index.add(w) print "added" def isInPolygon(n, polygon) : return Geometry.nodeInsidePolygon(n, polygon); def sameLayers( w1, w2) : if w1.get("layer") is not None : l1 = w1.get("layer") else : l1 = "0"; if w2.get("layer") is not None : l2 = w2.get("layer") else : l2 ="0"; return l1.equals(l2); def evaluateNode(self,p,obj): print "te" # print p # print obj def endTest2(self): for p in self.primitivesToCheck : collection = self.index.search(p.getBBox()) for object in collection: if (not p.equals(object)): if (isinstance(p,Node)): self.evaluateNode(p, object) else : print p # else if (p instanceof Way) # return evaluateWay((Way) p, object); # else if (p instanceof Relation) # return evaluateRelation((Relation) p, object); # return false; def endTest(self) : print "end" # bbox = BBox(-180,-90,180,90) bbox = BBox(-1000,-900,1800,900) print self.index collection = self.index.search(bbox) # print collection DisplayTable(self.primitivesToCheck)
print "<html><body>" print "Python" print "<p>" + currentNode.getProperty('text').getString() + "</p>" print "<!-- test access to sling java classes -->" from java.util import LinkedList list = LinkedList() list.add("LinkedListTest") print "<p>Test" + list.get(0) + "</p>" print "</body></html>"
for app in apps: clusterTargets = LinkedList() serverTargets = LinkedList() sServers = "" context = cMap.get(app) if context != "None": dep = AdminConfig.getid('/Deployment:' + app + '/') server = AdminConfig.getid('/Deployment:' + app + '/ServerTarget:/') cluster = AdminConfig.getid('/Deployment:' + app + '/ClusteredTarget:/') if cluster != "": cTargets = cluster.split(lineSeperator) for target in cTargets: cName = AdminConfig.showAttribute(target, 'name') clusterTarget = ClusteredTarget(cName) clusterTargets.add(clusterTarget) if server != "": sTargets = server.split(lineSeperator) for target in sTargets: sName = AdminConfig.showAttribute(target, 'name') nName = AdminConfig.showAttribute(target, 'nodeName') serverTarget = ServerTarget(nName, sName) serverTargets.add(serverTarget) application = Application(app, clusterTargets, serverTargets) rule = ExclusionRule('Application', 'name', app) if not ignore.contains(app) and not exclude.contains(rule): writer.addApplicationEntry(application, 0) else: print " Application " + app + " not found in Mappings.dat" print " You may need to run the utility to update the file"
def createCharacter(self, worldName, uid, properties): ot = Template() name = properties.get("characterName") # check to see that the name is valid # we may also want to check for uniqueness and reject bad words here if not name or name == "": properties.put("errorMessage", "Invalid name") return 0 meshName = None gender = properties.get("sex") if gender == "female": meshName = "human_female.mesh" elif gender == "male": meshName = "human_male.mesh" if meshName: displayContext = DisplayContext(meshName, True) submeshInfo = meshInfo[meshName] for entry in submeshInfo: displayContext.addSubmesh( DisplayContext.Submesh(entry[0], entry[1])) ot.put(WorldManagerClient.NAMESPACE, WorldManagerClient.TEMPL_DISPLAY_CONTEXT, displayContext) statProperties = [ "strength", "dexterity", "wisdom", "intelligence", "class" ] for statProp in statProperties: if (not properties.get(statProp)): properties.put("errorMessage", "Missing property " + statProp) return 0 # get combat settings strength = int(properties.get("strength")) dexterity = int(properties.get("dexterity")) wisdom = int(properties.get("wisdom")) intelligence = int(properties.get("intelligence")) player_class = str(properties.get("class")) # get default instance oid instanceOid = InstanceClient.getInstanceOid("default") if not instanceOid: Log.error("SampleFactory: no 'default' instance") properties.put("errorMessage", "No default instance") return 0 # set the spawn location spawnMarker = InstanceClient.getMarker(instanceOid, "spawn") spawnMarker.getPoint().setY(0) # override template ot.put(WorldManagerClient.NAMESPACE, WorldManagerClient.TEMPL_NAME, name) ot.put(WorldManagerClient.NAMESPACE, WorldManagerClient.TEMPL_INSTANCE, Long(instanceOid)) ot.put(WorldManagerClient.NAMESPACE, WorldManagerClient.TEMPL_LOC, spawnMarker.getPoint()) ot.put(WorldManagerClient.NAMESPACE, WorldManagerClient.TEMPL_ORIENT, spawnMarker.getOrientation()) restorePoint = InstanceRestorePoint("default", spawnMarker.getPoint()) restorePoint.setFallbackFlag(True) restoreStack = LinkedList() restoreStack.add(restorePoint) ot.put(Namespace.OBJECT_MANAGER, ObjectManagerClient.TEMPL_INSTANCE_RESTORE_STACK, restoreStack) ot.put(Namespace.OBJECT_MANAGER, ObjectManagerClient.TEMPL_CURRENT_INSTANCE_NAME, "default") ot.put(Namespace.OBJECT_MANAGER, ObjectManagerClient.TEMPL_PERSISTENT, Boolean(True)) ot.put(ClassAbilityClient.NAMESPACE, "class", player_class) ot.put(CombatClient.NAMESPACE, "strength", MarsStat("strength", strength)) ot.put(CombatClient.NAMESPACE, "dexterity", MarsStat("dexterity", dexterity)) ot.put(CombatClient.NAMESPACE, "wisdom", MarsStat("wisdom", wisdom)) ot.put(CombatClient.NAMESPACE, "intelligence", MarsStat("intelligence", intelligence)) ot.put(CombatClient.NAMESPACE, "stamina", MarsStat("stamina", int(int(strength) * 1.5))) ot.put(CombatClient.NAMESPACE, "stamina-max", MarsStat("stamina-max", int(int(strength) * 1.5))) ot.put(CombatClient.NAMESPACE, "mana", MarsStat("mana", int(intelligence) * 2)) ot.put(CombatClient.NAMESPACE, "mana-max", MarsStat("mana-max", int(intelligence) * 2)) ot.put(CombatClient.NAMESPACE, "health", MarsStat("health", int(strength) * 2)) ot.put(CombatClient.NAMESPACE, "health-max", MarsStat("health-max", int(strength) * 2)) ot.put(CombatClient.NAMESPACE, "experience", MarsStat("experience", 0, 100)) ot.put(CombatClient.NAMESPACE, "level", MarsStat("level", 1, 100)) # generate the object objOid = ObjectManagerClient.generateObject("DefaultPlayer", ot) Log.debug("SampleFactory: generated obj oid=" + str(objOid)) return objOid
def createCharacter(self, worldName, uid, properties): ot = Template() name = properties.get("characterName") name = name.lower() name = name.title() meshName = None gender = properties.get("gender") race = properties.get("race") skinColouring = properties.get("skinColour") meshName = properties.get("prefab") umaData = HashMap() umaData["Gender"] = gender umaData["Race"] = race umaData["skinColour"] = properties.get("skinColour") umaData["hairColour"] = properties.get("hairColour") umaData["hairStyle"] = properties.get("hairStyle") '''umaData["facialHairStyle"] = properties.get("facialHairStyle") umaData["hairSize"] = float(properties.get("hairSize")) umaData["height"] = float(properties.get("height")) umaData["upperMuscle"] = float(properties.get("upperMuscle")) umaData["upperWeight"] = float(properties.get("upperWeight")) umaData["lowerMuscle"] = float(properties.get("lowerMuscle")) umaData["lowerWeight"] = float(properties.get("lowerWeight")) umaData["breastSize"] = float(properties.get("breastSize")) umaData["foreheadSize"] = float(properties.get("foreheadSize")) umaData["foreheadPosition"] = float(properties.get("foreheadPosition")) umaData["noseSize"] = float(properties.get("noseSize")) umaData["nosePosition"] = float(properties.get("nosePosition")) umaData["noseCurve"] = float(properties.get("noseCurve")) umaData["noseWidth"] = float(properties.get("noseWidth")) umaData["noseFlatten"] = float(properties.get("noseFlatten")) umaData["earSize"] = float(properties.get("earSize")) umaData["earPosition"] = float(properties.get("earPosition")) umaData["cheekSize"] = float(properties.get("cheekSize")) umaData["cheekPosition"] = float(properties.get("cheekPosition")) umaData["lowerCheckPosition"] = float(properties.get("lowerCheckPosition")) umaData["lipsSize"] = float(properties.get("lipsSize")) umaData["mouthSize"] = float(properties.get("mouthSize")) umaData["jawPosition"] = float(properties.get("jawPosition")) umaData["chinSize"] = float(properties.get("chinSize")) umaData["chinPosition"] = float(properties.get("chinPosition"))''' # TODO: change the instance used based on race? #instanceName = "default" instanceName = properties.get("instanceName") # Set racial/gender based property values portrait = "" scaleFactor = 1.0 overheadOffset = 1900 soundSet = 4 spawnPoint = "spawn" zone = properties.get("instanceName") subzone = "" #meshName = "human_male" #meshName = "char_smoo.mesh" if meshName: displayContext = DisplayContext(meshName, True) displayContext.addSubmesh(DisplayContext.Submesh("", "")) #submeshInfo = meshInfo[meshName] #for entry in submeshInfo: # displayContext.addSubmesh(DisplayContext.Submesh(entry[0], entry[1])) ot.put(WorldManagerClient.NAMESPACE, WorldManagerClient.TEMPL_DISPLAY_CONTEXT, displayContext) # Do a few extra stat calcs #manamax = int(float(mana_base) * willpower / 100) #healthmax = int(float(health_base) * endurance / 100) # get default instance oid instanceOid = InstanceClient.getInstanceOid(instanceName) if not instanceOid: Log.error("SampleFactory: no 'default' instance") properties.put("errorMessage", "No default instance") return 0 # set the spawn location Log.debug("SPAWN: spawn marker name=" + str(spawnPoint) + " and race=" + str(race)) spawnMarker = InstanceClient.getMarker(instanceOid, spawnPoint) #spawnMarker.getPoint().setY(0) # override template ot.put(WorldManagerClient.NAMESPACE, WorldManagerClient.TEMPL_NAME, name) ot.put(WorldManagerClient.NAMESPACE, WorldManagerClient.TEMPL_INSTANCE, instanceOid) ot.put(WorldManagerClient.NAMESPACE, WorldManagerClient.TEMPL_LOC, spawnMarker.getPoint()) ot.put(WorldManagerClient.NAMESPACE, WorldManagerClient.TEMPL_ORIENT, spawnMarker.getOrientation()) ot.put(WorldManagerClient.NAMESPACE, "accountId", uid) ot.put(WorldManagerClient.NAMESPACE, "model", meshName) ot.put(WorldManagerClient.NAMESPACE, "race", race) ot.put(WorldManagerClient.NAMESPACE, "charactername", name) ot.put(WorldManagerClient.NAMESPACE, "world", instanceName) ot.put(WorldManagerClient.NAMESPACE, "category", 1) ot.put(WorldManagerClient.NAMESPACE, "zone", zone) zones = LinkedList() ot.put(WorldManagerClient.NAMESPACE, "zones", zones) ot.put(WorldManagerClient.NAMESPACE, "subzone", subzone) subzones = LinkedList() ot.put(WorldManagerClient.NAMESPACE, "subzones", subzones) ot.put(WorldManagerClient.NAMESPACE, "hearthLoc", spawnMarker.getPoint()) ot.put(WorldManagerClient.NAMESPACE, "hearthInstance", instanceName) ot.put(WorldManagerClient.NAMESPACE, "umaData", umaData) ot.put(WorldManagerClient.NAMESPACE, "primaryItem", 0) ot.put(WorldManagerClient.NAMESPACE, "secondaryItem", 0) ot.put(WorldManagerClient.NAMESPACE, "playerAppearance", 0) ot.put(WorldManagerClient.NAMESPACE, "scaleFactor", scaleFactor) ot.put(WorldManagerClient.NAMESPACE, "portrait", portrait) ot.put(WorldManagerClient.NAMESPACE, "soundSet", soundSet) ot.put(WorldManagerClient.NAMESPACE, "walk_speed", 3) ot.put(WorldManagerClient.NAMESPACE, "movementState", 1) factionData = HashMap() factionData.put(4, PlayerFactionData(4, "Randarock", 1000, "The Legion", 1)) faction = 1 ot.put(WorldManagerClient.NAMESPACE, "factionData", factionData) ot.put(WorldManagerClient.NAMESPACE, "faction", faction) # Other Properties ot.put(WorldManagerClient.NAMESPACE, "busy", False) ot.put(Namespace.QUEST, ":currentQuests", "") ot.put(SocialClient.NAMESPACE, ":channels", "") lastGames = LinkedList() # Keeps track of the time when the last 3 games were played #ot.put(WorldManagerClient.NAMESPACE, "lastGames", lastGames) #ot.put(InventoryClient.NAMESPACE, InventoryClient.TEMPL_ITEMS, "*1;*2;*5;*6;*7;*8;*9;*10") ot.put(InventoryClient.NAMESPACE, InventoryClient.TEMPL_ITEMS, "") #restorePoint = InstanceRestorePoint("default", spawnMarker.getPoint()) restorePoint = InstanceRestorePoint(instanceName, spawnMarker.getPoint()) restorePoint.setFallbackFlag(True) restoreStack = LinkedList() restoreStack.add(restorePoint) ot.put(Namespace.OBJECT_MANAGER, ObjectManagerClient.TEMPL_INSTANCE_RESTORE_STACK, restoreStack) ot.put(Namespace.OBJECT_MANAGER, ObjectManagerClient.TEMPL_CURRENT_INSTANCE_NAME, instanceName) ot.put(Namespace.OBJECT_MANAGER, ObjectManagerClient.TEMPL_PERSISTENT, Boolean(True)) # Combat Properties/stats ot.put(CombatClient.NAMESPACE, "aspect", "Earth") ot.put(CombatClient.NAMESPACE, "attackable", Boolean(True)) ot.put(CombatClient.NAMESPACE, "attackType", "crush") ot.put(CombatClient.NAMESPACE, "weaponType", "Unarmed") effectsList = LinkedList() ot.put(CombatClient.NAMESPACE, "effects", effectsList) # Arena Properties ot.put(WorldManagerClient.NAMESPACE, "arenaID", -1) # generate the object objOid = ObjectManagerClient.generateObject(-1, ObjectManagerPlugin.MOB_TEMPLATE, ot) Log.debug("SampleFactory: generated obj oid=" + str(objOid)) return objOid
print ' ',res,'customers deleted.' if ( res == len( toDelete ) ): return 0; print ' Deleted',res,'customers when',len(toDelete),'should have been deleted.' return 1; def printUsage(): print 'Usage:', sys.argv[0], '-c customer_prefix1 -c customer_prefix2 -d domainName -d domainName ...\n' sys.exit( -1 ) if __name__ == '__main__': customerList = LinkedList(); domainList = LinkedList(); numArgs = len( sys.argv ) - 1; if ( numArgs == 0 or numArgs % 2 != 0 ): printUsage(); i = 1; while ( i < numArgs ): if ( sys.argv[i] == "-c" ): customerList.add( sys.argv[i+1] ); elif ( sys.argv[i] == "-d" ): domainList.add( sys.argv[i+1] ); i += 2; res = deleteCustomers( customerList, domainList ); sys.exit( res )