David Bush | 3 Feb 02:13

api preoject

Hi there,
I am in need of a little assistance regarding a project I am about to embark on.
I have a cad program that has a built in python api, so the user can write a simple .py script and automate running a series of simulations in the program. My project is to write an equivalent java api from the python one. So basically i need to make an api for an api and call the python methods from my java api. Id imagine there is some term used for this process but I am very inexperienced in these matters.

Is Jython the best way to go about this? I am very much a beginner in both python and java, but am not too worried about the actual coding, just struggling with the overall idea of how to implement this, and what the actual architecture would be for the solution.
Many thanks for any help.

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
Tim Van den Bulcke | 4 Feb 15:13
Picon

java static field considered as a function instead of boolean in jython (unexpected behaviour / bug ?)

Hi,

I have the following java class with one static boolean field "isWindows":

public class Test {
  static boolean isWindows = System.getProperty("os.name").toLowerCase().contains("windows");
}

After compiling this class and launching the jython interactive console, this is the output when asking for the content of the field "isWindows":

>>>> Test.isWindows
<java function isWindows 1>


I would expect a boolean with value "True" on my Windows machine, but instead I get a handle to a java function. If "Test.isWindows" is called from within java, a boolean is returned as expected. Is this normal jython behaviour or not? And if so, why?

For completeness:
- I am running Jython version 2.2a1 and Java 1.5 runtime
- System.getProperty("os.name")  results in "Windows XP" on my machine


Thanks in advance for any feedback,

Tim.

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
Tim Van den Bulcke | 4 Feb 18:58
Picon

Re: java static field considered as a function instead of boolean in jython (unexpected behaviour / bug ?)

Hi Jeff,

thank you for your reply. I had oversimplified the problem in the post: there needed to be an additional method in the Test class which was also called isWindows().

For completeness, this is what the code should have looked like in my previous post:
public class Test {
  static boolean isWindows = System.getProperty("os.name").toLowerCase().contains("windows");

  /* ... */

  public static final boolean isWindows() {
    return isWindows;
  }

}

In Java there is no confusion possible between the isWindows field and the isWindows() function. However in jython the field gets hidden by the function.


My problem is solved now (my apologies for the incomplete previous post) but leads to a perhaps equally interesting question: if such Test class like the above one is given, is it then possible to access both the function "isWindows()" and the field "isWindows" of the Test class from within jython?


Thanks,

Tim.



On Wed, Feb 4, 2009 at 5:39 PM, Jeff Emanuel <jemanuel <at> frii.com> wrote:
It works for correctly me on Jython 2.2.1 and Java 1.6.
I made the isWindows field public.  Otherwise, I get
AttributeError: class 'Test' has no attribute 'isWindows'

Jython 2.2.1 on java1.6.0_04
Type "copyright", "credits" or "license" for more information.
>>> import Test
>>> Test.isWindows
1



Tim Van den Bulcke wrote:
Hi,

I have the following java class with one static boolean field "isWindows":

public class Test {
 static boolean isWindows = System.getProperty("os.name
").toLowerCase().contains("windows");
}

After compiling this class and launching the jython interactive console,
this is the output when asking for the content of the field "isWindows":

 
Test.isWindows
         
<java function isWindows 1>


I would expect a boolean with value "True" on my Windows machine, but
instead I get a handle to a java function. If "Test.isWindows" is called
from within java, a boolean is returned as expected. Is this normal jython
behaviour or not? And if so, why?

For completeness:
- I am running Jython version 2.2a1 and Java 1.5 runtime
- System.getProperty("os.name")  results in "Windows XP" on my machine


Thanks in advance for any feedback,

Tim.

 ------------------------------------------------------------------------

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
------------------------------------------------------------------------

_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
 

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
Jeff Emanuel | 4 Feb 19:15
Favicon

Re: java static field considered as a function instead of boolean in jython (unexpected behaviour / bug ?)


Tim,

I figured there was something like that.

Since your isWindows field is not public,
it won't (by default) be accessible from Jython,
so you'll only see the isWindows method.

To call the isWindows method you need
parentheses:

 >>> import Test
 >>> Test.isWindows()
 1

Third, if the static field is declared public
(or your accessiblity settings allow it) so
that you have a true name collision, Jython's
precedence hides the field (at least through 2.2.1).
However, you can still access the field with Java
reflection.

 >>> Test.getDeclaredField('isWindows').get(None)
 1

I hope that helps.

Jeff

Tim Van den Bulcke wrote:
> Hi Jeff,
>
> thank you for your reply. I had oversimplified the problem in the post:
> there needed to be an additional method in the Test class which was also
> called isWindows().
>
> For completeness, this is what the code should have looked like in my
> previous post:
> public class Test {
>   static boolean isWindows = System.getProperty("os.name
> ").toLowerCase().contains("windows");
>
>   /* ... */
>
>   public static final boolean isWindows() {
>     return isWindows;
>   }
> }
>
> In Java there is no confusion possible between the isWindows field and the
> isWindows() function. However in jython the field gets hidden by the
> function.
>
>
> My problem is solved now (my apologies for the incomplete previous post) but
> leads to a perhaps equally interesting question: if such Test class like the
> above one is given, is it then possible to access both the function
> "isWindows()" and the field "isWindows" of the Test class from within
> jython?
>
>
> Thanks,
>
> Tim.
>
>
>
> On Wed, Feb 4, 2009 at 5:39 PM, Jeff Emanuel <jemanuel <at> frii.com> wrote:
>
>   
>> It works for correctly me on Jython 2.2.1 and Java 1.6.
>> I made the isWindows field public.  Otherwise, I get
>> AttributeError: class 'Test' has no attribute 'isWindows'
>>
>> Jython 2.2.1 on java1.6.0_04
>> Type "copyright", "credits" or "license" for more information.
>>     
>>>>> import Test
>>>>> Test.isWindows
>>>>>           
>> 1
>>
>>
>>
>> Tim Van den Bulcke wrote:
>>
>>     
>>> Hi,
>>>
>>> I have the following java class with one static boolean field "isWindows":
>>>
>>> public class Test {
>>>  static boolean isWindows = System.getProperty("os.name
>>> ").toLowerCase().contains("windows");
>>> }
>>>
>>> After compiling this class and launching the jython interactive console,
>>> this is the output when asking for the content of the field "isWindows":
>>>
>>>
>>>
>>>       
>>>> Test.isWindows
>>>>         
>>>>>>>               
>>>>>> <java function isWindows 1>
>>>>>>             
>>> I would expect a boolean with value "True" on my Windows machine, but
>>> instead I get a handle to a java function. If "Test.isWindows" is called
>>> from within java, a boolean is returned as expected. Is this normal jython
>>> behaviour or not? And if so, why?
>>>
>>> For completeness:
>>> - I am running Jython version 2.2a1 and Java 1.5 runtime
>>> - System.getProperty("os.name")  results in "Windows XP" on my machine
>>>
>>>
>>> Thanks in advance for any feedback,
>>>
>>> Tim.
>>>
>>>  ------------------------------------------------------------------------
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Create and Deploy Rich Internet Apps outside the browser with
>>> Adobe(R)AIR(TM)
>>> software. With Adobe AIR, Ajax developers can use existing skills and code
>>> to
>>> build responsive, highly engaging applications that combine the power of
>>> local
>>> resources and data with the reach of the web. Download the Adobe AIR SDK
>>> and
>>> Ajax docs to start building applications today-
>>> http://p.sf.net/sfu/adobe-com
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Jython-users mailing list
>>> Jython-users <at> lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/jython-users
>>>
>>>
>>>       
>
>   
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
> software. With Adobe AIR, Ajax developers can use existing skills and code to
> build responsive, highly engaging applications that combine the power of local
> resources and data with the reach of the web. Download the Adobe AIR SDK and
> Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
> ------------------------------------------------------------------------
>
> _______________________________________________
> Jython-users mailing list
> Jython-users <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jython-users
>   

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
Tim Van den Bulcke | 5 Feb 11:41
Picon

Re: java static field considered as a function instead of boolean in jython (unexpected behaviour / bug ?)

Hi Jeff,

thank you for your clear answer.

Kind regards,

Tim.


On Wed, Feb 4, 2009 at 7:15 PM, Jeff Emanuel <jemanuel <at> frii.com> wrote:

Tim,

I figured there was something like that.

Since your isWindows field is not public,
it won't (by default) be accessible from Jython,
so you'll only see the isWindows method.

To call the isWindows method you need
parentheses:


>>> import Test
>>> Test.isWindows()
1

Third, if the static field is declared public
(or your accessiblity settings allow it) so
that you have a true name collision, Jython's
precedence hides the field (at least through 2.2.1).
However, you can still access the field with Java
reflection.

>>> Test.getDeclaredField('isWindows').get(None)
1

I hope that helps.

Jeff



Tim Van den Bulcke wrote:
Hi Jeff,

thank you for your reply. I had oversimplified the problem in the post:
there needed to be an additional method in the Test class which was also
called isWindows().

For completeness, this is what the code should have looked like in my
previous post:
public class Test {
 static boolean isWindows = System.getProperty("os.name
").toLowerCase().contains("windows");

 /* ... */

 public static final boolean isWindows() {
   return isWindows;
 }
}

In Java there is no confusion possible between the isWindows field and the
isWindows() function. However in jython the field gets hidden by the
function.


My problem is solved now (my apologies for the incomplete previous post) but
leads to a perhaps equally interesting question: if such Test class like the
above one is given, is it then possible to access both the function
"isWindows()" and the field "isWindows" of the Test class from within
jython?


Thanks,

Tim.



On Wed, Feb 4, 2009 at 5:39 PM, Jeff Emanuel <jemanuel <at> frii.com> wrote:

 
It works for correctly me on Jython 2.2.1 and Java 1.6.
I made the isWindows field public.  Otherwise, I get
AttributeError: class 'Test' has no attribute 'isWindows'

Jython 2.2.1 on java1.6.0_04
Type "copyright", "credits" or "license" for more information.
   
import Test
Test.isWindows
         
1



Tim Van den Bulcke wrote:

   
Hi,

I have the following java class with one static boolean field "isWindows":

public class Test {
 static boolean isWindows = System.getProperty("os.name
").toLowerCase().contains("windows");
}

After compiling this class and launching the jython interactive console,
this is the output when asking for the content of the field "isWindows":



     
Test.isWindows
       
             
<java function isWindows 1>
           
I would expect a boolean with value "True" on my Windows machine, but
instead I get a handle to a java function. If "Test.isWindows" is called
from within java, a boolean is returned as expected. Is this normal jython
behaviour or not? And if so, why?

For completeness:
- I am running Jython version 2.2a1 and Java 1.5 runtime
- System.getProperty("os.name")  results in "Windows XP" on my machine


Thanks in advance for any feedback,

Tim.

 ------------------------------------------------------------------------


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with
Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code
to
build responsive, highly engaging applications that combine the power of
local
resources and data with the reach of the web. Download the Adobe AIR SDK
and
Ajax docs to start building applications today-
http://p.sf.net/sfu/adobe-com
------------------------------------------------------------------------

_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users


     

 ------------------------------------------------------------------------

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
------------------------------------------------------------------------

_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
 

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
jlist9 | 6 Feb 07:33
Picon

Use class file in Jython - is it possible?

Hi,

I understand I can create a jar file and add the jar to sys.path,
then import a class from the jar and use it.

I wonder if there is a way to use a .class file directly?

Thanks

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
Nicholas Riley | 6 Feb 09:33
Picon

Re: Use class file in Jython - is it possible?

In article <135605556.20090205223355 <at> gmail.com>, jlist9 <at> gmail.com 
wrote:

> I understand I can create a jar file and add the jar to sys.path,
> then import a class from the jar and use it.
> 
> I wonder if there is a way to use a .class file directly?

You can add a directory containing a .class file to sys.path too.
--

-- 
Nicholas Riley <njriley <at> uiuc.edu>

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
Josh Juneau | 6 Feb 14:04
Picon

Re: Jython BoF @ PyCon

I have created a wiki page for the Jython BoF @ PyCon 2009.

Please visit the following URL:

http://us.pycon.org/2009/openspace/jythonbof/

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

On Tue, Jan 27, 2009 at 10:13 PM, Josh Juneau <juneau001 <at> gmail.com> wrote:
> Jim Baker and I are planning to coordinate a Jython BoF for the
> upcoming PyCon conference this March in Chicago, IL.  The anticipated
> date would be on Thursday, March 26 sometime in the evening.
>
> If you are interested in attending the BoF and you think that 3/26
> would be a good date, please reply back and let us know .  Also, if
> you have any suggestions then please send them our way.
>
> We appreciate the response and hope to see you at the conference!
>
> Thanks
>
> Josh Juneau
> juneau001 <at> gmail.com
> http://jj-blogger.blogspot.com
> http://www.gathereventplanning.com
> Twitter ID:  javajuneau
>

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
Marc Downie | 6 Feb 16:27

[Announce] - Field: a new environment for digital art (in Jython)

Dear Jython community,

After 6 years of in-house development and 1 as a quiet open source
project amongst friends, The OpenEnded Group is pleased to announce
the first beta binary releases of Field, a new development environment
for digital art and experimental programming.

Field builds an IDE around Jython and, while geared around the needs
of digital artists, will hopefully be of interest to Jython hackers
and Java hackers of all kinds. We have a fully featured text editor
with integrated graphical elements; an innovative "canvas" where you
can make timelines, dataflows, visualizations and other visual code
metaphors; fine-grained Mercurial support; an excellent 2d drawing
system; integrated image processing and special support for
integration with the popular Processing runtime. Under the hood
there's a powerful 3d scenegraph library, a bytecode rewriting
annotation library and an application framework for animation. But
most of all Field wants to talk to, and be integrated with, your own
Java and Jython codebases.

See http://openendedgroup.com/field/wiki/OverviewBanners2 for a list
of features. A special starting place for Jython, Python and Java
Programmers is here:
http://openendedgroup.com/field/wiki/StartingPlaceForPythonProgrammers

Field is for Mac OS X 10.5, it's GPL v 3 and uses latest Jython
(that's 2.5 beta 1 + some recent bug fixes). Thanks go, of course, to
the Jython developers --- without which Field (and most of the
artworks on http://openendedgroup.com) wouldn't have been possible.

kind regards,

Marc Downie
The OpenEnded Group

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
Tom Whittaker | 9 Feb 17:34
Picon
Favicon

JNumeric broken in Jython 2.2+

(Sorry if this has been covered before -- I searched, but found no
other comments/questions.)  We just moved an application to Jython 2.2
....and found that JNumeric is quite broken.  One cannot even say
"from Numeric import *" without getting an Exception.  Any ideas and
help appreciated.

Here's the Excpetion (abreviated):

>>> from Numeric import *
Traceback (innermost last):
  File "<console>", line 1, in ?
        at JNumeric.PyMultiarray.<init>(PyMultiarray.java:73)
........
java.lang.NoSuchMethodError: java.lang.NoSuchMethodError:
org.python.core.PySequence.<init>(Lorg/python/core/PyClass;)V

The issues appear to be mostly (if not all) in the PyMultiarray class,
referencing signatures that have changed since 2.1.  Here's the output
from an attempt to recompile the package:

C:\Temp\jnumeric\src\>javac -cp \jython2.2b2\jython.jar;. *.java JNumeric\*.java

PyMultiarray.java:29: JNumeric.PyMultiarray is not abstract and does
not override abstract method pyget(int) in org.python.core.PySequence
public class PyMultiarray extends PySequence {
       ^
PyMultiarray.java:73: cannot find symbol
symbol  : constructor PySequence(org.python.core.PyClass)
location: class org.python.core.PySequence
        super(__class__);
        ^
PyMultiarray.java:904: cannot find symbol
symbol  : method getValue()
location: class org.python.core.PyObject
        return new int []
{asarray(o).__getitem__(Py.Ellipsis).__int__().getValue()};
                                  ^
PyMultiarray.java:913: cannot find symbol
symbol  : method getValue()
location: class org.python.core.PyObject
            intArray[i] = o.__getitem__(i).__int__().getValue();
                                       ^
PyMultiarray.java:1428: list has protected access in org.python.core.PySequenceL
ist
        PyObject indices[] = (pyIndices instanceof PyTuple) ?
((PyTuple)pyIndices).list : new PyObject[] {pyIndices};
                                                              ^
PyMultiarray.java:1428: incompatible types
found   : java.lang.Object
required: org.python.core.PyObject[]
        PyObject indices[] = (pyIndices instanceof PyTuple) ?
((PyTuple)pyIndices).list : new PyObject[] {pyIndices};
                                                            ^

--

-- 
Tom Whittaker
University of Wisconsin-Madison
Space Science & Engineering Center (SSEC)
Cooperative Institute for Meteorological Satellite Studies (CIMSS)
1225 W. Dayton Street
Madison, WI  53706  USA
ph: +1 608 262 2759

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com

Gmane