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: Kevin B. <kb...@ca...> - 2001-10-31 16:44:24
|
> V=E1clav Tolar wrote: >=20 > Hello, > I would like to get help from you. > I am using PythonInterpreter object to execute some Python commands= . If executing command has bad syntax or throwing exception, some jav= a exception from exec(String) method is thrown. > Now, what I want to is to determine what KIND of error in python co= mmad was occured - for example there is SYNTAX ERROR or PYTHON EXCEPT= ION is thrown. You can do this by grabbing sys.last_value and sys.last_type. Example follows: import org.python.util.*; import org.python.core.*; import java.io.*; import java.util.*; /** * Test for exception in executed code by looking at sys.last_value, = etc. **/ public class InterpException { public static void main( String[] args ) throws Exception { PythonInterpreter.initialize( System.getProperties(), new Properties(), args ); =20 InteractiveInterpreter interp =3D new InteractiveInterpreter(= ); //#Console(); //# String inputLine =3D ""; String taskText =3D ""; DataInputStream in =3D new DataInputStream( System.in ); boolean more; String prompt =3D ">>>"; // get 'sys' imported interp.runsource( "import sys" ); // get reference to 'sys' module PyString sysName =3D new PyString( "sys" ); PyStringMap locals =3D (PyStringMap) interp.getLocals(); PySystemState sys =3D (PySystemState) locals.get( sysName ); PyObject lastValue; =20 System.out.print( prompt ); while ((inputLine =3D in.readLine()) !=3D null){ lastValue =3D sys.last_value; // sentinel to check if it = hasn't changed if ( taskText.length() > 0 ) { taskText +=3D "\n"; } taskText +=3D inputLine; more =3D interp.runsource( taskText ); if ( more ) { prompt =3D "..."; } else { taskText =3D ""; prompt =3D ">>>"; } if ( lastValue !=3D sys.last_value ) // an error occurred= in this statement { System.out.println( "An error of type: " + sys.last_t= ype + " occurred." ); // use sys.last_traceback and sys.last_value as desir= ed... } =20 System.out.print( prompt ); } } } kb |
From: Andres Corrada-E. <co...@ci...> - 2001-10-31 16:05:30
|
Hello, I'm trying to set-up Jython to use the XML functionality in jaxp.jar and parser.jar. The code fails with an error of the form: TypeError: parse(): 1st arg can't be coerced to java.io.File, org.xml.sax.InputSource, java.io.InputStream or String The code is as follows: # Create new SAXParser factory = SAXParserFactory.newInstance() saxParser = factory.newSAXParser() # Create new handler handler = BookLibrary() # The test file to parse file = java.io.File('./books.xml') saxParser.parse( file, handler) It seems that "parse" is being fed the class instance first, but I cannot figure out how to do the call properly. Similar code works within Java code, so I know classes are being recognized and have the required methods. Any clue what I'm doing wrong? Thank you. Andres Corrada-Emmanuel Senior Research Fellow Center for Intelligent Information Retrieval University of Massachusetts, Amherst |
From: <to...@gn...> - 2001-10-31 08:06:09
|
Hello, I would like to get help from you.=20 I am using PythonInterpreter object to execute some Python commands. If = executing command has bad syntax or throwing exception, some java = exception from exec(String) method is thrown. Now, what I want to is to determine what KIND of error in python commad = was occured - for example there is SYNTAX ERROR or PYTHON EXCEPTION is = thrown. Thanks, Vaclav Tolar |
From: Ype K. <yk...@xs...> - 2001-10-30 19:21:47
|
This is especially for those interested in using multithreading and multiprocessors in Jython: After the profiler showed me that quite a bit of time is spent non waiting in threading.py (even in no more used debugging code), I looked around for a more 'native' solution and, to my surprise, found something very appropriate for jython. I downloaded the zip file and wrote a python interface (less than 100 code lines) below. Thanks to Doug Lea and Mr. Laufer for making this so easy. The package is called util.concurrent and it uses method names that are almost a perfect match for the standard python names. I refrained from adapting the names completely to the python standard for performance reasons. (Having small differences between `platforms' is quite common in python.) I think concurrent.py is an appropriate name for what follows: """ Jython interface to the util.concurrent package of Doug Lea. See: http://g.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html This is based on the java 1.1 precompiled version downloaded from: http://www.cs.luc.edu/~laufer/courses/337/handouts/concurrent11.zip This zip file should be on the class path when invoking jython for using this module. From the documentation of util.concurrent: " This package provides standardized, efficient versions of utility classes commonly encountered in concurrent Java programming. The ideas behind and applications of several of these classes are discussed in the second edition of Concurrent Programming in Java. [...] The packege mainly consists of implementations of a few interfaces: Sync -- locks, conditions Channel -- queues, buffers Barrier -- multi-party synchronization SynchronizedVariable -- atomic ints, refs etc java.util.Collection -- collections Executor -- replacements for direct use of Thread Plus some utilities and frameworks that build upon these. " (One of these frameworks is the Fork/Join Task framework for efficient use of threads on multiprocessor systems. There is no python interface defined for this.) This python module defines alternate and faster versions of: Queue.Queue threading.RLock threading.Condition threading.Semaphore Also defined, but not faster: threading.Lock threading.Event (The Event defined here is the standard version, it may be faster because it is using a faster Condition). Non standard behaviour: Not available: Use instead: acquire() with a time out attempt(msecs) wait() with time out timedwait(msecs) Semaphore() Semaphore(1). size() of unbounded Queue nothing. A java.lang.Interrupt can be generated when threads have been interrupted elsewhere. The standard behaviour in jython is that a java.lang.Interrupt (eg. during time.sleep()) causes a message to standard output: "Interrupted thread". """ import EDU.oswego.cs.dl.util.concurrent as _conc # To access the full util.concurrent module: # from _conc import * class Queue: """Uses (Bounded)LinkedQueue from util.concurrent.""" def __init__(self, maxSize = 0): if maxSize == 0: self.q = _conc.LinkedQueue() # no qsize available forLinkedQueue, why? else: self.q = _conc.BoundedLinkedQueue(maxSize) self.qsize = self.q.size self.full = lambda self=self: self.qsize() >= self.q.capacity() self.empty = self.q.isEmpty self.get = self.q.take self.put = self.q.put # Add when needed: #self.get_timedwait = self.q.poll # msecs #self.put_timedwait = self.q.offer # msecs def put_nowait(self, item): return self.q.offer(item, 0) def get_nowait(self): return self.q.poll(0) Lock = _conc.Mutex RLock = _conc.ReentrantLock class Condition: def __init__(self, lock=None): if lock is None: lock = RLock() self.acquire = lock.acquire self.release = lock.release cv = _conc.CondVar(lock) self.notify = cv.signal self.notifyAll = cv.broadcast self.wait = cv.await self.timedwait = cv.timedwait Semaphore = _conc.Semaphore # no more default 1 arg. class Event: # Based on threading.py from the jython 21a3 distribution. # Uses the Condition and Lock of this module. Added a timedwait() method. # Might alternatively be based on _conc.WaitableBoolean, but then there is no timeout available. # (WaitableBoolean needs java 1.2 collections.) # After Tim Peters' event class (without is_posted()) def __init__(self): self.__cond = Condition(Lock()) self.__flag = 0 def isSet(self): return self.__flag def set(self): self.__cond.acquire() self.__flag = 1 self.__cond.notifyAll() self.__cond.release() def clear(self): # _cond.Latch can't do this. self.__cond.acquire() self.__flag = 0 self.__cond.release() def wait(self): # time argument only in timedwait() method self.__cond.acquire() if not self.__flag: self.__cond.wait() self.__cond.release() def timedwait(self, msecs): self.__cond.acquire() if not self.__flag: self.__cond.timedwait(msecs) self.__cond.release() |
From: rohit s. <ro2...@ya...> - 2001-10-30 08:33:42
|
Hi, In jython we can execute .ghs files which can be used to extend our .py files. PythonInterpreter.execfile("A.py") PythonInterpreter.execfile("B.ghs") B.ghs is created by the end user to control A.py To what extent can we play with these .ghs files. Can we import them as modules? If not directly then with some other way round. Any pointers to some material available on the same or any kind of hint will be highly appreciated. Thanks and Regards, Rohit Seth __________________________________________________ Do You Yahoo!? Make a great connection at Yahoo! Personals. http://personals.yahoo.com |
From: brian z. <bz...@zi...> - 2001-10-29 22:20:56
|
If you have a PyObject and want to get the underlying Java instance, use: po.__tojava__(<the Java class you want>) For instance, say arg is a PyInteger instance, the following would get the long value: long ticks = ((Number) arg.__tojava__(Number.class)).longValue(); Most subclasses (maybe all) of PyObject implement this method and try their best to give you what you want. It's amazing thorough for most types. brian ----- Original Message ----- From: "Sells, Fred" <fr...@ad...> To: "Jython (E-mail)" <jyt...@li...> Sent: Monday, October 29, 2001 3:15 PM Subject: [Jython-users] casting a java object created in jython to its true class > I use exec() in java to run some Python that defines gui elements. > > I would like to get specific elements by name. > > I can get do PyObject po = Python.get("xyz") > > but I cannot cast this to anything but java.lang.Object > > what am I missing here???? > > tia > > fred > > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users |
From: Sells, F. <fr...@ad...> - 2001-10-29 21:15:43
|
I use exec() in java to run some Python that defines gui elements. I would like to get specific elements by name. I can get do PyObject po = Python.get("xyz") but I cannot cast this to anything but java.lang.Object what am I missing here???? tia fred |
From: <Mat...@i2...> - 2001-10-29 21:06:37
|
On 10/27/2001 10:03:47 PM "Robert W. Bill" wrote: > > Wait for a patch <g> > Did a little digging - I think its a one line fix, and this fix does work for me, but not sure if it might break something else...? I'm not sure how patches should be generated, so here is what I did. In jython/org/python/core/SyspathArchive.java, change makeEntry from: private String makeEntry(String entry) { String archive = super.toString(); int idx = archive.indexOf('!'); if (idx < 0) { return entry; } String folder = archive.substring(idx+1); return folder + "/" + entry; } To: private String makeEntry(String entry) { String archive = super.toString(); int idx = archive.indexOf('!'); if (idx < 0) { return entry; } String folder = archive.substring(idx+1).replace('!', '/'); return folder + "/" + entry; } |
From: Robert W. B. <rb...@di...> - 2001-10-28 02:04:04
|
Hi Matt, On Sat, 27 Oct 2001 Mat...@i2... wrote: > On 10/27/2001 02:19:07 AM jython-users-admin wrote: > > > > java -Dpython.home=/export/cvs/jython \ > > Do you have a Lib directory in your python home? If you do, you could be > getting pawt from there. DOH! I'm sure you've already guessed the answer here :) Yes, I forgot to hide Lib before testing, but I was also lazy in reading the debugging output because of some assumptions made based on the imp.java source. The loadFromZipFile method in imp.java checks for packages (__init__.py), which only makes sense if it traverses packages. After looking closer, it seems that it does not correctly traverse packages in archives. This makes "import pawt.colors" and other packages stored in archive files not work at the present time. > > One guess might be that you have a package that is missing its > __init__.py > > file. > > Hmm, There is a __init__.py in the pawt directory, but none in the Lib > directory (just a __future__.py) > Could that be the cause? Only packages need __init__.py (those directories that are subdirectories of sys.path entries. e.g. Lib/pawt). So Lib itself doesn't need an __init__.py. > Windows 2000SP2 > java full version "1.3.1_01a" > > Any ideas? Wait for a patch <g> -robert |
From: <Mat...@i2...> - 2001-10-27 20:22:29
|
On 10/27/2001 02:19:07 AM jython-users-admin wrote: > > java -Dpython.home=/export/cvs/jython \ Do you have a Lib directory in your python home? If you do, you could be getting pawt from there. > One guess might be that you have a package that is missing its __init__.py > file. Hmm, There is a __init__.py in the pawt directory, but none in the Lib directory (just a __future__.py) Could that be the cause? Windows 2000SP2 java full version "1.3.1_01a" I run it like this: java -Dpython.path=jython-lib.jar!Lib -classpath "jython.jar;jython-lib.jar" org.python.util.jython -v import: 'exceptions' as org.python.core.exceptions in builtin modules Jython 2.1a3 on java1.3.1_01 (JIT: null) import: 'site' as Lib/site$py.class import: 'sys' as sys in builtin modules import: 'os' as org.python.modules.os in builtin modules import: 'javaos' as Lib/javaos$py.class import: 'java' as java package import: 'File' as java class import: 'javapath' as Lib/javapath$py.class import: 'System' as java class import: 'sitecustomize' not found (=> ImportError) Type "copyright", "credits" or "license" for more information. >>> import string import: 'string' as Lib/string$py.class import: 'strop' not found (=> ImportError) >>> import pawt import: 'pawt' not found (=> ImportError) Traceback (innermost last): File "<console>", line 1, in ? ImportError: no module named pawt >>> I can validate the contents of jython-lib.jar by uncompressing it into a temp directory and running against that instead, with the following results: unzip jython-lib.jar t java -Dpython.path=./t/Lib -classpath"jython.jar" org.python.util.jython -v import: 'exceptions' as org.python.core.exceptions in builtin modules Jython 2.1a3 on java1.3.1_01 (JIT: null) import: 'site' as .\t\Lib\site$py.class import: 'sys' as sys in builtin modules import: 'os' as org.python.modules.os in builtin modules import: 'javaos' as .\t\Lib\javaos$py.class import: 'java' as java package import: 'File' as java class import: 'javapath' as .\t\Lib\javapath$py.class import: 'System' as java class import: 'sitecustomize' not found (=> ImportError) Type "copyright", "credits" or "license" for more information. >>> import string import: 'string' as C:\dvobs\a-Source\CommonServices\dist\lib\.\t\Lib\string$py.class import: 'strop' not found (=> ImportError) >>> import pawt import: 'pawt' as C:\dvobs\a-Source\CommonServices\dist\lib\.\t\Lib\pawt\__init__.py import: 'pawt' as java package >>> Any ideas? Matt |
From: Robert W. B. <rb...@di...> - 2001-10-27 06:19:20
|
On Fri, 26 Oct 2001 Mat...@i2... wrote: > I have a jar setup containing all of jython/Lib (*.py and all > pre-byte-compiled *$py.class). I pass in a "-Dpython.path=my.jar!Lib", > and imports work fine for all the modules in the main Lib directory (e.g. > glob), but if I try and import something in a nested directory (e.g. > Lib/pawt) I get an ImportError. Any ideas? Thanks, > > Matt I think some additional info would help here. I tried the same setup you mention, and all the pawt modules/classes imported correctly (without ImportError). The trick now is to find out what is different for you. -My setup== jdk1.3.1, Linux, latest cvs jython -all libs (*.py and *.class files) in jyLibs.jar. -used the following command to start Jython: java -Dpython.home=/export/cvs/jython \ -Dpython.path=/export/cvs/jython/jyLibs.jar\!Lib \ -cp /export/cvs/jython/jython.jar:/export/cvs/jython/jyLibs.jar \ org.python.util.jython -v -the following imports work fine (plus other permutations of from pawt import x): import pawt.colors import pawt.GridBag import pawt.swing One guess might be that you have a package that is missing its __init__.py file. -Robert |
From: Samuele P. <pe...@in...> - 2001-10-26 23:43:55
|
> Ok, that makes sense - is there a particular reason why jython doesn't > have a custom classloader to which add_* adds extra paths? Or is just > that no one has gotten around to it yet? =) > You should consider that the add_ family generalize from add_package (the desire would be to make it's usage very rare, but in reality we needed generalizations too), which is about informing jython about loadable packages not about setting up classloaders ... So what would seems natural in the add_extdir,etc perspective, it is not in the general (add_package). regards, Samuele. |
From: <Mat...@i2...> - 2001-10-26 23:38:13
|
I have a jar setup containing all of jython/Lib (*.py and all pre-byte-compiled *$py.class). I pass in a "-Dpython.path=my.jar!Lib", and imports work fine for all the modules in the main Lib directory (e.g. glob), but if I try and import something in a nested directory (e.g. Lib/pawt) I get an ImportError. Any ideas? Thanks, Matt |
From: <Mat...@i2...> - 2001-10-26 23:31:46
|
Ok, that makes sense - is there a particular reason why jython doesn't have a custom classloader to which add_* adds extra paths? Or is just that no one has gotten around to it yet? =) Matt On 10/26/2001 06:35:00 PM "Robert W. Bill" wrote: > > Yes, the add_* methods (add_classdir, add_extdir, add_package) are a bit > tricky because they do not make classes available to Jython, they just > give the packageManager some hints to make the packages available. The > classloader still must find the class in the classpath |
From: Robert W. B. <rb...@di...> - 2001-10-26 22:35:11
|
On Fri, 26 Oct 2001 Mat...@i2... wrote: > Ahh, ok, that worked, thanks. > Actually - that also fails if my jar isn't in my classpath when I start > jython, and I use sys.add_extdir() to add the dir containing my jar. > > Matt Yes, the add_* methods (add_classdir, add_extdir, add_package) are a bit tricky because they do not make classes available to Jython, they just give the packageManager some hints to make the packages available. The classloader still must find the class in the classpath -robert > On 10/26/2001 08:19:32 PM jython-users-admin wrote: > > > > Import should work with classes that are not in a package. If class > "foo" > > has no package statement and is in the classpath, then "import foo" > should > > work. > > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > |
From: <Mat...@i2...> - 2001-10-26 21:54:59
|
Ahh, ok, that worked, thanks. Actually - that also fails if my jar isn't in my classpath when I start jython, and I use sys.add_extdir() to add the dir containing my jar. Matt On 10/26/2001 08:19:32 PM jython-users-admin wrote: > > Import should work with classes that are not in a package. If class "foo" > has no package statement and is in the classpath, then "import foo" should > work. |
From: Robert W. B. <rb...@di...> - 2001-10-26 21:25:13
|
Hello Matt, On Thu, 25 Oct 2001 Mat...@i2... wrote: > I'm having a problem loading python modules from a jar file. > I'm trying to package up the jython/Lib dir into a jar for use within an > embededded interpreter. > > If I jar up the contents of Lib into jython-lib.jar and add > "-Dpython.path=jython-lib.jar!Lib" to the launch of my app, it all works > fine. > If I first byte compile the contents of Lib and jar it up, that also works > fine. > However, if I jar up _just_ the byte compiled files in Lib, then I get > module import errors. > > Any idea what the problem is? I don't mind doing the second scenario so > long as someone can confirm that jython does in fact use the byte compiled > files and not the py files when they both exist in the jar. Thanks, > > Matt > mat...@i2... Jython's -v option allows you to trace the imports. Trying -v with your option #2 should show the *$py.class is used. The loadFromZip(jar)File actually does the same file time checking as it would from a dir to make sure the .py file isn't newer than the .class file, which makes loads from the jar fail without the .py files. I've wondered if this is necessary. Finn and Samuele have a better handle on that, but if you wanted to experiment with a *.py-less jar file the unified diff to do so is below. -robert ---------------------------------- --- jython/org/python/core/imp.java Fri Oct 26 16:20:15 2001 +++ imp.java Fri Oct 26 16:15:40 2001 @@ -308,24 +308,20 @@ ZipEntry pyEntry = zipArchive.getEntry(pyName); ZipEntry classEntry = zipArchive.getEntry(className); - if (pyEntry != null) { - Py.writeDebug("import", "trying source entry: " + pyName + - " from jar/zip file " + zipArchive); - if (classEntry != null) { - Py.writeDebug("import", "trying precompiled entry " + - className + " from jar/zip file " + - zipArchive); - long pyTime = pyEntry.getTime(); - long classTime = classEntry.getTime(); - if (classTime >= pyTime) { - InputStream is = zipArchive.getInputStream(classEntry); - o = createFromPyClass(modName, is, true, - classEntry.getName()); - if (o != null) { - return o; - } - } - } + Py.writeDebug("import", "trying source entry: " + pyName + + " from jar/zip file " + zipArchive); + if (classEntry != null) { + Py.writeDebug("import", "trying precompiled entry " + + className + " from jar/zip file " + + zipArchive); + InputStream is = zipArchive.getInputStream(classEntry); + o = createFromPyClass(modName, is, true, + classEntry.getName()); + if (o != null) { + return o; + } + } + if (pyEntry != null) { InputStream is = zipArchive.getInputStream(pyEntry); return createFromSource(modName, is, pyEntry.getName(), null); } |
From: Robert W. B. <rb...@di...> - 2001-10-26 19:26:05
|
On Fri, 26 Oct 2001 Mat...@i2... wrote: > How does one import the default java package - i.e. I want to use a class > in the jython interpreter that has no package name. > > Matt > mat...@i2... Import should work with classes that are not in a package. If class "foo" has no package statement and is in the classpath, then "import foo" should work. -robert |
From: Samuele P. <pe...@in...> - 2001-10-26 16:32:03
|
Andres Corrada-Emmanuel wrote: > I didn't know about the jython switch. I'd rather set the > switch and avoid having to write wrapper classes. I was beginning to > despair that Jython was not up to the task. This is awesome! > This is very newbie :) , without offense. I would not consider the python.respectJavaAccessibility option a production option, while handy it is more a testing option, in particular not a newbie option. It should be noted that under some security settings it will not work and in some applicative context it can cause security troubles ... Anyway in your case this could be just irrelevant, I'm lacking the context information to assess this. regards, Samuele Pedroni. |
From: <Mat...@i2...> - 2001-10-26 15:28:57
|
How does one import the default java package - i.e. I want to use a class in the jython interpreter that has no package name. Matt mat...@i2... |
From: Andres Corrada-E. <co...@ci...> - 2001-10-26 01:06:06
|
Hi Kevin, Thank you for the example code. It illustrates my confusion perfectly. I hope this sort of newbie mistake gets posted to the FAQ with your example solution. Andres Corrada-Emmanuel Senior Research Fellow Center for Intelligent Information Retrieval University of Massachusetts, Amherst On Thu, 25 Oct 2001, Kevin Butler wrote: > You can do it just fine, but you have to set 'respectJavaAccessibility=false' in the jython registry (and this requires some permission in the Java VM - usually not a problem for Java applications, but applets may have problems). > > The reason that you still need to set this flag, even though you are generating code in the appropriate package , is that jythonc generates java code that uses the Python interpreter classes to do the method/attribute lookup. This means that the Python classes are trying to access the protected attribute, rather than the class that you generated. > > Example from my generated code, attempting to access the '_package' variable (package protected): > > Py.printComma(frame.getlocal(0).__getattr__("_package")); > > Note that it isn't doing the reflection itself, but is delegating to PyObject to do the reflection. > > My code & makefile attached below. > > kb > > ---Attribute.java > package test; > > public class Attribute > { > private int _private = 1; > int _package = 2; > protected int _protected = 3; > public int _public = 4; > } > > > ---testAttribute.py > from test import Attribute > class X( Attribute ): > def go( self ): > print self._package, self._private, self._protected, self._public > > X().go() > > ---Makefile > testAttribute: > javac -d . Attribute.java > jythonc --package test testAttribute.py > java -classpath .\;./jpywork\;w:/tools/jython/jython.jar test.testAttribute > > ---command: > make testAttribute > > ---output: > javac -d . Attribute.java > jythonc --package test testAttribute.py > processing testAttribute > > Required packages: > test > > Creating adapters: > > Creating .java files: > testAttribute module > X extends test.Attribute > > Compiling .java to .class... > Compiling with args: ['D:\\jdk1.3\\bin\\javac', '-classpath', '"w:/tools/jython/jython.jar;.;w:\\classes;w:\\lib\\ldapjdk.jar;w:\\lib\\xerces.jar;w:\\lib\\ldap.jar;w:\\lib\\providerutil.jar;w:\\lib\\jaas.jar;w:\\lib\\jndi.jar;w:\\lib\\ldapbp.jar;w:\\lib\\jsse-export\\jnet.jar;w:\\lib\\jsse-export\\jsse.jar;w:\\jars\\servlet.jar;w:\\;.\\jpywork;;w:\\tools\\jython\\Tools\\jythonc;e:\\work\\kb\\test\\jython\\.;w:\\tools\\jython\\Lib;w:\\src\\com\\pipeline\\test\\bom;w:\\src\\com\\pipeline\\test;d:\\python;w:\\tools\\jython"', '.\\jpywork\\test\\testAttribute.java'] > 0 Note: Some input files use or override a deprecated API. > Note: Recompile with -deprecation for details. > > java -classpath .\;./jpywork\;w:/tools/jython/jython.jar test.testAttribute > 2 1 3 4 > > > The '2 1 3 4' is the output of the command. > > It looks like it works to me - note that I have 'respectJavaAccessibility=false' in my jython registry. > > If I have 'respect...=true', I get: > > Java Traceback: > > at org.python.core.Py.AttributeError(Py.java:90) > at org.python.core.PyObject.__getattr__(PyObject.java:692) > at test.testAttribute$_PyInner.go$1(testAttribute.java:43) > at test.testAttribute$_PyInner.call_function(testAttribute.java:32) > at org.python.core.PyTableCode.call(PyTableCode.java:198) > at org.python.core.PyTableCode.call(PyTableCode.java:253) > at org.python.core.PyFunction.__call__(PyFunction.java:170) > at org.python.core.PyInstance.invoke(PyInstance.java:236) > at test.testAttribute$_PyInner.main$3(testAttribute.java:59) > at test.testAttribute$_PyInner.call_function(testAttribute.java:36) > at org.python.core.PyTableCode.call(PyTableCode.java:198) > at org.python.core.PyCode.call(PyCode.java:13) > at org.python.core.imp.createFromCode(imp.java:165) > at org.python.core.Py.runMain(Py.java:818) > at test.testAttribute.main(testAttribute.java:110) > Traceback (innermost last): > File "E:\work\kb\test\jython\testAttribute.py", line 0, in main > File "E:\work\kb\test\jython\testAttribute.py", line 0, in go > AttributeError: instance of 'X' has no attribute '_package' > > kb > > Andres Corrada-Emmanuel wrote: > > > > Hello, > > > > My problem has evolved to this thread. Let me recapitulate my intent: > > > > To create a Java class using Python code. The Python class subclasses from > > a class in some package "edu.umass.cs.ciir.metamorph". > > > > I compile the Python class to a .class file using jythonc with the > > package switch. The resultant .java file has the correct package > > declaration: > > > > package edu.umass.cs.ciir.metamorph; > > > > at the top of the file. > > > > My Python class tries to access a package-accesible super attribute but > > fails. If I make that attribute public it succeeds. This is > > unsatisfactory. I'm trying to use someone elses code and I cannot change > > the attribute properties. > > > > Can I still use Jython or do I need to abandon this line of approach and > > resign myself to having to program in Java directly? > > > > Andres Corrada-Emmanuel > > Senior Research Fellow > > Center for Intelligent Information Retrieval > > University of Massachusetts, Amherst > > > > _______________________________________________ > > Jython-users mailing list > > Jyt...@li... > > https://lists.sourceforge.net/lists/listinfo/jython-users > |
From: Andres Corrada-E. <co...@ci...> - 2001-10-26 01:03:15
|
Hi Robert, Thank you. I didn't know about the jython switch. I'd rather set the switch and avoid having to write wrapper classes. I was beginning to despair that Jython was not up to the task. This is awesome! Andres Corrada-Emmanuel Senior Research Fellow Center for Intelligent Information Retrieval University of Massachusetts, Amherst On Thu, 25 Oct 2001, Robert W. Bill wrote: > > The package statement does not ensure that access occurs from this class. > Creating 'dynamicism' means using indirection. Jython's indirection > means that the attribute request may not originate in the class found > in the generated .java file. > > > My Python class tries to access a package-accesible super attribute but > > fails. If I make that attribute public it succeeds. This is > > unsatisfactory. I'm trying to use someone elses code and I cannot change > > the attribute properties. > > > > Can I still use Jython or do I need to abandon this line of approach and > > resign myself to having to program in Java directly? > > Yes. You can set python.respectJavaAccessibility to false and use Jython. > Even if you do not do so, you do not have to abandon Jython. Instead, > write only a wrapper class in java that makes access > Jython-friendly, then go about the project in Jython. > > -robert > > |
From: <Mat...@i2...> - 2001-10-25 23:50:23
|
I'm having a problem loading python modules from a jar file. I'm trying to package up the jython/Lib dir into a jar for use within an embededded interpreter. If I jar up the contents of Lib into jython-lib.jar and add "-Dpython.path=jython-lib.jar!Lib" to the launch of my app, it all works fine. If I first byte compile the contents of Lib and jar it up, that also works fine. However, if I jar up _just_ the byte compiled files in Lib, then I get module import errors. Any idea what the problem is? I don't mind doing the second scenario so long as someone can confirm that jython does in fact use the byte compiled files and not the py files when they both exist in the jar. Thanks, Matt mat...@i2... |
From: Kevin B. <kb...@ca...> - 2001-10-25 22:27:21
|
You can do it just fine, but you have to set 'respectJavaAccessibility=false' in the jython registry (and this requires some permission in the Java VM - usually not a problem for Java applications, but applets may have problems). The reason that you still need to set this flag, even though you are generating code in the appropriate package , is that jythonc generates java code that uses the Python interpreter classes to do the method/attribute lookup. This means that the Python classes are trying to access the protected attribute, rather than the class that you generated. Example from my generated code, attempting to access the '_package' variable (package protected): Py.printComma(frame.getlocal(0).__getattr__("_package")); Note that it isn't doing the reflection itself, but is delegating to PyObject to do the reflection. My code & makefile attached below. kb ---Attribute.java package test; public class Attribute { private int _private = 1; int _package = 2; protected int _protected = 3; public int _public = 4; } ---testAttribute.py from test import Attribute class X( Attribute ): def go( self ): print self._package, self._private, self._protected, self._public X().go() ---Makefile testAttribute: javac -d . Attribute.java jythonc --package test testAttribute.py java -classpath .\;./jpywork\;w:/tools/jython/jython.jar test.testAttribute ---command: make testAttribute ---output: javac -d . Attribute.java jythonc --package test testAttribute.py processing testAttribute Required packages: test Creating adapters: Creating .java files: testAttribute module X extends test.Attribute Compiling .java to .class... Compiling with args: ['D:\\jdk1.3\\bin\\javac', '-classpath', '"w:/tools/jython/jython.jar;.;w:\\classes;w:\\lib\\ldapjdk.jar;w:\\lib\\xerces.jar;w:\\lib\\ldap.jar;w:\\lib\\providerutil.jar;w:\\lib\\jaas.jar;w:\\lib\\jndi.jar;w:\\lib\\ldapbp.jar;w:\\lib\\jsse-export\\jnet.jar;w:\\lib\\jsse-export\\jsse.jar;w:\\jars\\servlet.jar;w:\\;.\\jpywork;;w:\\tools\\jython\\Tools\\jythonc;e:\\work\\kb\\test\\jython\\.;w:\\tools\\jython\\Lib;w:\\src\\com\\pipeline\\test\\bom;w:\\src\\com\\pipeline\\test;d:\\python;w:\\tools\\jython"', '.\\jpywork\\test\\testAttribute.java'] 0 Note: Some input files use or override a deprecated API. Note: Recompile with -deprecation for details. java -classpath .\;./jpywork\;w:/tools/jython/jython.jar test.testAttribute 2 1 3 4 The '2 1 3 4' is the output of the command. It looks like it works to me - note that I have 'respectJavaAccessibility=false' in my jython registry. If I have 'respect...=true', I get: Java Traceback: at org.python.core.Py.AttributeError(Py.java:90) at org.python.core.PyObject.__getattr__(PyObject.java:692) at test.testAttribute$_PyInner.go$1(testAttribute.java:43) at test.testAttribute$_PyInner.call_function(testAttribute.java:32) at org.python.core.PyTableCode.call(PyTableCode.java:198) at org.python.core.PyTableCode.call(PyTableCode.java:253) at org.python.core.PyFunction.__call__(PyFunction.java:170) at org.python.core.PyInstance.invoke(PyInstance.java:236) at test.testAttribute$_PyInner.main$3(testAttribute.java:59) at test.testAttribute$_PyInner.call_function(testAttribute.java:36) at org.python.core.PyTableCode.call(PyTableCode.java:198) at org.python.core.PyCode.call(PyCode.java:13) at org.python.core.imp.createFromCode(imp.java:165) at org.python.core.Py.runMain(Py.java:818) at test.testAttribute.main(testAttribute.java:110) Traceback (innermost last): File "E:\work\kb\test\jython\testAttribute.py", line 0, in main File "E:\work\kb\test\jython\testAttribute.py", line 0, in go AttributeError: instance of 'X' has no attribute '_package' kb Andres Corrada-Emmanuel wrote: > > Hello, > > My problem has evolved to this thread. Let me recapitulate my intent: > > To create a Java class using Python code. The Python class subclasses from > a class in some package "edu.umass.cs.ciir.metamorph". > > I compile the Python class to a .class file using jythonc with the > package switch. The resultant .java file has the correct package > declaration: > > package edu.umass.cs.ciir.metamorph; > > at the top of the file. > > My Python class tries to access a package-accesible super attribute but > fails. If I make that attribute public it succeeds. This is > unsatisfactory. I'm trying to use someone elses code and I cannot change > the attribute properties. > > Can I still use Jython or do I need to abandon this line of approach and > resign myself to having to program in Java directly? > > Andres Corrada-Emmanuel > Senior Research Fellow > Center for Intelligent Information Retrieval > University of Massachusetts, Amherst > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users |
From: Robert W. B. <rb...@di...> - 2001-10-25 20:41:54
|
On Thu, 25 Oct 2001, Andres Corrada-Emmanuel wrote: > Hello, > My problem has evolved to this thread. Let me recapitulate my intent: > > To create a Java class using Python code. The Python class subclasses from > a class in some package "edu.umass.cs.ciir.metamorph". > > I compile the Python class to a .class file using jythonc with the > package switch. The resultant .java file has the correct package > declaration: > > package edu.umass.cs.ciir.metamorph; > > at the top of the file. The package statement does not ensure that access occurs from this class. Creating 'dynamicism' means using indirection. Jython's indirection means that the attribute request may not originate in the class found in the generated .java file. > My Python class tries to access a package-accesible super attribute but > fails. If I make that attribute public it succeeds. This is > unsatisfactory. I'm trying to use someone elses code and I cannot change > the attribute properties. > > Can I still use Jython or do I need to abandon this line of approach and > resign myself to having to program in Java directly? Yes. You can set python.respectJavaAccessibility to false and use Jython. Even if you do not do so, you do not have to abandon Jython. Instead, write only a wrapper class in java that makes access Jython-friendly, then go about the project in Jython. -robert |