jython

Migrating from CPython to Jython

I'm considering moving my code (around 30K LOC) from CPython to Jython, so that I could have better integration with my java code. Is there a checklist or a guide I should look at, to help my with the migration? Does anyone have experience with doing something similar? From reading the Jython site, most of the problems seem too obscur...

Jython, Query multiple columns dynamically

Hey all, I am working with a oracle database and Jython. I can get data pulled from the database no problem. results = statement.executeQuery("select %s from %s where column_id = '%s'", % (column, table, id)) This works fine if I want to pull one column of data. Say I wanted to loop threw a list like this: columns = ['column1', 'c...

How to connect to database from Jython

I cannot connect to database from my Jython program. Pure Java programs can connect, and I can connect to db from Jython but only using JDBC-ODBC bridge: "sun.jdbc.odbc.JdbcOdbcDriver". If I use native JDBC driver my program fails with "driver not found" exception. Code: import sys from com.ziclix.python.sql import zxJDBC connection1 ...

Jython and python modules

I've just started using the PythonInterpreter from within my Java classes, and it works great! However, if I try to include python modules (re, HTMLParser, etc.), I'm receiving the following exception (for re): Exception in thread "main" Traceback (innermost last): File "", line 1, in ? ImportError: no module named re How could I m...

Jython support in editors?

I've recently started writing some performance tests in The Grinder 3, and one of the first things I noticed is that PyCheckMate doesn't work because it can't find some of the imports. Which editor(s) provide the best support for Jython? ...

Using a java library from python.

I have a python app and java app. The python app generates input for the java app and invokes it on the command line. I'm sure there must be a more elegant solution to this; just like using JNI to invoke C code from Java. Any pointers? (FYI I'm v. new to Python) Clarification (at the cost of a long question: apologies) The py app (w...

Jython zxJDBC cursor.tables() always returns None

I am using Jython 2.2.1 and MySQL Connector/J 5.1 to access a MySQL database. I would like to use zxJDBC's cursor.tables() method to retrieve a list of tables in that database. However, this method always returns None. According to the zxJDBC documentation, cursor.tables() is the same as Java's DatabaseMetaData.getTables(). When I cal...

Is it possible to use SWT from Jython?

The SWT-Gui looks very nice. Is there an easy way to use it in Jython ? ...

Event handling with Jython & Swing

I'm making a GUI by using Swing from Jython. Event handling seems to be particularly elegant from Jython, just set JButton("Push me", actionPerformed = nameOfFunctionToCall) However, trying same thing inside a class gets difficult. Naively trying JButton("Push me", actionPerformed = nameOfMethodToCall) or JButton("Push me", action...

Is there a Python equivalent of Groovy/Grails for Java

I'm thinking of something like Jython/Jango? Does this exist? Or does Jython allow you to do everything-Python in Java including Django (I'm not sure how Jython differs from Python)? ...

Jython, ImageInfo

Hi, I trying to use ImageInfo and Jython to get information from a image on my harddrive. I have imported the module fine but keep getting this error: TypeError: setInput(): expected 2 args; got 1 And this is the code I am trying to use: filename = "C:\\image.jpg" img = ImageInfo.setInput(filename) Could anyone point out what I a...

Security with Java Scripting (JRuby, Jython, Groovy, BeanShell, etc)

I'm looking to run some un-verified scripts (written in a yet-to-be-determined language, but needs to be Java-based, so JRuby, Groovy, Jython, BeanShell, etc are all candidates). I want these scripts to be able to do some things and restricted from doing other things. Normally, I'd just go use Java's SecurityManager and be done with it....

How can I add jars to the classpath when I invoke Jython *without* adding them to $CLASSPATH?

I'd like to do something similar to jython -cp FOO:BAR:BAZ argle.py. If I add FOO, BAR, and BAZ to $CLASSPATH this works. I tried to add them to sys.path at run-time, but that doesn't appear to work for jars. It does work if I add a path to the expanded jars to sys.path at runtime. Is there a simple alternative to exploding the jar file...

Background Image on Jython GUI

Hi, I am trying to create a GUI in Jython. I want to import a background image that I can place buttons and textfields on. I've already created the frame with the buttons and labels in their appropriate places, I just need to know how to import a background image. The GUI is implemented in Jython. ...

Cross-platform way to get PIDs by process name in python

Several processes with the same name are running on host. What is the cross-platform way to get PIDs of that processes by name using python or jython? It's like pidof but in python (I don't have pidof anyway). I can't parse /proc because it might be unavailable (on HP-UX). I do not want to run os.popen('ps') and parse the output becaus...

Why can't I use my Jython class in an imported module?

I have a couple of Jython modules living in the same directory. One of them defines the following class: from java.lang import Runnable class MyTask(Runnable): def __init__(self, params): Runnable.__init__(self) self._params = params def run(self): # do stuff print "Done doing stuff" I can ins...

Why Jython behaves inconsistently when tested with PyStone?

I've been playing recently with Jython and decided to do some quick and dirty benchmarking with pystone. In order to have a reference, I first tested cPython 2.6, with an increasing numbers of loops (I thought this may be relevant as Jython should start to profit from the JIT only after some time). (richard garibaldi):/usr/local/src/pyb...

Jython Netbeans with JavaSE

Hello everyone, I want to develop a Java application mixing java with jython. I am using the IDE Netbeans with the python plugin. How do i work on this? (There is a built in support for Groovy with javaSE from IDE call Groovy classes from Java code, and Java classes from Groovy code but not for jython) ref: http://www.netbeans.org/fe...

Rename files, Python/Jython

I have a directory full of files, some which have an ampersand in their names. I would like to rename all the files with ampersands and replace each ampersand with a plus (+). I am working with around 10k files. What would be the best method to do this? ...

Best resources for starting Jython

I just got my first Jython (and Python) project, and I was wondering what documentation, IDEs, etc. are best suited to a Java buff like me. I know there are a lot of questions about starting out with Python, so I'm asking for things that might be specific to Jython. Where should I start? If it helps, I'm running Linux and Solaris only....