You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(6) |
Nov
(8) |
Dec
(51) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(105) |
Feb
(93) |
Mar
(194) |
Apr
(145) |
May
(100) |
Jun
(111) |
Jul
(117) |
Aug
(126) |
Sep
(233) |
Oct
(138) |
Nov
(164) |
Dec
(109) |
2002 |
Jan
(216) |
Feb
(175) |
Mar
(216) |
Apr
(194) |
May
(157) |
Jun
(140) |
Jul
(158) |
Aug
(73) |
Sep
(105) |
Oct
(164) |
Nov
(104) |
Dec
(95) |
2003 |
Jan
(72) |
Feb
(69) |
Mar
(81) |
Apr
(151) |
May
(101) |
Jun
(139) |
Jul
(99) |
Aug
(118) |
Sep
(115) |
Oct
(151) |
Nov
(161) |
Dec
(102) |
2004 |
Jan
(120) |
Feb
(175) |
Mar
(106) |
Apr
(111) |
May
(54) |
Jun
(78) |
Jul
(76) |
Aug
(105) |
Sep
(94) |
Oct
(143) |
Nov
(75) |
Dec
(85) |
2005 |
Jan
(99) |
Feb
(77) |
Mar
(164) |
Apr
(97) |
May
(79) |
Jun
(57) |
Jul
(65) |
Aug
(102) |
Sep
(95) |
Oct
(129) |
Nov
(123) |
Dec
(52) |
2006 |
Jan
(48) |
Feb
(99) |
Mar
(90) |
Apr
(51) |
May
(81) |
Jun
(136) |
Jul
(56) |
Aug
(109) |
Sep
(50) |
Oct
(44) |
Nov
(74) |
Dec
(75) |
2007 |
Jan
(92) |
Feb
(137) |
Mar
(93) |
Apr
(79) |
May
(52) |
Jun
(74) |
Jul
(143) |
Aug
(175) |
Sep
(154) |
Oct
(137) |
Nov
(88) |
Dec
(90) |
2008 |
Jan
(58) |
Feb
(113) |
Mar
(167) |
Apr
(88) |
May
(105) |
Jun
(37) |
Jul
(87) |
Aug
(72) |
Sep
(56) |
Oct
(41) |
Nov
(102) |
Dec
(70) |
2009 |
Jan
(115) |
Feb
(113) |
Mar
(126) |
Apr
(58) |
May
(125) |
Jun
(45) |
Jul
(90) |
Aug
(125) |
Sep
(84) |
Oct
(61) |
Nov
(111) |
Dec
(61) |
2010 |
Jan
(85) |
Feb
(86) |
Mar
(130) |
Apr
(58) |
May
(57) |
Jun
(32) |
Jul
(25) |
Aug
(50) |
Sep
(41) |
Oct
(65) |
Nov
(63) |
Dec
(24) |
2011 |
Jan
(43) |
Feb
(31) |
Mar
(28) |
Apr
(68) |
May
(53) |
Jun
(42) |
Jul
(58) |
Aug
(26) |
Sep
(51) |
Oct
(76) |
Nov
(60) |
Dec
(9) |
2012 |
Jan
(16) |
Feb
(32) |
Mar
(32) |
Apr
(39) |
May
(16) |
Jun
(19) |
Jul
(3) |
Aug
(11) |
Sep
(35) |
Oct
(47) |
Nov
(28) |
Dec
(18) |
2013 |
Jan
(18) |
Feb
(36) |
Mar
(10) |
Apr
(7) |
May
(7) |
Jun
(27) |
Jul
(17) |
Aug
(35) |
Sep
(19) |
Oct
(31) |
Nov
(8) |
Dec
(22) |
2014 |
Jan
(5) |
Feb
(11) |
Mar
(18) |
Apr
(23) |
May
(26) |
Jun
(14) |
Jul
(18) |
Aug
(26) |
Sep
(20) |
Oct
(48) |
Nov
(13) |
Dec
(9) |
2015 |
Jan
(9) |
Feb
(15) |
Mar
(25) |
Apr
(10) |
May
(26) |
Jun
(6) |
Jul
(13) |
Aug
(5) |
Sep
(14) |
Oct
(36) |
Nov
(24) |
Dec
(18) |
2016 |
Jan
(24) |
Feb
(11) |
Mar
(1) |
Apr
(6) |
May
(7) |
Jun
(3) |
Jul
(9) |
Aug
(15) |
Sep
(22) |
Oct
(5) |
Nov
(5) |
Dec
(2) |
2017 |
Jan
(20) |
Feb
(4) |
Mar
(4) |
Apr
(1) |
May
(5) |
Jun
(7) |
Jul
(14) |
Aug
(9) |
Sep
(18) |
Oct
(2) |
Nov
(3) |
Dec
(3) |
2018 |
Jan
(7) |
Feb
(6) |
Mar
(1) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
(18) |
Sep
(8) |
Oct
(9) |
Nov
(4) |
Dec
(6) |
2019 |
Jan
(5) |
Feb
|
Mar
(2) |
Apr
(4) |
May
(6) |
Jun
(8) |
Jul
(11) |
Aug
(10) |
Sep
(6) |
Oct
|
Nov
(1) |
Dec
|
2020 |
Jan
(8) |
Feb
(3) |
Mar
(1) |
Apr
(4) |
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
(1) |
Oct
(5) |
Nov
(2) |
Dec
(1) |
2021 |
Jan
|
Feb
|
Mar
(5) |
Apr
(2) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2022 |
Jan
|
Feb
(2) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
(7) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
(5) |
Jul
(15) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2024 |
Jan
|
Feb
(1) |
Mar
|
Apr
(2) |
May
|
Jun
(5) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2025 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <Mat...@i2...> - 2001-10-03 20:14:28
|
On 10/03/2001 02:04:35 PM jython-users-admin wrote: > > The PyFactory looks something like this: Cool, thanks for the useful pattern. > was nice. Incidentally, the Python implementation of the > layout engine was 599 lines, while the Java came to 941. Heh, yeah, I wrote a GUI jython script launcher initially in jython, it was about 1000 lines, had to rewrite it in Java (for speed) and it was > 2300 lines, so I feel your pain =) Matt |
From: Bill K. <bi...@ct...> - 2001-10-03 18:01:14
|
From: "rohit seth" <ro2...@ya...> > > Hi, > > I am planning to use Jython scripts to extend the > runtime flexibility of my Java application. Just > wanted to know if it is possible to pass and retrieve > parameters/variables from Jython file to Java File and > vice versa. > > If yes, then how? What we've done here is create what we call a PyFactory. :-) (I *wish* the whole application could be written in Jython, but we're dealing with a lot of legacy code, so the thing is still Java-centric. (*)) The PyFactory looks something like this: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import org.python.util.PythonInterpreter; public class PyFactory { public static void initialize () throws ClassNotFoundException { String pyPath = "wherever/your/python/scripts/are"; _py = new PythonInterpreter(); _py.exec("import sys"); _py.exec("sys.path.append('"+pyPath+"')"); _py.exec("import pyfactory"); Class pyfactoryClass = Class.forName("com.eb.py.PyFactoryInterface"); _py.exec("pie = pyfactory.PyFactory()"); _pie = (PyFactoryInterface) _py.get("pie", pyfactoryClass); } public static PyFactoryInterface pie () { return _pie; } private static PythonInterpreter _py; private static PyFactoryInterface _pie; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Where the PyFactoryInferface is our own interface in java that is implemented by Python code . . . interfaces are the key to having Java code be able to utilize Python classes (all this assumes you're not using jythonc, which is another approach entirely . . .) So for completeness, PyFactoryInterface looks something like: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public interface PyFactoryInterface { public DictParser newDictParser (); public HtmlParser newHtmlParser (Hashtable tagToNode); public HtmlRenderComponent newHtmlRenderComponent (); public URLHandler newURLHandler (String productPath); // etc. } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ So. . . again with the 'interfaces'. Each of those guys being returned (DictParser, HtmlParser, etc.) are all Java interfaces implemented by the jython classes we're instantiating and returning here. The PyFactoryInterface itself is, of course, implemented in jython. So, again for completeness, it looks a bit like: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ from dictparser import DictParser from htmlparse import HtmlParser from htmlrender import HtmlRenderComponent from urlhandler import URLHandler # etc . . . class PyFactory(com.your.java.package.PyFactoryInterface): def newDictParser(self): return DictParser() def newHtmlParser(self, tagToNode): return HtmlParser(tagToNode) def newHtmlRenderComponent(self): return HtmlRenderComponent() def newURLHandler(self, productPath): return URLHandler(productPath) # etc . . . ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ . . . in re-reading the above, since I forgot to actually show a usage example of the factory, here it is (in case it wasn't obvious already :) From Java, PyFactory.initialize(); HtmlRenderComponent hr = PyFactory.pie().newHtmlRenderComponent(); Remember that HtmlRenderComponent is just an 'interface' implemented by the Python class providing that functionality. (*) On a side note, I had to re-implement our Python-based HTML layout engine in Java last weekend, 'cause jython just wasn't up to the task, speed-wise, unfortunately. (At least 2.1a3 - I didn't try other versions of the interpreter.) However, the Java re-implementation was still able to use the Python-based unit tests, almost totally unmodified. So that was nice. Incidentally, the Python implementation of the layout engine was 599 lines, while the Java came to 941. Hope this helps, Bill |
From: <Mat...@i2...> - 2001-10-03 15:32:43
|
Someone answered this question for me a few days ago. Check the jython-users archive for details. You use interp.set("name", objectValue) to pass to jython from java, and I guess the easiest way from jython back to java would be to call a setter on some object you passed in using interp.set() Matt rohit seth <ro2...@ya...> Sent by: jyt...@li... 10/03/01 08:54 AM To: jyt...@li... cc: Subject: [Jython-users] Extending the runtime flexibility of my Java application using Jython Hi, I am planning to use Jython scripts to extend the runtime flexibility of my Java application. Just wanted to know if it is possible to pass and retrieve parameters/variables from Jython file to Java File and vice versa. If yes, then how? Coz I have come across ways to execute specific Jython commands from a Java file or to execute complete Jython scripts. I dont know if there is any possible way to pass a parameter or variable from Jython file and retrieve it in Java file..or the other way round. Thanks and Regards, Rohit __________________________________________________ Do You Yahoo!? Listen to your Yahoo! Mail messages from any phone. http://phone.yahoo.com _______________________________________________ Jython-users mailing list Jyt...@li... https://lists.sourceforge.net/lists/listinfo/jython-users |
From: rohit s. <ro2...@ya...> - 2001-10-03 12:54:08
|
Hi, I am planning to use Jython scripts to extend the runtime flexibility of my Java application. Just wanted to know if it is possible to pass and retrieve parameters/variables from Jython file to Java File and vice versa. If yes, then how? Coz I have come across ways to execute specific Jython commands from a Java file or to execute complete Jython scripts. I dont know if there is any possible way to pass a parameter or variable from Jython file and retrieve it in Java file..or the other way round. Thanks and Regards, Rohit __________________________________________________ Do You Yahoo!? Listen to your Yahoo! Mail messages from any phone. http://phone.yahoo.com |
From: <Mat...@i2...> - 2001-10-02 18:29:22
|
On 10/01/2001 05:36:42 PM jython-users-admin wrote: > > class Foo(java.lang.Object): > def __init__(self, blah): > "@sig public Foo(String blah)" > self.blah = blah > def doSomething(): > blah.doSomethingElse() > > The @sig doc strings are a feature only of jythonc, they make a > method java visible (the class will have a concrete java method > with that signature) otherwise unless overriding a method is just a > pure Python method not directly accessible from Java side. > So in in this case doSomething will remain a pure Python method. Cool, thats exactly what I needed - I didn't know you could translate a python __init__ to a java constructor. Thanks, Matt |
From: Andre M D. <amd...@te...> - 2001-10-02 14:01:24
|
Hi, I am currently using the PyObject __call__() method to execute a = previously compile python function. pyOnInitialize.__call__(); // where pyOnInitialize is a PyObject The problem is I need to pass it the locals variable, so I can always = restart my python variables at a certain state. I am now using the following code, which allows me to do this : pythonInterpreter.setLocals(locals); pythonInterpreter.exec(((PyFunction)pyOnInitialize).func_code); the problem is I can't pass any parameters to this call, or receive any = return values. Is there a way of doing the equivalent of the __call__() method but = using my locals variable?? Thanks a lot. Andre M. Descombes |
From: Christoph R. <rom...@zh...> - 2001-10-02 12:48:20
|
Hello people I solved my last problem by myself, thanx any way for your preparedness to help. Greets Chris Content Security by MailMarshal |
From: Christoph R. <rom...@zh...> - 2001-10-02 08:13:08
|
Hello people I'trying to use a Java class generated through jythonc (with a public constructor, see last to mails). When I want to create a new instance, as JBlackScholesAdv jbsa = new JBlackScholesAdv(); I get this error message: ImportError: no module named JBlackScholesAdv Both classes, calling and JBlackScholesAdv are located in the same package package ch.comit.da.pricing; Actually, it isn't a jar file at the moment and depens on the folder structure. But I guess this isn't a problem. Could it be that there is a wrong classpath, or something like that? Any help appreciated. Thanx Chris Content Security by MailMarshal |
From: Samuele P. <pe...@in...> - 2001-10-01 21:36:50
|
Hi. > > How do I run a piece of frozen python script within an embedded jython > interpreter? First jythonc and the interpeter are not incompatible but do not collabarate much. See: http://aspn.activestate.com/ASPN/Mail/Message/555125 In your case is not a problem because you want construct your Python/Java object on Java side. > i.e. How do I get the following contrived example to work? > > Foo.py: > class Foo: > def __init__(self, blah): > self.blah = blah > def doSomething(): > blah.doSomethingElse() > > Foo.py is precompiled to Foo.class using jythonc, This produces a java class that correspond to a Python module not to a class, the java class has just basically a main method. If you want a Java (proxy) class corresponding to a python class, your python class should inherit from Java: import java class Foo(java.lang.Object): def __init__(self, blah): "@sig public Foo(String blah)" self.blah = blah def doSomething(): blah.doSomethingElse() The @sig doc strings are a feature only of jythonc, they make a method java visible (the class will have a concrete java method with that signature) otherwise unless overriding a method is just a pure Python method not directly accessible from Java side. So in in this case doSomething will remain a pure Python method. > > PyObject f = new Foo(); // how do I call __init__ with arguments? Now something like this Foo f = new Foo("blah"); should work. Notice that java side Foo class does not inherit form PyObject in this case. > > PythonInterpreter interp = new PythonInterpreter(); > interp.set("foo", f); > interp.exec("foo.doSomething()"); This works because the java/python conversion behind the scene accesssz the full-fledged python instance, for which the java class Foo is just a proxy :) . > > Alternatively, how would I bytecompile a script, and pass the code object > to the interpreter? I tried to use jythonc to create a class file, and > then used that as a source for an InputStream to > PythonInterpreter.exexfile(), This doesn't work. > but that just gave me syntax errors on the > binary data at runtime. I guess it needs to be a python byte compiled > file instead...? No jython does not never deal with python bytecode. > bar.py: > print "hello world" > print "bye world" > > How do I bytecompile bar.py? > how do I then load and run the bytecompiled bar.py using a > PythonInterpreter instance? > *warning* hack: org.python.core.PyRunnable bar = new bar._PyInner(); PyObject code = bar.getMain(); interp.exec(code) or some flavor of what was in the posting cited above. regards. |
From: <Mat...@i2...> - 2001-10-01 20:30:58
|
How do I run a piece of frozen python script within an embedded jython interpreter? i.e. How do I get the following contrived example to work? Foo.py: class Foo: def __init__(self, blah): self.blah = blah def doSomething(): blah.doSomethingElse() Foo.py is precompiled to Foo.class using jythonc, PyObject f = new Foo(); // how do I call __init__ with arguments? PythonInterpreter interp = new PythonInterpreter(); interp.set("foo", f); interp.exec("foo.doSomething()"); Alternatively, how would I bytecompile a script, and pass the code object to the interpreter? I tried to use jythonc to create a class file, and then used that as a source for an InputStream to PythonInterpreter.exexfile(), but that just gave me syntax errors on the binary data at runtime. I guess it needs to be a python byte compiled file instead...? bar.py: print "hello world" print "bye world" How do I bytecompile bar.py? how do I then load and run the bytecompiled bar.py using a PythonInterpreter instance? Any help appreciated, thanks, Matt mat...@i2... |
From: Paul G. <pau...@so...> - 2001-10-01 07:40:59
|
Barnabas Wolf wrote: >I'm trying to add Python scripting capabilities to an existing Java >application. I would need to be able to execute scripts fully >independently in different threads. I've attempted this by creating >an instance of PythonInterpreter in each of the threads. This approach >appears to work, but not perfectly. For example, all interpreters >share the same IO streams -- calling setOut(), setErr(), etc. on any >of the interpreters will redirect *all* of the interpreters to the >new stream. This particular problem is not a complete show stopper, >but it makes me worry about how independent the interpreters really >are. I have also tried to use multiple interpreters in different threads. That was a while back using JPython 1.1. At that time, the different threads corrupted each other in short order. I have not tried again recently, but after looking inside the jython code, I see that quite a lot of state information is stored statically, which leads me to believe that jython was not designed for multithreaded used in this way. If so, that is a shame, as this would be very useful. Perhaps someone knows otherwise and can tell us what we are doing wrong? -Paul -- Paul Giotta Software Architect pau...@so... Office: +41 1 445 2370 | Fax: +41 1 445 2372 | Mobile: +41 76 389 1180 Technoparkstr.1, 8005 Zurich, Switzerland | http://www.softwired-inc.com * e2e Java Messaging, Pure and Simple. * |
From: dman <ds...@ri...> - 2001-09-30 03:14:56
|
On Thu, Sep 27, 2001 at 06:42:55AM -0700, R Datta wrote: | I need to install pyXML but cant, because setup.py asks for distutils, and | jython 2.1 doesn't seem to have it. the Distutil page says that it has been | part of the distribution since 1.6 .... what gives? I don't think you can install pyXML anyways, because at least on the systems I've installed it on it requires expat (a C XML parsing library). Hopefully someone will prove me wrong though. In any case, there are Java implementations of XML parsers that can be used. Perhaps someone will wrap a java implementation to conform to the pyXML interface. -D |
From: Frank C. <fc...@pu...> - 2001-09-29 15:39:32
|
In the words of Rodney: Can't we all just live together? Other analogies comes to mind: Let the farmer and the cowboy be friends. I'll keep in mind that I can get the PyTraceback in Jython. But for this application I'd like to do so in Java. Oh well, I'll keep digging. -Frank -- Frank Cohen, founder, PushToTest, www.pushtotest.com, phone: 408 374 7426 Come to PushToTest for Load, a free open-source tool for performance and scalability testing and data migration. > From: Ype Kingma <yk...@xs...> > Date: Sat, 29 Sep 2001 11:16:29 +0100 > To: jyt...@li... > Subject: Re: [Jython-users] Catching and showing errors > >> I'm writing a little utility that will run a Jython script and when it >> catches an error it will open an editor and jump to the line number that >> contains the offending script. I'm starting with a Java application and am >> correctly catching a forced example exception. Jython gives the exception a >> PyException object. From PyException how may I get a PyTraceback object, so >> I may get the line number from tb_lineno? |
From: Ype K. <yk...@xs...> - 2001-09-29 09:09:46
|
Frank, >I'm writing a little utility that will run a Jython script and when it >catches an error it will open an editor and jump to the line number that >contains the offending script. I'm starting with a Java application and am >correctly catching a forced example exception. Jython gives the exception a >PyException object. From PyException how may I get a PyTraceback object, so >I may get the line number from tb_lineno? Have look at the traceback module. It's straightforward to do this in Jython, and I suspect you are getting the hang of doing jython things directly in java, (which I prefer to avoid :) )... Have fun, Ype Btw. I just started using jEdit: higly recommended, good syntax highlighting for python code. |
From: Frank C. <fc...@pu...> - 2001-09-29 06:12:39
|
I'm writing a little utility that will run a Jython script and when it catches an error it will open an editor and jump to the line number that contains the offending script. I'm starting with a Java application and am correctly catching a forced example exception. Jython gives the exception a PyException object. From PyException how may I get a PyTraceback object, so I may get the line number from tb_lineno? -Frank -- Frank Cohen, founder, PushToTest, www.pushtotest.com, phone: 408 374 7426 Come to PushToTest for Load, a free open-source tool for performance and scalability testing and data migration. |
From: Mats W. <ma...@la...> - 2001-09-28 23:24:11
|
At 12:09 PM 9/28/2001 -0400, Barnabas Wolf wrote: >I'm trying to add Python scripting capabilities to an existing Java >application. I would need to be able to execute scripts fully >independently in different threads. I've attempted this by creating >an instance of PythonInterpreter in each of the threads. This approach >appears to work, but not perfectly. For example, all interpreters >share the same IO streams -- calling setOut(), setErr(), etc. on any >of the interpreters will redirect *all* of the interpreters to the >new stream. This particular problem is not a complete show stopper, >but it makes me worry about how independent the interpreters really >are. That's the way threads are supposed to work: separate threads of control within a single execution context, which means they have a lot of resources in common, including open files. Mats |
From: Barnabas W. <bar...@ms...> - 2001-09-28 16:13:25
|
I'm trying to add Python scripting capabilities to an existing Java application. I would need to be able to execute scripts fully independently in different threads. I've attempted this by creating an instance of PythonInterpreter in each of the threads. This approach appears to work, but not perfectly. For example, all interpreters share the same IO streams -- calling setOut(), setErr(), etc. on any of the interpreters will redirect *all* of the interpreters to the new stream. This particular problem is not a complete show stopper, but it makes me worry about how independent the interpreters really are. Have my spiciest behaved properly only by accident? Are there any other volatile data structures shared by the interpreters? Is there a recommended way to create independent interpreters that I've overlooked? (Aside from setting up independent classloaders in a sandbox for each thread, which I'd like to avoid) Any help or suggestions would be appreciated... Barnabas |
From: R D. <rd...@cr...> - 2001-09-27 13:43:16
|
I need to install pyXML but cant, because setup.py asks for distutils, and jython 2.1 doesn't seem to have it. the Distutil page says that it has been part of the distribution since 1.6 .... what gives? Thanks Raj Datta Professional Services Direct : 408-530-4932 CrossAccess Corp Cell : 408-316-5473 2900 Gordon Ave #100 Fax : 408-735-0328 Santa Clara CA 95051 Email : rd...@cr... |
From: John G. <jgo...@co...> - 2001-09-27 07:38:40
|
"Robert W. Bill" <rb...@di...> writes: > An implementation quirk. If dir() doesn't reveal an object's > methods, add ".__class__" to get a closer look. Is that a bug? It somewhat seems that way to me. Or is it a fluke that CPython worked the way it did? |
From: Carlos Q. <car...@we...> - 2001-09-26 21:11:46
|
On Wednesday 26 September 2001 23:57, Mat...@i2... wrote: Some answers > Hi all, > > I recently discovered jython - I must say, very cool! > > I'm trying to embed a jython interpreter within a java application, and I > have most things working, but have a few questions: > > 1) With an embedded interpreter, do I still need the jython distribution > directory in order for the scripts I run to have access to the standard > lib (Lib\*.py)? Yes, or you can create a jar containin al libs and distribute that. In this case you have to explictly add the file to sys.path > 2) How do I add an instance of a Java object to the namespace I pass to > the PythonInterpreter exec() method? You can set a variable beforfe interpeter.set(object, "name") interpeter.exec("foo(name)") > 3) How do I programmatically define a python class (and instantiate it) > and pass it to the interpreter as in (2) ? By programmatically I mean > calling a bunch of java methods and _not_ simply evaluating a string that > has my python class. Can you explain this a little bit better, do you want to programatically define the class interface and implementation? > 4) W.r.t (2) and (3) what I'm really trying to do is delegate to a Java > instance from a Python instance so I can default some of the arguments on > some methods (i.e. make a nicer interface to my java internals for the > script writers). Any tips on how to do this? > 5) I setup my own SecurityManager to deny exits so that scripts can't > terminate my java process - anyone know of a better way to do this? Not me at least > 6) If no to (5), I wrap my script execution in a try/except block to catch > my DenyExitSecurityException, thus enabling me to swallow the ugly stack > trace when a script calls exit, however, this only works when the script > calls the java System.exit(), with sys.exit() I still get the stack trace. > Any idea how to stop this before I go digging around in the code? > > Any help appreciated, thanks, > > Matt > mat...@i2... > > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users |
From: Samuele P. <pe...@in...> - 2001-09-26 21:02:47
|
[Ted Berg] > > :) no secrets, but not much of a clue either. Here's the relevant code, if > it helps. > <snip> > > I've put an __init__.py file in both the pyhandlers and nodehandlers > directories, but i still get the 'ImportError: no module named ...' errors. > ( note that they are suppressed in this code ). Then I should check that out. regards. |
From: <Mat...@i2...> - 2001-09-26 20:57:45
|
Hi all, I recently discovered jython - I must say, very cool! I'm trying to embed a jython interpreter within a java application, and I have most things working, but have a few questions: 1) With an embedded interpreter, do I still need the jython distribution directory in order for the scripts I run to have access to the standard lib (Lib\*.py)? 2) How do I add an instance of a Java object to the namespace I pass to the PythonInterpreter exec() method? 3) How do I programmatically define a python class (and instantiate it) and pass it to the interpreter as in (2) ? By programmatically I mean calling a bunch of java methods and _not_ simply evaluating a string that has my python class. 4) W.r.t (2) and (3) what I'm really trying to do is delegate to a Java instance from a Python instance so I can default some of the arguments on some methods (i.e. make a nicer interface to my java internals for the script writers). Any tips on how to do this? 5) I setup my own SecurityManager to deny exits so that scripts can't terminate my java process - anyone know of a better way to do this? 6) If no to (5), I wrap my script execution in a try/except block to catch my DenyExitSecurityException, thus enabling me to swallow the ugly stack trace when a script calls exit, however, this only works when the script calls the java System.exit(), with sys.exit() I still get the stack trace. Any idea how to stop this before I go digging around in the code? Any help appreciated, thanks, Matt mat...@i2... |
From: Ted B. <te...@et...> - 2001-09-26 20:35:09
|
On Wednesday 26 September 2001 13:01, you wrote: > [Ted Berg] > > > > have you an __init__.py or __init__$py.class there? > > > > No, I don't. Do I need to do anything special in the __init__.py file, > > or does it just need to be there? > > Just need to be there. If then it still don't work it's a bug ;) > or you have other secrets. > > regards. :) no secrets, but not much of a clue either. Here's the relevant code, if it helps. Essentially every time someone imports or creates a new node in a tree control in the application, a new BaseNodehandler subclass is created based on info provided in the XML that describes the node. if, for example, the XML element says it's for a textctrl_handler, the java class net.etherstorm.jOpenRPG.nodehandlers.textctrl_handler is created. If the XML element says it's for a alias_handler, the loadJavaNodehandler call returns null, and the code tries to load the script/pyhandlers/alias_handler.py script included in the jar or, failing that, the <user's home directory>/nodehandlers/alias_handler.py script. I've put an __init__.py file in both the pyhandlers and nodehandlers directories, but i still get the 'ImportError: no module named ...' errors. ( note that they are suppressed in this code ). ---- <code> /** * Method declaration * * * @param name * @param e * * @return * * */ BaseNodehandler loadJavaNodehandler( String name, Element e ) { try { String classname = "net.etherstorm.jOpenRPG.nodehandlers." + name; Class c = getClass().getClassLoader().loadClass( classname ); Class[] arg_types = { Element.class }; java.lang.reflect.Constructor ctor = c.getConstructor( arg_types ); Object[] args = { e }; BaseNodehandler bnh = ( BaseNodehandler )ctor.newInstance( args ); return bnh; } catch ( Exception ex ) { /* ExceptionHandler.handleException( ex ); */ return null; } } /** * Method declaration * * * @param name * @param e * * @return * * */ BaseNodehandler loadInternalPyNodehandler( String name, Element e ) { try { this.referenceManager.getPythonInterpreter().exec( "import java\nimport sys\njava.lang.System.out.println( sys.path )" ); System.out.println( "using internal python nodehandler" ); /* this.referenceManager.getPythonInterpreter().exec( "import scripts" ); */ /* this.referencemanager.getpythoninterpreter().exec( "import scripts.pyhandlers" ); */ this.referenceManager.getPythonInterpreter().exec( "import pyhandlers" ); this.referenceManager.getPythonInterpreter().set( "__element", e ); this.referenceManager.getPythonInterpreter().exec( "__foo = pyhandlers." + name + "( __element )" ); BaseNodehandler bnh = ( BaseNodehandler )this.referenceManager.getPythonInterpreter().get( "__foo", BaseNodehandler.class ); System.out.println( bnh ); System.out.println( "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" ); return bnh; } catch ( Exception ex ) { /* ExceptionHandler.handleException( ex ); */ return null; } } /** * Method declaration * * * @param name * @param e * * @return * * */ BaseNodehandler loadExternalPyNodehandler( String name, Element e ) { try { File f = new File( System.getProperty( "user.home" ) + File.separator + "jopenrpg" + File.separator + "nodehandlers" + File.separator + name + ".py" ); if ( f.exists() ) { this.referenceManager.getPythonInterpreter().exec( "import nodehandlers" ); this.referenceManager.getPythonInterpreter().set( "__element", e ); this.referenceManager.getPythonInterpreter().exec( "__foo = nodehandlers." + name + "( __element )" ); BaseNodehandler bnh = ( BaseNodehandler )this.referenceManager.getPythonInterpreter().get( "__foo", BaseNodehandler.class ); return bnh; } else { return null; } } catch ( Exception ex ) { /* ExceptionHandler.handleException( ex ); */ return null; } } /** * * * @param name * @param e * @return */ BaseNodehandler loadHandler( String name, Element e ) { BaseNodehandler bnh = loadJavaNodehandler( name, e ); if ( bnh == null ) { bnh = loadInternalPyNodehandler( name, e ); if ( bnh == null ) { bnh = loadExternalPyNodehandler( name, e ); if ( bnh == null ) { bnh = new UnknownNodehandler( e ); } } } return bnh; } </code> ---- |
From: Ted B. <te...@et...> - 2001-09-26 20:25:57
|
On Wednesday 26 September 2001 13:13, Carlos Quiroz wrote: > On Wednesday 26 September 2001 22:09, Ted Berg wrote: > Hi Ted, could you describe how you load dynamically a java jar, I have had > some problems to do it > > Regards > I'm not actually dynamically loading the jar. the modules are shipped within the jar i'm using. What are you trying to load from the jar on the fly? I'm not an expert at such things, by any means, but I can try to help. ted |
From: Carlos Q. <car...@we...> - 2001-09-26 20:16:16
|
On Wednesday 26 September 2001 22:09, Ted Berg wrote: Hi Ted, could you describe how you load dynamically a java jar, I have had some problems to do it Regards > I have a java application that makes use of jython as a scripting engine. > I want to allow the end user to extend the functionality I provide by > dynamically loading module ( java or python ) at runtime. The java stuff > is working fine, but i'm running into a problem with the embedded python. > > runtime sys.path looks like this: > ['.', > '/home/tedberg/.javaws/cache/http/Djopenrpg.sourceforge.net/P80/DMfiles/RMj >openrpg.jar!Lib', > '/home/tedberg/.javaws/cache/http/Djopenrpg.sourceforge.net/P80/DMfiles/RMj >openrpg.jar!scripts', '/home/tedberg/jopenrpg'] > > I can import python modules in the directories "Lib" and "scripts" that are > in the jar. What I *cannot* do, and *need* to do, is import modules in > "!scripts/pyhandlers". > > I have tried: > from scripts import pyhandlers > import scripts.pyhandlers > import pyhandlers > > all of which return a "no module named" referencing scripts and pyhandlers > respectively. > > Also: > I can do a "import nodehandlers" ( nodehandlers is a dir in > /home/tedberg/jopenrpg ), but I cannot import any modules *within* that > directory.l > > What *am* I doing wrong? > > ted > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users |