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 setFile(self, file): try: self.spritefile = Spritefile(file) self.items = LinkedList(self.spritefile.sprites.keySet()) Collections.sort(self.items) except: self.items = [] self.cache = {} self.positions = []
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 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): 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 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() 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 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 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
from com.ibm.ws.legacycell.xmlutils import * from com.ibm.ws.legacycell.jdk142 import * from com.ibm.ws.legacycell.jdkcommon import * from com.ibm.ws.legacycell import * from com.ibm.ws.legacycell.exceptions import * from java.lang import System # init lineSeperator = java.lang.System.getProperty('line.separator') last = len(sys.argv) workDir = sys.argv[last - 1] mappingData = workDir + "/bin/Mappings.dat" cMap = HashMap() factory = XMLUtilFactory.instance() writer = factory.get142DomWriter() ignore = LinkedList() tList = LinkedList() parser = RuleParser() ############# Map(Context) Population ############################# #DESC : Populate Context mapping def populateContext(): f = open(mappingData, "r") lines = f.readlines() for line in lines: words = line.split('*') if len(words) == 0: continue app = words[0]
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']
from __future__ import print_function import sys, traceback from synchronize import make_synchronized from java.util.concurrent import Callable, Future, Executors, ThreadFactory, TimeUnit from java.util.concurrent.atomic import AtomicInteger from java.lang.reflect.Array import newInstance as newArray from java.lang import Runtime, Thread, Double, Float, Byte, Short, Integer, Long, Boolean, Character, System, Runnable from net.imglib2.realtransform import AffineTransform3D from net.imglib2.view import Views from java.util import LinkedHashMap, Collections, LinkedList, HashMap from java.lang.ref import SoftReference from java.util.concurrent.locks import ReentrantLock printService = Executors.newSingleThreadScheduledExecutor() msgQueue = Collections.synchronizedList(LinkedList()) # synchronized def printMsgQueue(): while not msgQueue.isEmpty(): try: print(msgQueue.pop()) except: System.out.println(str(sys.exc_info())) class Printer(Runnable): def __init__(self, stdout): self.stdout = sys.stdout def run(self): while not msgQueue.isEmpty():
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
# See the License for the specific language governing permissions and # limitations under the License. ## # Examples of Jython-specific functionality # @category: Examples.Python # Using Java data structures from Jython python_list = [1, 2, 3] java_list = java.util.LinkedList(java.util.Arrays.asList(1, 2, 3)) print str(type(python_list)) print str(type(java_list)) # Importing Java packages for simpler Java calls from java.util import LinkedList, Arrays python_list = [1, 2, 3] java_list = LinkedList(Arrays.asList(1, 2, 3)) print str(type(python_list)) print str(type(java_list)) # Python adds helpful syntax to Java data structures print python_list[0] print java_list[0] # can't normally do this in java print java_list[0:2] # can't normally do this in java # Iterate over Java collection the Python way for entry in java_list: print entry # "in" keyword compatibility print str(3 in java_list)
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>"
from com.ibm.ws.legacycell.exceptions import * from com.ibm.ws.legacycell.security import * from java.net import Inet4Address from java.net import UnknownHostException from java.util import Iterator from java.lang import System ################## Fields ################################# # init encrypt = "false" save = "false" lineSeparator = java.lang.System.getProperty('line.separator') map = HashMap() agentMap = HashMap() installedApps = LinkedList() clusters = LinkedList() decryptor = DesEncryptor() adminUser = sys.argv[0] adminPass = sys.argv[1] encrypt = sys.argv[2] save = sys.argv[3] if encrypt == "true": adminUser = decryptor.decodeString(adminUser) adminPass = decryptor.decodeString(adminPass) # Needed in some instances where security values were added # as empty strings - arg parser doesn't treat the empties as # an arg, so specific placing gets thrown off # (Shouldn't be needed with new Code) - will remove after verification workDir = sys.argv[len(sys.argv) - 1]
class Load(Callable): def __init__(self, filepath): self.filepath = filepath 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 #