jython

Import jar API in Jython

五迷三道 提交于 2019-12-07 03:18:25
问题 I am trying to import a Java API, which is distributed as a jar file. I followed the instructions from this answer at a similar question in Stack Overflow, but it didn't work. In Jython, I did: >>> import sys >>> sys.path.append("/path/to/jar/api") >>> from com.thingmagic import * Traceback (most recent calls last): File "<stdin>", line 1, in <module> ImportError: no module named thingmagic Am I missing something or did I do something wrong? 回答1: You need to provide the full path of the JAR

sqlite3 module for Jython

若如初见. 提交于 2019-12-07 03:01:12
问题 I'm using Java Scripting API to execute some external Python scripts from my Java application. The python scripts use sqlite3 module. Execution of the application is resulting in error ImportError: No module named sqlite3 As I look into the Lib directory(which is in the classpath) of Jython, there's no sqlite3 module. Hence, my search begins and I found one _sqlite3.py file which is an implementation of javasqlite (http://bugs.jython.org/issue1682864). It's use produced more similar kind of

Fading a picture gradually

荒凉一梦 提交于 2019-12-07 02:36:55
问题 The idea of this function is to fade the top half only of the picture (make it gradually darker). Here is what I have but it seems to be making all of the top half solid black. def fadeDownFromBlack(pic1): w=getWidth(pic1) h=getHeight(pic1) for y in range(0,h/2): for x in range(0,w): px=getPixel(pic1,x,y) setBlue(px,y*(2.0/h)) setRed(px,y*(2.0/h)) setGreen(px,y*(2.0/h)) 回答1: Let's look at just one line here: setBlue(px,y*(2.0/h)) and key part here is y*(2.0/h) y changes, as you go down. Let's

Using JRuby/Jython for Ruby/Python interoperability?

房东的猫 提交于 2019-12-06 20:59:54
问题 Quite-probably a silly question, as I don't know much about Java/Jython/JRuby/bytecode, but.. I stumbled across _why's unholy again today.. It allows you to output Python bytecode from Ruby code.. Basically allowing them to produce the same bytecode.. Jython outputs Java bytecode, as does JRuby.. Since these both compile to the same bytecode, does this mean you could potentially use any Python library from Ruby, and Ruby libraries from Python? 回答1: No, that won't work. At least not the way

Why does this Jython loop fail after a single run?

前提是你 提交于 2019-12-06 17:30:34
问题 I've got the following code: public static String getVersion() { PythonInterpreter interpreter = new PythonInterpreter(); try { interpreter.exec(IOUtils.toString(new FileReader("./Application Documents/Scripts/Version.py"))); PyObject get_version = interpreter.get("get_latest_version"); PyObject result = get_version.__call__(interpreter.get("url")); String latestVersion = (String) result.__tojava__(String.class); interpreter.close(); return latestVersion; } catch (IOException ex) { ex

In Sikuli, How to find and click a minimum of 3 identical images?

半腔热情 提交于 2019-12-06 15:51:45
I'm trying to click no less than 3 of the same image, but with findAll() I am having difficulty with sikuli wanting to select only 1 image when I don't want it to select any if there is not 3 or more. if exists(Pattern("1474201252795.png").similar(0.95)): wait(1) for x in findAll(Pattern("1474201252795.png").similar(0.95)): click(x) So just count the images first and check if the count is higher than 3. imageCount=0 images = [] # find all images and store them in a list to prevent additional search for image in findAll("Win7StartBtn.png"): images.append(image) #check list length and act

Jython @property SyntaxError: mismatched input '' expecting CLASS

牧云@^-^@ 提交于 2019-12-06 15:39:43
I tried to run this example from the docs in the Jython interpreter: http://www.jython.org/docs/library/functions.html class C(object): def __init__(self): self._x = None @property def x(self): """I'm the 'x' property.""" return self._x @x.setter def x(self, value): self._x = value @x.deleter def x(self): del self._x Just entering the first 4 lines (up to and including @property ) yields a SyntaxError: >>> class C(object): ... def __init__(self): ... self._x = None ... @property File "<stdin>", line 4 @property ^ SyntaxError: mismatched input '' expecting CLASS Update: I am on Jython 2.5.2

Unable to provide user input in PyDev console on Eclipse with Jython

巧了我就是萌 提交于 2019-12-06 15:04:22
问题 I was trying to debug a jython program for a long time that I was running in Eclipse using the PyDev plugin, but it worked once I ran it from the terminal instead. I suspected it might be that the user input wasn't working on the Eclipse console, so I tried running the most basic input program for jython I could think of name = raw_input("What is your name? ") print "Hello %s" % (name) When this runs it outputs What is your name? and when I type in the console, the normal green text appears,

Mirroring an Image by its Diagonal in Jython

岁酱吖の 提交于 2019-12-06 14:21:30
So I need to mirror an image. The top right side of the image should be flipped over to the bottom left side. I created a function that flips the top left side of an image to the bottom right, but I just can't seem to figure out how to do it the other way. Here's the code: def mirrorPicture(picture): height = getHeight(canvas) width = height # to make mirroring easier, let us make it a square with odd number # of rows and columns if (height % 2 == 0): height = width = height -1 # let us make the height and width odd maxHeight = height - 1 maxWidth = width - 1 for y in range(0, maxWidth): for x

Could not install packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle

半城伤御伤魂 提交于 2019-12-06 14:16:06
问题 I am trying to install a robotframework library called ImageHorizonLibrary. However, I am running into an issue. I am trying to install it using pip in the jython environment: /Users/nimam/jython2.7.0/Lib/site-packages I do the following: sudo -H pip install robotframework-imagehorizonlibrary And I get the following error: Could not install packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle, invalid path: __pyclasspath__/pip/_vendor/certifi/cacert.pem If