jython

Jython: is there a clean way to implement a Java interfaces with function references?

I know that I can implement a Java interface with Jython like this: class MyListener (Listener): def foo(self, event): print(str(event)) Python has first-class functions so that seems like an overkill - especially for interfaces with one method. Is there a way to just pass a lambda or function which implements a single method i...

inserting number into oracle sql - using jython

I have this insert command where iam trying to insert a number to be taken from loop i=0 for line in column: myStmt.executeQuery("INSERT INTO REVERSE_COL ( TABLE_NAME,COL_NAME,POS) values (,'test','"+column[i]+"','"+i+"'") i=i+1 POS IS NUMBER DATATYPE but it works if i hard code as 1 i=0 for line in column: myStmt.execut...

next line in jython

Hi everyone , count_record=file.readline() count_prev=count_record[:-1] , i used this to read the previous line and it worked but now when i am using count_next=count_record[:+1] i am not able to read the next line , is there is way to do so read the next time . Thanks for your help ...

Breaking the loop in Jython

Hi everyone, I have a written a loop for and if condition and I want to break to loop completely when if gets satisfied. while count: i=0 for line in read_record: #print str.strip(count[1:28]) #print str.strip(read_record[i]) if string.find(str.strip(read_record[i]),str.strip(count[1:28]))>0: ...

A Question about using jython when run a receving socket in python

Hi, I have not a lot of knowledge of python and network programming. Currently I am trying to implement a simple application which can receive a text message sent by the user, fetch some information from the google search api, and return the results via text message to the user. This application will continue to listening to the users m...

call a jython file from another program

Hi everyone, can i call a jython file from another jython program and execute that . Also i know os.system(cmd.exe)get the system prompt . is it possible that i can trigger cmd.exe and cmd.exe gets poped up into the screen. Thanks ...

one variable for all the sql output

hi everyone myRs=myStmt.executeQuery("select i_col,col_name from tab_col") i=0 while (myRs.next()): list= myRs.getString("I_COL")+','+myRs.getString("COL_NAME") i have a jython code to run a sql statement i want to store all the row of the sql into a single variable. I used to list to store the value but its always storing only t...

display each record of list into a separate line in jython

Hi everyone, how to display record of the list in different line ['0 , INDIVS08 , ODI_TEMP', '1 , C$_0EMPLOYEES , ODI_TEMP', '2 , C$_0PACS08 , ODI_TEMP'] i want to display as '0 , INDIVS08 , ODI_TEMP' , '1 , C$_0EMPLOYEES , ODI_TEMP', '2 , C$_0PACS08 , ODI_TEMP' Thanks for all of your help ...

getting complete sql query in jython

result=sqlstring.executeQuery("select distinct table_name,owner from all_tables ") rs.append(str(i)+' , '+result.getString("table_name")+' , '+result.getString("owner")) If i want to display the query select * from all_tables or ' select count(*) from all_tables' how can i get the output to display . Please suggest thanks ...

How do you invoke a python script inside a jar file using python ?

I'm working on an application that intersperses a bunch of jython and java code. Due to the nature of the program (using wsadmin) we are really restricted to Python 2.1 We currently have a jar containing both java source and .py modules. The code is currently invoked using java, but I'd like to remove this in favor of migrating as muc...

how to do a select * in jython and get the result

Hi everyone, how to do a select * from table in jython and get the result for each row into a list or string. i know how to do for select counmn_name1 ,column_name2 from table1 but not able to figure out for select * Please suggest .thanks ...

running jython bytecode using java

It looks like I'm missing something. When using Jython to run my Python code in Java, Java bytecode files are generated (test.py -> [email protected]). Can I run these classes directly using java? In other words, I want to make this: $ java test@py [additional cp args] work. The intent: writing Python code and not having to give away ...

How do I get the username in Java (ie, who -m in Java) (or Jython 2.1)

Here's the situation. I have a jython 2.1 script in a shared account that needs to know who is calling it. In bash, I can simply use $(who -m) and it will give me the correct username. By "shared account", I mean I log in as myself, then $(sudo su - shared_account) to get to the shared account. I haven't been able to find anything in j...

Is there an easy way to develop with Swing Application Framework (JSR 296) AND Jython?

I'm learning Jython. I developed a simple Swing Application with Jython and it's ok. Now I would to use the Swing Application Framework (JSR 296). I did not find any example in Internet. ...

problem in decoupling urls.py , while following a tutorial of django

http://docs.djangoproject.com/en/dev/intro/tutorial03/ I was at the step Decoupling the URLconfs where the tutorial illustrates how to decouple urls.py. On doing exactly what it says, i get the following error- error at /polls/1/ nothing to repeat Request Method: GET Request URL: http://localhost:8000/polls/1/ Exception Type: error ...

Calling Python from Java through scripting engine (jython)?

I'm trying to call Jython from a Java 6 application using javax.script: import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; public class jythonEx { public static void main (String args[]) throws ScriptException { ScriptEngineManager mgr = new ScriptEngineManage...

How to stop an IOException error using whilst using a combination of jython, pyro and ant?

So the wonderful low down on this doozie of a problem: short version: We are building a distribution system for this item of software we're using. Basically we take out build artifact, store it on an ftp server which passes it to multiple clients which execute scripts to patch their servers. Long version: 1 distribution server mult...

What does "str indices must be integers" mean?

I'm working with dicts in jython which are created from importing/parsing JSON. Working with certain sections I see the following message: TypeError: str indices must be integers This occurs when I do something like: if jsondata['foo']['bar'].lower() == 'baz': ... Where jsondata looks like: {'foo': {'bar':'baz'} } What does ...

os.stat().st_uid always returns a value of 0 to wsadmin (jython 2.1)

Hi guys, I come a across a tricky issue developing wsadmin code for websphere. No matter what file I choose, os.stat() seems always to give me back a uid = 0. See the following files: -rw-r--r-- 1 tn58660 other 1625 Apr 26 15:03 search.py -rw-r--r-- 1 wasapps wasapp 109 Mar 22 17:27 test.py bash-3.00# /export/opt/W...

Using JRuby/Jython for Ruby/Python interoperability?

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 by...