Anthony Smith | 4 Jun 14:54
Picon
Favicon

For loops in Jython 2.1

Hi all,

I'm trying to adapt a Java class so that "for" loops run smoothly in  
Jython 2.1, but I'm getting confused.

At the moment I'm overriding __getitem__(int), which the API says I  
shouldn't do, and it's giving a java.lang.IndexOutOfBoundsException  
after looping over the items.

Could someone point me to a simple explanation of what happens when a  
"for" loop is called?
	for a in b:
		...
Which methods are invoked and in which order?  __getitem__(PyObject)?   
__finditem__(...)?

(I think __iter__ is a Python 2.2 innovation, so I guess that's not  
involved in Jython 2.1?)

Thanks!

Anthony

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
(Continue reading)

Andrew Lentvorski | 5 Jun 01:27
Gravatar

Problem with reshape calling JOGL

I'm trying to use jogl from Jython.  I tried the demo at:
http://wiki.python.org/jython/JythonMonthly/Articles/January2007/2

This got me a nice segmentation fault.  So, I backed up and tried a 
plain java JOGL demo.  That works fine and validates that I have JOGL 
installed correctly.

So, then I tried to isolate a bunch of stuff.  After chopping a lot of 
the code away, I noticed that the "reshape" function is being called 
multiple times with *different number of arguments*.

I can obviously just test for the number of arguments, but do I *really* 
want to do this?  It seems like something is fundamentally flawed with 
this approach.  Why is reshape being called with two different numbers 
of arguments?  Is this expected?

Code follows.

Thanks,
-a

from javax.swing import *
from java.awt import *
from javax.media.opengl import *

from java.lang import InterruptedException
from java.lang import Thread

class GLPanel2A(JPanel, GLEventListener):
     def __init__(self):
(Continue reading)

Ranga Raju | 5 Jun 02:25
Picon

How to use variables inside regular expressions in Jython ?


Hi,

I am trying to use variable in regular expressions but its not working for
some reason.

I am using Jython that comes with WebSphere 6.1.

wsadmin>print oNodes
ndm-ws16a(cells/WS16/nodes/ndm-ws16a|node.xml#Node_1)
wsejbfpp1wpdiu528(cells/WS16/nodes/wsejbfpp1wpdiu528|node.xml#Node_1)
wsadmin>

wsadmin>print oNodeList
['ndm-ws16a(cells/WS16/nodes/ndm-ws16a|node.xml#Node_1)',
'wsejbfpp1wpdiu528(cells/WS16/nodes/wsejbfpp1wpdiu528|node.xml#Node_1)']
wsadmin>

wsadmin>print nodeName
wpdiu528
wsadmin>

wsadmin>expr = r".*wpdiu528.*"
wsadmin>pat4 = re.compile(expr)
wsadmin>m = re.search(expr,oNodes)
wsadmin>print m
org.python.modules.sre.MatchObject <at> 7b507b50
wsadmin>
wsadmin>m.group()
'wsejbfpp1wpdiu528(cells/WS16/nodes/wsejbfpp1wpdiu528|node.xml#Node_1)'
(Continue reading)

Ranga Raju C.V.S. | 5 Jun 02:18
Picon

How to use variables inside regular expressions in Jython ?

Hi,
 
I am trying to use variable in regular expressions but its not working for some reason.
 
I am using Jython that comes with WebSphere 6.1.
 
wsadmin>print oNodes
ndm-ws16a(cells/WS16/nodes/ndm-ws16a|node.xml#Node_1)
wsejbfpp1wpdiu528(cells/WS16/nodes/wsejbfpp1wpdiu528|node.xml#Node_1)
wsadmin>
 
wsadmin>print oNodeList
['ndm-ws16a(cells/WS16/nodes/ndm-ws16a|node.xml#Node_1)', 'wsejbfpp1wpdiu528(cells/WS16/nodes/wsejbfpp1wpdiu528|node.xml#Node_1)']
wsadmin>
 
wsadmin>print nodeName
wpdiu528
wsadmin>
 
wsadmin>expr = r".*wpdiu528.*"
wsadmin>pat4 = re.compile(expr)
wsadmin>m = re.search(expr,oNodes)
wsadmin>print m
org.python.modules.sre.MatchObject <at> 7b507b50
wsadmin>
wsadmin>m.group()
'wsejbfpp1wpdiu528(cells/WS16/nodes/wsejbfpp1wpdiu528|node.xml#Node_1)'
 
This 'wsejbfpp1wpdiu528(cells/WS16/nodes/wsejbfpp1wpdiu528|node.xml#Node_1)' is the desired result. I am able to achieve this result when I provide "wpdiu528" directly in variable expr. But I would like to use another variable called nodeName in place of the string "wpdiu528" inside the regular expression.
 
I tried as shown below, but it fails.

wsadmin>expr = r".*%nodeName.*"
wsadmin>pat4 = re.compile(expr)
wsadmin>m = re.search(expr,oNodes)
wsadmin>print m
None
wsadmin>
wsadmin>m.group()
WASX7015E: Exception running command: "m.group()"; exception information:
 com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
  File "<input>", line 1, in ?
AttributeError: 'None' object has no attribute 'group'
wsadmin>
 
Please see if you can assist me here...
 
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
Marc Downie | 5 Jun 03:16

Re: Problem with reshape calling JOGL

Why is reshape being called with two different numbers
of arguments?  Is this expected?

I'll guess: reshape(x,y,w,h) in JComponent (JPanel superclass) and reshape(GLAutoDrawable, x,y,w,h) in GLEventListener.

A segfault is always bad news (and hard to pin on Jython --- whoever is making your JVM might be interested in a bug report), but JOGL is very low level — some times, depending on drivers, I have been able to give you a page of Python that locks up a machine.

best of luck,

Marc.

-------------------------------
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
Anthony Smith | 5 Jun 08:42
Picon
Favicon

Re: How to use variables inside regular expressions in Jython ?

Hi Ranga,

On 5 Jun 2009, at 01:18, Ranga Raju C.V.S. wrote:

> This 'wsejbfpp1wpdiu528(cells/WS16/nodes/wsejbfpp1wpdiu528| 
> node.xml#Node_1)' is the desired result. I am able to achieve this  
> result when I provide "wpdiu528" directly in variable expr. But I  
> would like to use another variable called nodeName in place of the  
> string "wpdiu528" inside the regular expression.

Try
expr = ".*" + nodeName + ".*"

 >>> expr = ".*" + nodeName + ".*"
 >>> pat4 = re.compile(expr)
 >>> m = re.search(expr, oNodes)
 >>> m.group()
'wsejbfpp1wpdiu528(cells/WS16/nodes/wsejbfpp1wpdiu528|node.xml#Node_1)'

Cheers,

Anthony

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
Josh Juneau | 5 Jun 19:51
Picon

Re: Problem with reshape calling JOGL

I'm glad to hear that you tried out the sample, sorry to hear that it failed for you.  I went back and ran the same code that I posted in my sample on a different machine and also had a seg fault.  This is perhaps due to a different JDK since I tried to run it on a Mac this time.  It may also be due to a different version of JOGL.  Sorry that I'm no expert in JOGL so I cannot say for certain.

I agree with Marc's response that reshape() is implemented different ways within the JComponent and GLEventListener...that's probably why you get the different # of args...but I can't be sure without digging more deeply into the code.

Hope that you're able to work something out to overcome the issues.

Best

Josh Juneau
juneau001 <at> gmail.com
http://jj-blogger.blogspot.com
http://www.gathereventplanning.com
Twitter ID:  javajuneau


On Thu, Jun 4, 2009 at 6:27 PM, Andrew Lentvorski <bsder <at> allcaps.org> wrote:
I'm trying to use jogl from Jython.  I tried the demo at:
http://wiki.python.org/jython/JythonMonthly/Articles/January2007/2

This got me a nice segmentation fault.  So, I backed up and tried a
plain java JOGL demo.  That works fine and validates that I have JOGL
installed correctly.

So, then I tried to isolate a bunch of stuff.  After chopping a lot of
the code away, I noticed that the "reshape" function is being called
multiple times with *different number of arguments*.

I can obviously just test for the number of arguments, but do I *really*
want to do this?  It seems like something is fundamentally flawed with
this approach.  Why is reshape being called with two different numbers
of arguments?  Is this expected?

Code follows.

Thanks,
-a



from javax.swing import *
from java.awt import *
from javax.media.opengl import *

from java.lang import InterruptedException
from java.lang import Thread

class GLPanel2A(JPanel, GLEventListener):
    def __init__(self):
        print "GLPanel __init__..."
        self.canvas = GLCanvas()
        self.canvas.addGLEventListener(self)
        self.add(self.canvas)
        self.setSize(320,480)
        self.canvas.setSize(320,480)
        self.canvas.setVisible(True)

    def init(self, glDrawable):
        print "GLPanel init..."

    def reshape(self, *a):
        print "Reshape... Numargs:", len(a)
        print a

    def display(self, *a):
        print "Display... Numargs:", len(a)
        print a

class JOGLTest(JFrame):
    def __init__(self):
        print "__init__..."
        self.running = False
        self.animThread = None
        self.a = None
        self.b = None

    def init(self):
        print "init..."
        glPanelA = GLPanel2A()
        self.getContentPane().add(glPanelA)
        self.a = glPanelA

if __name__== "__main__":
   jogl = JOGLTest()
   jogl.init()
   jogl.setSize(400, 400)
   jogl.visible = True

   while (True):
       try:
           Thread.sleep(100)
       except InterruptedException, e:
           raise



------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
Wizzzard | 5 Jun 20:40
Picon

Re: How to use variables inside regular expressions in Jython ?

Anthony Smith schrieb:
> Hi Ranga,
> 
> On 5 Jun 2009, at 01:18, Ranga Raju C.V.S. wrote:
> 
>> This 'wsejbfpp1wpdiu528(cells/WS16/nodes/wsejbfpp1wpdiu528| 
>> node.xml#Node_1)' is the desired result. I am able to achieve this  
>> result when I provide "wpdiu528" directly in variable expr. But I  
>> would like to use another variable called nodeName in place of the  
>> string "wpdiu528" inside the regular expression.
> 
> 
> Try
> expr = ".*" + nodeName + ".*"
> 
>  >>> expr = ".*" + nodeName + ".*"
>  >>> pat4 = re.compile(expr)
>  >>> m = re.search(expr, oNodes)
>  >>> m.group()
> 'wsejbfpp1wpdiu528(cells/WS16/nodes/wsejbfpp1wpdiu528|node.xml#Node_1)'
> 

Why not this?

expr = ".*%s.*" % nodeName

Regards,
Roland.

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
Peter Shin | 5 Jun 20:49
Picon

jreload, errors from java.lang.reflect

Hi,

I'm getting an unexpected error when calling a method from the
imported jar file by jreload.

com.rbnb.sapi.Client is an abstract class, and com.rbnb.sapi.Sink
extends the abstract class.

I'm constructing a class Sink and using it in SinkClientManager.py.
When the constructor for Sink is called, it does not cause any
problem.  But, when a method named OpenRBNBConnection from abstract
class Client is called, it produces the following error.
OpenRBNBConnection class is overloaded with three different numbers of
arguments.

I get the following error message

  File "SinkClientManager.py", line 55, in ?
  File "SinkClientManager.py", line 17, in __init__
  File "SinkClientManager.py", line 33, in __init__
        at com.rbnb.sapi.Client.OpenRBNBConnection(Client.java:310)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)

com.rbnb.sapi.SAPIException: com.rbnb.sapi.SAPIException: Nesting
java.net.ConnectException

Two questions:
1.  Any idea on how to approach solving this problem?

2.  If this were to be a bug in Jython, will this be a reasonable approach?

This part is a small component in big system.  All the Sink related
operations are done in this component.  If I were to create this piece
in JAVA program, will it avoid the above problem (after integrating
the JAVA class with other Jython programs)?

Thank you very much,

Peter
p.s.  I'm sending this email to both the user list and the bug list
because I can't determine if it's an error on my side or Jython's.
Sorry about that.

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
Jones, Steven | 5 Jun 23:19
Favicon

using zxJDBC for Queries with NUMBER datatype in Oracle

When I run Oracle queries using zxJDBC, the results for the Oracle datatype ‘NUMBER’ always have a decimal place added (e.g. 12345.0 instead of just 12345).  If I run the query using SQLPlus for example, the results returned are integers as expected.

 

Here is the query in Jython:

 

>> from com.ziclix.python.sql import zxJDBC

>> db = zxJDBC.connect('jdbc:oracle:thin: <at> host:port:db','system','xxxx','oracle.jdbc.OracleDriver')

>> a = db.cursor()

>> a.execute('select part_uid,product_id from mytable.dp_history')

>> a.fetchone()

(4209580.0, u'ARCH')

 

 

The same result in SQL*Plus returns:

4209580, ARCH

 

 

Is there a way to configure the data types in zxJDBC?

 

My classpath:  /home/jython/ojdbc6.jar

 

My Java version:

 

$ java -version

java version "1.6.0_03"

Java(TM) SE Runtime Environment (build 1.6.0_03-b05)

Java HotSpot(TM) Server VM (build 1.6.0_03-b05, mixed mode)

 

 

This issue can be replicated in any version of Jython.

 

 

Thanks,

Steve

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users

Gmane