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: Mats W. <ma...@la...> - 2001-07-27 11:32:43
|
At 10:12 AM 7/25/2001 +0000, Finn Bock wrote: >>I am using Jython 2.1a1 and JDK (from Sun) 1.3.1 > >... and I believe 1.3.1 is the real problem. Even if it isn't, I >strongly doubt you can make java1 applets with a java2 JVM. You will >need to get hold of and install a JDK1.1 and use that when running >jythonc. I'm wondering if there are any sensible solutions to this. Can the 1.1 JDK coexist with a 1.3? I had understood that the purpose of the "Java plugin" that now comes bundled with the 1.3.x distribution kit was for this reason: you can't count on the browser, but you can add a plugin to take care of it. I haven't had any joy making that work, however. Is there something special one can do - thus enabling a 1.3-built Applet to run? i've sometimes detected that the plugin is active, but I seem never to have gotten it to work for a Jython-built applet. I don't believe this compatibility headache is unique to Jython, but the situation's not going to get better: Sun's started the end-of-life track on the 1.1 JDK (thus "continue to build with 1.1" is not going to remain a viable story). It also doesn't help that Microsoft is dropping Java support entirely in Win XP and IE. So back to the Java plugin question: how do I make that work, in the likely event I'm missing something. Mats |
From: Kieran B. <ki...@br...> - 2001-07-27 09:11:29
|
I get the following error: $ jython clone.py Traceback (innermost last): File "clone.py", line 13, in ? File "clone.py", line 7, in clone AttributeError: class 'java.lang.Object' has no attribute 'clone' For the following short code example from java.lang import * class MyClone(Object, Cloneable): def __init__(self): self.x = 4 def clone(self): return Object.clone(self) # the line that is being complained about if __name__=='__main__': x = MyClone() y = x.clone() print y.x ------------------------- clone() is protected on Object, so I guess I'm not calling the default super clone function correctly. In Java you would: return super.clone() How do I do this in Jython? Any info appreciated. |
From: Ginanjar U. <gin...@tp...> - 2001-07-27 01:55:12
|
From: Rune H. <ro...@vi...> - 2001-07-26 12:13:58
|
Regarding my previous post. I found and applyed the fix for the "Py Meta Class Bug". Lo and behold the applet runs. Now I get an error then exceuting the pageHandler function: "LookupError: no codec search functions registered: can't find encoding" Am I far off the mark when I suggest that jython2.x isn't quite ready for this kind of applets yet? I haven't had any problems with applets that don't use "Cpython" modules. regards Rune Hansen On Thu, 26 Jul 2001, Rune Hansen wrote: > I'm trying to create a (very) simple jython applet and theres obviously > something I'm doing wrong. > > --applet code-- > import urllib > import re > from java.applet import Applet > from java import awt > class simpleHttp(Applet): > def __init__(self): > self.setBackground(awt.Color.white) > self.setLayout(awt.FlowLayout()) > self.t1 = awt.TextField("",20) > self.b1 = awt.Button("Get IP",actionPerformed=self.pageHandler) > self.add(self.t1) > self.add(self.b1) > def pageHandler(self,event): > pagehandler = urllib.urlopen("http://someserver/cgi-bin/getIp.py") > data = pagehandler.read(512) > ipaddr = re.findall("\d+\.\d+\.\d+\.\d+",data) > pagehandler.close() > self.t1.setText(ipaddr[0]) > --applet-- > > I proceed to compile with "jythonc -c -d -j simpleHttp.jar > simpleHttp.py" and it compiles fine using both 2.0 and 2.1a2. When > executed it however exits with:"java.lang.ExceptionInInitializerError: > java.lang.ExceptionInInitializerError" when compiled with 2.0 and > "java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: > org/python/util/PyMetaClass" when compiled with 2.1.a2. -- |
From: Rune H. <ro...@vi...> - 2001-07-26 11:33:30
|
I'm trying to create a (very) simple jython applet and theres obviously something I'm doing wrong. --applet code-- import urllib import re from java.applet import Applet from java import awt class simpleHttp(Applet): def __init__(self): self.setBackground(awt.Color.white) self.setLayout(awt.FlowLayout()) self.t1 = awt.TextField("",20) self.b1 = awt.Button("Get IP") self.add(self.t1) self.add(self.b1) def pageHandler(self,event): pagehandler = urllib.urlopen("http://someserver/cgi-bin/getIp.py") data = pagehandler.read(512) ipaddr = re.findall("\d+\.\d+\.\d+\.\d+",data) pagehandler.close() self.t1.setText(ipaddr[0]) --applet-- I proceed to compile with "jythonc -c -d -j simpleHttp.jar simpleHttp.py" and it compiles fine using both 2.0 and 2.1a2. When executed it however exits with:"java.lang.ExceptionInInitializerError: java.lang.ExceptionInInitializerError" when compiled with 2.0 and "java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: org/python/util/PyMetaClass" when compiled with 2.1.a2. Rewritten without import urllib and re the applet compiles and runs with out errors. What am I not getting here? regards Rune Hansen run...@vi... Viventus AS Liaveien 11, 1411 Kolbotn +4766812280/86 "It's a damn poor mind that can only think of one way to spell a word." --Andrew Jackson |
From: Robert W. B. <rb...@di...> - 2001-07-25 19:19:09
|
On Wed, 25 Jul 2001, Joern Eckhoff wrote: > now my script looks like this: > > # ----------- begin ob script > import java > java.lang.System.getProperty("python.home") > java.lang.System.getProperty("python.path") > > import sys > sys.path.append("c:\\program files\\jython;c:\\program files\\jython\\lib") This append may be the culprit. Sorry if I've missed this in earlier mails, but for... sys.path.append("c:\\;c:\\windows\\desktop") import test # a Jython script on my desktop The above does not work. sys.path is a list of individual directories, rather than system directory representations (e.g. ["\\path\\one", "\\path\\two"] instead of \\path\\one;\\path\\two). Instead, if I use: sys.path.append("c:\\") sys.path.append("c:\\windows\\desktop") import test # a Jython script on my desktop All is well. So, give this a try: sys.path.append("c:\\program files\\jython\\Lib") # only one dir # or sys.path.extend( ("c:\\program files\\jython", "c:\\program files\\jython\\Lib") ) > print "python.home: ",java.lang.System.getProperty("python.home") > print "python.path: ",java.lang.System.getProperty("python.path") > print "sys.path: ",sys.path > print "sys.prefix: ",sys.prefix > > # Import support for strings > import string > > # Get the value of the scalar node > value = scriptinterface.getNodeValue(".1.3.6.1...") > > # Convert value to INT > valueAsInt=string.atoi(value) > > # Add 1 to value > valueAsInt=valueAsInt+1 > > # Set a limit of 8 for value > if valueAsInt > 8: > valueAsInt=1 > > # Convert valueAsInt back to string > value=str(valueAsInt) > > # Write back (increased) value to node > scriptinterface.updateValue(".1.3.6.1...",value,"CONST") > # ----------- end ob script > > And this is how the log-file looks right after executing the script: > <snip> > .. > python.home: None > python.path: None > sys.path: ['.\\jars\\Lib', 'c:\\program files\\jython;c:\\program > files\\jython\\lib'] > sys.prefix: .\jars\ > Traceback (innermost last): > File > "D:\AdventNet\simulator\mibs\_behavior_scripts_\counter_with_import.py", > line 14, in ? > ImportError: no module named string > Exception while executing the Python Script > > 'python.home' is not set, therefore 'registry' could not be read and > 'python.path' isn't set accurately, right? yes, but these are not required. The right path in sys.path is the goal, these properties help the initialization step meet that goal. > 'sys.path' is correct Maybe not. > - the > '.\\jars\\Lib' is the path leading to the jars containing all the > class-files of the AgentSimulator. The module 'string.py' actually is > present at 'c:\program files\jython\lib'. Doesn't it indicate the path to > the modules is missing? Does jython use sys.path as well as python.path? Properties, like python.path, python.home and etcettera, are all about initializing Jython. Java code takes steps to set Jython's system state before actually creating the interpreter instance, and these property values are what is used in these steps. The main step is PythonInterpreter.initialize(), but remember that this method should be called before instantiating an interpreter. After instantiation, Jython's sys module as the final word. python.path is added to the sys.path during initialization. Following that, what is in sys.path is the final word. > > >>> import sys > > >>> sys.path.append("\\the\\required\\directory") > > > > instead of: > >> props = Properties() > >> props.setProperty("python.path", "c:\Program Files\Jython;c:\Program > >> Files\Jython\lib") > >> PythonInterpreter.initialize(System.getProperties(), props, "") > > Hmmm ... because this will delete the old path that I may need further!? It's more because initialize is a bit out of place within Jython. Initialize should only be called one time- preceeding interpreter instantiations. This means called from Java. > PythonInterpreter.initialize in fact is present. Just look at the example > below. 'inizialize' is a typo. It actually _is_ 'initialize'. Sorry. The > disatvantage is that we don't know which changes the programers from > AdventNet made. They probably didn't change anything. I was just looking for an easy explaination :) Cheers, Robert |
From: Anthony E. <ae...@si...> - 2001-07-25 16:58:24
|
Greetings, First let me say that I have found Jython to be extremely useful and I have included it in the majority of my applications (as the preferred scripting language through IBM's Bean Scripting Framework.) The authors have done a really good job. I am seeing some strange behavior in Jython 2.0 where some JARs are not loaded or cached. The classes within these JARs are therefore not accessible. These JARs can be found in the class path, and other JARs within the same application appear without any problems. Could this have anything to do with some classes being marked as final or having a private constructor? If so why would it cause the whole JAR to not be loaded? Thanks for any thoughts. Sincerely, Anthony Eden |
From: Joern E. <Joe...@mi...> - 2001-07-25 13:32:17
|
Hi all, hi Robert <snip> >>> [Robert] >>> 1. is python.home set so that it actually finds and reads the registry? >> >> [Joern] >> >> I don't know. How do I find out? The whole Jython-related code is "hidden" >> within a jar-file. No chance to dip into it. > > >>> import java > >>> java.lang.System.getProperty("python.home") > > Also add... > > >>> import sys > >>> print sys.path, sys.prefix > > Knowing these three values is the best first step I've done so and now my script looks like this: # ----------- begin ob script import java java.lang.System.getProperty("python.home") java.lang.System.getProperty("python.path") import sys sys.path.append("c:\\program files\\jython;c:\\program files\\jython\\lib") print "python.home: ",java.lang.System.getProperty("python.home") print "python.path: ",java.lang.System.getProperty("python.path") print "sys.path: ",sys.path print "sys.prefix: ",sys.prefix # Import support for strings import string # Get the value of the scalar node value = scriptinterface.getNodeValue(".1.3.6.1...") # Convert value to INT valueAsInt=string.atoi(value) # Add 1 to value valueAsInt=valueAsInt+1 # Set a limit of 8 for value if valueAsInt > 8: valueAsInt=1 # Convert valueAsInt back to string value=str(valueAsInt) # Write back (increased) value to node scriptinterface.updateValue(".1.3.6.1...",value,"CONST") # ----------- end ob script And this is how the log-file looks right after executing the script: <snip> ... python.home: None python.path: None sys.path: ['.\\jars\\Lib', 'c:\\program files\\jython;c:\\program files\\jython\\lib'] sys.prefix: .\jars\ Traceback (innermost last): File "D:\AdventNet\simulator\mibs\_behavior_scripts_\counter_with_import.py", line 14, in ? ImportError: no module named string Exception while executing the Python Script 'python.home' is not set, therefore 'registry' could not be read and 'python.path' isn't set accurately, right? 'sys.path' is correct - the '.\\jars\\Lib' is the path leading to the jars containing all the class-files of the AgentSimulator. The module 'string.py' actually is present at 'c:\program files\jython\lib'. Doesn't it indicate the path to the modules is missing? Does jython use sys.path as well as python.path? > Is fpformat is the import error you originally saw? if so, it may be that > you need to copy that module from the CPython distribution into your > Jython Lib directory. Yes, the import error happens when I try to import fpformat, too, but 'fpformat.py' actually is present in the Jython lib directory 'c:\program files\jython\lib\'. I guess it's because of the missing 'python.path'. > <snip> >> # ---------- start of noneworking script >> from org.python.util import PythonInterpreter >> from java.util import Properties >> from java.lang import System > > re-initializing is probably the wrong way to go here. If you are running > something in Jython and need to import modules from a specific directory, > it is better to use: > > >>> import sys > >>> sys.path.append("\\the\\required\\directory") > > instead of: >> props = Properties() >> props.setProperty("python.path", "c:\Program Files\Jython;c:\Program >> Files\Jython\lib") >> PythonInterpreter.initialize(System.getProperties(), props, "") Hmmm ... because this will delete the old path that I may need further!? > Also make sure that the module does in fact live in one of the directories > in sys.path. > > Side note: The 3rd arg to initialize should be [""] - it needs to convert > to a String[] rather than just a String. However, the error message > indicates other problems... > >> # Import support for strings >> import string >> >> # Get the value of the scalar node >> value = scriptinterface.getNodeValue(".1.3.6.1...") >> >> # Convert value to INT >> valueAsInt=string.atoi(value) >> >> # Add 1 to value >> valueAsInt=valueAsInt+1 >> >> # Set limit for value to 256. If reached reset value to 1. >> if valueAsInt > 256: >> valueAsInt=1 >> >> # Convert valueAsInt back to string >> value=str(valueAsInt) >> >> # Write back (increased) value to node >> scriptinterface.updateValue(".1.3.6.1...",value,"CONST") >> # ---------- end of noneworking script > > This script could be written as: > > value = int( scriptinterface.getNodeValue(".1.3.6.1...") ) > value = value > 255 and "1" or str(value + 1) > scriptinterface.updateValue(".1.3.6.1...",value,"CONST") > > read the second line as: if value + 1 > 256, return "1" for the > expression, else return value + 1 as a string. I know the script could be coded more compact but it's example-code for my colleagues so I left it more detailed for them. >> The scripts were executed by the AgentSimulator at runtime whereat the >> condition the script will be started can be chosen freely (requestBased, >> timerBased, thresholdBased). How, why and were the script will be started >> can't be seen at all - the whole jython-stuff is "hidden" in a jar. The >> AgentSimulators' logfile contains this after executing the (noneworking) >> script: >> >> Traceback (innermost last): >> File "D:\AdventNet\simulator\mibs\_behavior_scripts_\counter.py", line 7, >> in ? >> AttributeError: class 'org.python.util.PythonInterpreter' has no attribute >> 'initialize' >> Exception while executing the Python Script > > My guess is that the error message above indicates initialize has been > modified/renamed. No matter, I don't think it is what you are after > anyway. > >> I'm wondering how this can happen, because using System.getProperties() is >> absolutely similar to using PythonInterpreter.initialize() or am I wrong >> somehow? > > Initialize is all about establishing system state information from system > properties, registry properties and the new properties specified in the > 2nd arg. So it is not really like getProperties. If jython is already > running, however, intialize is trying to re-initialize things, which > isn't really effective. > >> And 'initialize' isn't an attribute but a method. > > In the Python world, anything in a class is an attribute. The error > message you see is a Jython error- not a Java error, so it is the correct > error message to report only if "initialize" truly does not exist in your > PythonInterpreter class. Check dir(PythonInterpreter) a few times to see > if "initialize" is really there, or if it has been modified. Note that > this is only to explain the error, I still don't think you want initialize > for your situation :) PythonInterpreter.initialize in fact is present. Just look at the example below. 'inizialize' is a typo. It actually _is_ 'initialize'. Sorry. The disatvantage is that we don't know which changes the programers from AdventNet made. >> From my point of >> view this should work fine, but as you can see it doesn't. It looks like >> the path to the libs can't be found as before. I've set the correct path >> within the file 'registry'. Using a DOS-Box behaves the same way: >> >> (Inside the DOS-Box, again.) >> C:\>jython >> Jython 2.0 on java1.3.0 (JIT: null) >> Type "copyrigth", ... etc. >> >>> from org.python.util import PythonInterpreter >> >>> PythonInterpreter.initialize("old", "new", "") >> Traceback (innermost last): >> File "<console>", line 1, in ? >> AttributeError: class 'org.python.util.PythonInterpreter' has no attribute >> 'initialize' >> >>> dir(PythonInterpreter) >> ['err', 'eval', 'exec', 'execfile', 'get', 'getLocale', 'inizialize', >> 'locals', 'out', 'set', 'setErr', 'setLocals', 'setOut'] > > Is 'inizialize' a typo in the mail, or does the dir really and truly > report 'inizialize'. If it really and truly says 'inizialize', your > results make more sense. > > <snip> >> May jython has to be started with the -D option? > > "has to"? - no. You may use the -D option to start java applications that > embed Jython. This allows the setting of properties from the command-line. > Look at the jython.bat file for example. If your embedded Jython > application that is giving you trouble implements initialize like > org.python.util.jython does, you may be able to force certain > properties with -D. For example: > > java -cp \path\to\jython.jar -Dpython.hom="c:\my\Jython\home\dir" \ > -Dpython.path="c:\some\dir" org.python.util.jython > > This starts Jython with a specific python.home and python.path. Other > Java apps that embed Jython and use the > PythonInterpreter.initialize(System.getProperties(), props, new String[0]) > should also make use of the -D options (unless they specifically override > these options in the props values internally). My thought was that the > application you are working with could merely be started with a > -Dpython.path="\\some\\path" to add the path you desired to sys.path. But > I misunderstood the situation. <snip> > Cheers, > Robert Bye Joern |
From: <bc...@wo...> - 2001-07-25 10:11:14
|
Moved to jython-users. [Mark] >I am teaching a simple introductory course on programming. I am using >Python and am interested in introducing at the end for interest sake the >ability to create simple little programs running inside a browser. > >I am a bit clueless about Java. > >I have CLASSPATH set to: > >[mt@galois applet]$ plecho $CLASSPATH >/home/mt/external/jython-2.1a1/jython.jar >. >./jpywork >/home/mt/external/jython-2.1a1/Tools/jythonc >/home/mt/external/jython-2.1a1 >/home/mt/external/jython-2.1a1/Lib These last three entries isn't necessary. >I have the following HelloWorld.py file: > >from java.applet import Applet > >class HelloWorld(Applet): > def paint(self, g): > g.drawString("Hello from Jython!", 20, 30) > >Running jythonc -J deprecation HelloWorld.py >produces a class file with 9 deprecated API warnings. > >I have the following html file: > ><html> ><body> ><center> ><applet code="HelloWorld.class" > width = 500 > height = 105> ></applet> ></center> ></body> ></html> > >The environment that netscape has does contain the same CLASSPATH >variable (this is required right?). Not sure. It is certainly different from the setup used on the applet demo pages: http://www.jython.org/applets. There we make a .jar file that contains all the needed files including the core python files. As a result no CLASSPATH setup is required but the html must then include a line like: ARCHIVE="helloworld.jar". >Here is the java console output: > ># Applet exception: exception: java.lang.NullPointerException: trying to call makeJavaPackage(Ljava/lang/String;Ljava/lang/Str >java.lang.NullPointerException: trying to call makeJavaPackage(Ljava/lang/String;Ljava/lang/Str > at org.python.core.PySystemState.add_package(PySystemState.java:504) > at org.python.core.Py.initProperties(Py.java:701) > at org.python.core.Py.initProxy(Py.java:719) >... > >What the hell does this mean???? Not sure. This is the first time I have seen this message. I'm guesing the stacktrace is a bit bogus. Applets are wellknown for reporting errors that does not reflect the real problem ... >I am using Jython 2.1a1 and JDK (from Sun) 1.3.1 ... and I believe 1.3.1 is the real problem. Even if it isn't, I strongly doubt you can make java1 applets with a java2 JVM. You will need to get hold of and install a JDK1.1 and use that when running jythonc. >For interest sake here are the warning from jythonc: These warnings are not important. We could make them to away but the alternatives does not run as fast. >Anybody have a clue as to what I am doing wrong? I have tried copying >the HelloWorld.class all sorts of different places. I have tried >calling the .class file in the html file different names like HelloWorld >or jpywork/HelloWorld.class jpywork.HelloWorld - pretty much every >conceivable combo. > >This applet is working for me at http://www.jython.org/applets the Then I suggest you try to reproduce the way I built the applet demoes. See the "Example" section on http://www.jython.org/docs/jythonc.html >source of the html there is exactly what I have. Not quite, the tag used on the applet demo pages look like this: <APPLET CODE="HelloWorld" WIDTH="160" HEIGHT="50" ARCHIVE="appletdemo.jar" NAME="HelloWorld" ALIGN="BOTTOM" alt="This browser doesn't support JDK 1.1 applets."> <PARAM NAME="cabbase0" VALUE="appletdemo.cab"> <H3>Something has gone wrong loading this applet.</H3> </APPLET> You need the ARCHIVE attribute for netscape (atleast for the windows version) and the <PARAM NAME="cabbase0" ..> tag is needed for older IE browsers. Newer version of IE uses the ARCHIVE attribute instead. regards, finn |
From: <bc...@wo...> - 2001-07-25 09:22:21
|
[syKim] >hello. > >I'm trying applet program.. > >my applet program use inner class extending & method overriding > >sample code : >... >------------------------------------------------------------------ > >but, in 2.0 it's not work. (It doesn't make xxx$HTMLFactory) > >then i try jython 2.1a2, although it makes xxx$HTMLFactory but it occur >error > >then i test simply applet, it occur same error in every applet program. > >the error message is : > >------------------------------------------------------------------- > >Java Traceback: >... >java.lang.NoClassDefFoundError: org/python/util/PyMetaClass > at org.python.core.Py.makeClass(Py.java) > >------------------------------------------------------------------- > >i'm using jdk1.3.1 & jython 2.1a2 & windows 98 (i tested under windows2000) > >it works well just using <jython excutionfilename> > >but in case jythonc it's not work. It is an unfortunate bug that wasn't detected during our last testing. A workaround is to edit the main.py file and add a single line. See here for details: http://www.jython.org/cgi-bin/moin.cgi/PyMetaClassBug The CVS already contain a fix. regards, finn |
From: Robert W. B. <rb...@di...> - 2001-07-24 17:32:32
|
Hello Joern, On Tue, 24 Jul 2001, Joern Eckhoff wrote: > > [Robert] > > Hello Joern, > > > > I only had two seconds free, but appended some ideas in case they > > help. Sorry for any gaps due to my rush. > > >>>> [Joern] > >>>> > >>>> While working in a DOS-Box import works really fine. But writing > >>>> a script which imports the same pakages throws an exception. > > >>> [finn] > >>> > >>> It sounds like a embedding problem. Try to check the value of sys.path > >>> at the beginning of your script. > >>> > >>> If you are doing the embedding take a look at this FAQ answer for how > >>> to set up a usefull python.path. > >>> > >>> http://www.jython.org/cgi-bin/faqw.py?req=show&file=faq06.002.htp > >>> > >>> Otherwise you can always add entries to sys.path from within your > >>> script. > > [Robert] > > 1. is python.home set so that it actually finds and reads the registry? > > [Joern] > > I don't know. How do I find out? The whole Jython-related code is "hidden" > within a jar-file. No chance to dip into it. >>> import java >>> java.lang.System.getProperty("python.home") Also add... >>> import sys >>> print sys.path, sys.prefix Knowing these three values is the best first step Is fpformat is the import error you originally saw? if so, it may be that you need to copy that module from the CPython distribution into your Jython Lib directory. <snip> > # ---------- start of noneworking script > from org.python.util import PythonInterpreter > from java.util import Properties > from java.lang import System re-initializing is probably the wrong way to go here. If you are running something in Jython and need to import modules from a specific directory, it is better to use: >>> import sys >>> sys.path.append("\\the\\required\\directory") instead of: > props = Properties() > props.setProperty("python.path", "c:\Program Files\Jython;c:\Program > Files\Jython\lib") > PythonInterpreter.initialize(System.getProperties(), props, "") Also make sure that the module does in fact live in one of the directories in sys.path. Side note: The 3rd arg to initialize should be [""] - it needs to convert to a String[] rather than just a String. However, the error message indicates other problems... > # Import support for strings > import string > > # Get the value of the scalar node > value = scriptinterface.getNodeValue(".1.3.6.1.4.1.781.5.8.1.1.1") > > # Convert value to INT > valueAsInt=string.atoi(value) > > # Add 1 to value > valueAsInt=valueAsInt+1 > > # Set limit for value to 256. If reached reset value to 1. > if valueAsInt > 256: > valueAsInt=1 > > # Convert valueAsInt back to string > value=str(valueAsInt) > > # Write back (increased) value to node > scriptinterface.updateValue(".1.3.6.1.4.1.781.5.8.1.1.1",value,"CONST") > # ---------- end of noneworking script This script could be written as: value = int( scriptinterface.getNodeValue(".1.3.6.1.4.1.781.5.8.1.1.1") ) value = value > 255 and "1" or str(value + 1) scriptinterface.updateValue(".1.3.6.1.4.1.781.5.8.1.1.1",value,"CONST") read the second line as: if value + 1 > 256, return "1" for the expression, else return value + 1 as a string. > The scripts were executed by the AgentSimulator at runtime whereat the > condition the script will be started can be chosen freely (requestBased, > timerBased, thresholdBased). How, why and were the script will be started > can't be seen at all - the whole jython-stuff is "hidden" in a jar. The > AgentSimulators' logfile contains this after executing the (noneworking) > script: > > Traceback (innermost last): > File "D:\AdventNet\simulator\mibs\_behavior_scripts_\counter.py", line 7, > in ? > AttributeError: class 'org.python.util.PythonInterpreter' has no attribute > 'initialize' > Exception while executing the Python Script My guess is that the error message above indicates initialize has been modified/renamed. No matter, I don't think it is what you are after anyway. > I'm wondering how this can happen, because using System.getProperties() is > absolutely similar to using PythonInterpreter.initialize() or am I wrong > somehow? Initialize is all about establishing system state information from system properties, registry properties and the new properties specified in the 2nd arg. So it is not really like getProperties. If jython is already running, however, intialize is trying to re-initialize things, which isn't really effective. > And 'initialize' isn't an attribute but a method. In the Python world, anything in a class is an attribute. The error message you see is a Jython error- not a Java error, so it is the correct error message to report only if "initialize" truly does not exist in your PythonInterpreter class. Check dir(PythonInterpreter) a few times to see if "initialize" is really there, or if it has been modified. Note that this is only to explain the error, I still don't think you want initialize for your situation :) > From my point of > view this should work fine, but as you can see it doesn't. It looks like > the path to the libs can't be found as before. I've set the correct path > within the file 'registry'. Using a DOS-Box behaves the same way: > > (Inside the DOS-Box, again.) > C:\>jython > Jython 2.0 on java1.3.0 (JIT: null) > Type "copyrigth", ... etc. > >>> from org.python.util import PythonInterpreter > >>> PythonInterpreter.initialize("old", "new", "") > Traceback (innermost last): > File "<console>", line 1, in ? > AttributeError: class 'org.python.util.PythonInterpreter' has no attribute > 'initialize' > >>> dir(PythonInterpreter) > ['err', 'eval', 'exec', 'execfile', 'get', 'getLocale', 'inizialize', > 'locals', 'out', 'set', 'setErr', 'setLocals', 'setOut'] Is 'inizialize' a typo in the mail, or does the dir really and truly report 'inizialize'. If it really and truly says 'inizialize', your results make more sense. <snip> > May jython has to be started with the -D option? "has to"? - no. You may use the -D option to start java applications that embed Jython. This allows the setting of properties from the command-line. Look at the jython.bat file for example. If your embedded Jython application that is giving you trouble implements initialize like org.python.util.jython does, you may be able to force certain properties with -D. For example: java -cp \path\to\jython.jar -Dpython.hom="c:\my\Jython\home\dir" \ -Dpython.path="c:\some\dir" org.python.util.jython This starts Jython with a specific python.home and python.path. Other Java apps that embed Jython and use the PythonInterpreter.initialize(System.getProperties(), props, new String[0]) should also make use of the -D options (unless they specifically override these options in the props values internally). My thought was that the application you are working with could merely be started with a -Dpython.path="\\some\\path" to add the path you desired to sys.path. But I misunderstood the situation. > .. *truncateMUCH* ... Ok, gimme a minute to figure out ... > > (Starting DOS-Box.) > C:\>jython > Jython 2.0 on java1.3.0 (JIT: null) > Type "copyrigth", ... etc. > >>> from org.python.util import PythonInterpreter > >>> inter = PythonInterpreter > >>> inter.initialize("old", "new", "") > Traceback (innermost last): > File "<console>", line 1, in ? > TypeError: initialize(): 1st arg can't be coerced to java.util.Properties > >>> _ > > .. this! Erm, bingo?! Let me have a looong and close look to that and > await my report on this topic soon. There's nothing wrong with using an interpreter object from within Jython, but the initialize is suspect, and again, probably not what you really wanted. > And last but not least a hopingly simple question. Why are so much people > using two single quotes instead of a quotation mark (like ''this'') or > different quotes (like `this') instead of two identical ones to distinguish > some kind of text (e.g. strings)? I'm wondering every time I see it. I'm not sure why others do. I use ` and ' because they look nice like smart quotes, and use ''this'' because of habitual avoidance of embedded double-quotes in Java strings. Cheers, Robert |
From: dman <ds...@ri...> - 2001-07-24 15:55:51
|
On Tue, Jul 24, 2001 at 04:37:56PM +0200, Joern Eckhoff wrote: | May it was mistakable. WinNT does not allow a filename .jython, because the | file*name* is missing. You can create filenames without an extension but | filenames without file*names* aren't possible, therefore ".jython" isn't a | valid | filename for WinNT. WinNT separates name and extension with a dot. But whom | I'm telling this? :-) | (Or may I *totally* misunderstood you.) Actually, you can create "dotfiles" (files where the first character of the name is a dot) in WinNT and Win2k. I have lots of them on my machine at work. The problem must be your method of creating it. I use cygwin (g)vim heavily. They have no problems creating, editing, reading dotfiles at all. Maybe you could try using a little python to create the .jython file then use your favorite editor to edit it? FYI, -D |
From: Joern E. <Joe...@mi...> - 2001-07-24 14:40:11
|
> [Robert] > > Hello Joern, > > I only had two seconds free, but appended some ideas in case they > help. Sorry for any gaps due to my rush. >>>> [Joern] >>>> >>>> While working in a DOS-Box import works really fine. But writing >>>> a script which imports the same pakages throws an exception. >>> [finn] >>> >>> It sounds like a embedding problem. Try to check the value of sys.path >>> at the beginning of your script. >>> >>> If you are doing the embedding take a look at this FAQ answer for how >>> to set up a usefull python.path. >>> >>> http://www.jython.org/cgi-bin/faqw.py?req=show&file=faq06.002.htp >>> >>> Otherwise you can always add entries to sys.path from within your >>> script. >> [Joern] >> >> Hi again, >> >> thanks, finn, for the hint, but ... it doesn't work yet. I've read the site >> you've quoted above and the according site at jython.com. I've tried to >> find the registry file, but wasn't able to do so. Actually it isn't >> neccessary at all, right? I'm working on WinNT and a name .jython for a >> file isn't allowed (Message: You must type a filename). > [Robert] > > Not to worry- Jython doesn't mind (on win98 at least): > > import java, os > filename = os.path.join(java.lang.System.getProperty("user.home"), > ".jython") > open(filename, "w") [Joern] May it was mistakable. WinNT does not allow a filename .jython, because the file*name* is missing. You can create filenames without an extension but filenames without file*names* aren't possible, therefore ".jython" isn't a valid filename for WinNT. WinNT separates name and extension with a dot. But whom I'm telling this? :-) (Or may I *totally* misunderstood you.) >> [Joern] >> >> So I suggest it's >> the file called registry at c:\program files\jython as stated in the docs >> of jython (It took half a day to find the hint for that. It's placed >> _very_ unfavourable). > [Robert] > > Yes, it is the "registry" file in Jython's installation directory or > .jython in your home directory. I added a FAQ entry in case that makes > this information easier to locate. If you get an opportunity to check its > accuracy, and more importantly, its helpfulness, your feedback would be > appreciated. >> [Joern] >> >> Even after adding an own line specifying the path >> matching my system it doesn't work. This is what I've added to >> c:\program files\jython\registry: >> >> # this is how to specify the path at my computer. Joern >> python.path=c:\\program files\\jython;c:\\program files\\jython\\lib >> >> >> After that and adding the code to set the python.path within the script, >> too, I've started the AdventNet SimulationToolkit again. This message was >> written to the log-file of the SimulationToolkit: >> >> Traceback (innermost last): >> (no code object) at line 0 >> File "D:\AdventNet\simulator\mibs\_behavior_scripts_\script.py", line 1 >> Properties props = new Properties(); >> ^ >> SyntaxError: invalid syntax >> Exception while executing the Python Script >> >> >> But ... erm ... the registry-file is updated, so why can't I remove the >> code specifying the path in the script? Well, after removing the code the >> path could not be found, therefore string could not be imported. >> >> >> Environmet is set: >> PYTHONPATH=c:\program files\jython;c:\program files\jython\lib >> >> .. Path within script is set: >> Properties props = new Properties(); >> props.setProperty("python.path", "c:\Program Files\Jython;c:\Program >> Files\Jython\lib"); >> PythonInterpreter.initialize(System.getProperties(), props, new String[] >> {""}); >> >> .. and line to file registry has been added: >> # this is how to specify the path at my computer. Joern >> python.path=c:\\program files\\jython;c:\\program files\\jython\\lib >> >> >> So, what to do next, IOW: What am I doing wrong? It seems to me that the >> Properties could not be found, i.e. jython could not resolve the line >> Properties props = new Properties() - but how? > [Robert] > > I'm unsure of the problem, but thought it was worth checking the > python.home property. The reason this comes up is because your path > includes the "Lib" directory, but if python.home is set correctly this > "Lib" directory should automatically be in the path. It doesn't hurt > anything, it just made me wonder if python.home is set. > > 1. is python.home set so that it actually finds and reads the registry? [Joern] I don't know. How do I find out? The whole Jython-related code is "hidden" within a jar-file. No chance to dip into it. > [Robert] > > 2. should the property value be "c:\\Program Files\\Jython;c:\\Program > Files\\jython\\lib" # My frustration of escape char=path sep means > I've never actually tried single back-slashes to know. > > 3. does this application that jython is embedded in have special class > loaders? If so, do you need to add packages/classes with > sys.add_package(packagename) or sys.add_classdir(directory) or > sys.add_extdir(directoryOfJarsAndZips)? [Joern] As said under 1. - don't know. > 4. If nothing helps, can we see the code? Your snippets and > descriptions are clear, but I always waste too much time guessing about > what I'm not seeing. Seeing the offending class, plus the command-line you > use to run this class, would be easier. [Joern] Of course. See the end of this e-mil - code as far as you can look. > [Robert] > > Keep us posted on the progress. If it's a lack-of-progress, don't worry- > just post the class, and more ideas will come. [Joern] The problem is much to straightforward, so I don't work with classes. It's only a very small and simple jython-script - nothing complex or difficult. > Cheers, > Robert [Joern] Hi all. Thanks a lot, Robert. The import doesn't work at all yet, but my script (to be more exact: one of my scripts) does what it should do. This is the idea: I'm simulating agents using the AdventNet AgentSimulator v1. The AgentSimulator now supports agents' behavior. You can read and write a nodes' value by using jython-scripts. Here my example for a counter: # ---------- start of working script # Get the value of the scalar node (nodes' OID shortened) value = scriptinterface.getNodeValue(".1.3.6.1...") # Convert value to INT by "misusing" eval() valueAsInt=eval(value) # Add 1 to value valueAsInt=valueAsInt+1 # Set limit for value to 256. If reached reset value to 1. if valueAsInt > 256: valueAsInt=1 # Convert valueAsInt back to string value=str(valueAsInt) # Write (increased) value to node (nodes' OID shortened) scriptinterface.updateValue(".1.3.6.1...",value,"CONST") # ---------- end of working script My first idea was to use the function string.atoi() to convert the value from string to int. After browsing through the reference and tutorial I've found eval() and thought "Hey, why do I have to use eval for calculation?". So I've tried to "eval" the string '1' and ... fortunately (and surprisingly) it works. This is the history of the (working) script as shown above. But I've the foreboding that I have to use import, too, to implement more difficult behavior and therefore I'm trying to figure out how it works *with* imports. Here we are: # ---------- start of noneworking script from org.python.util import PythonInterpreter from java.util import Properties from java.lang import System props = Properties() props.setProperty("python.path", "c:\Program Files\Jython;c:\Program Files\Jython\lib") PythonInterpreter.initialize(System.getProperties(), props, "") # Import support for strings import string # Get the value of the scalar node value = scriptinterface.getNodeValue(".1.3.6.1.4.1.781.5.8.1.1.1") # Convert value to INT valueAsInt=string.atoi(value) # Add 1 to value valueAsInt=valueAsInt+1 # Set limit for value to 256. If reached reset value to 1. if valueAsInt > 256: valueAsInt=1 # Convert valueAsInt back to string value=str(valueAsInt) # Write back (increased) value to node scriptinterface.updateValue(".1.3.6.1.4.1.781.5.8.1.1.1",value,"CONST") # ---------- end of noneworking script The scripts were executed by the AgentSimulator at runtime whereat the condition the script will be started can be chosen freely (requestBased, timerBased, thresholdBased). How, why and were the script will be started can't be seen at all - the whole jython-stuff is "hidden" in a jar. The AgentSimulators' logfile contains this after executing the (noneworking) script: Traceback (innermost last): File "D:\AdventNet\simulator\mibs\_behavior_scripts_\counter.py", line 7, in ? AttributeError: class 'org.python.util.PythonInterpreter' has no attribute 'initialize' Exception while executing the Python Script I'm wondering how this can happen, because using System.getProperties() is absolutely similar to using PythonInterpreter.initialize() or am I wrong somehow? And 'initialize' isn't an attribute but a method. From my point of view this should work fine, but as you can see it doesn't. It looks like the path to the libs can't be found as before. I've set the correct path within the file 'registry'. Using a DOS-Box behaves the same way: (Inside the DOS-Box, again.) C:\>jython Jython 2.0 on java1.3.0 (JIT: null) Type "copyrigth", ... etc. >>> from org.python.util import PythonInterpreter >>> PythonInterpreter.initialize("old", "new", "") Traceback (innermost last): File "<console>", line 1, in ? AttributeError: class 'org.python.util.PythonInterpreter' has no attribute 'initialize' >>> dir(PythonInterpreter) ['err', 'eval', 'exec', 'execfile', 'get', 'getLocale', 'inizialize', 'locals', 'out', 'set', 'setErr', 'setLocals', 'setOut'] >>> dir(PythonInterpreter.initialize.__doc__) [] >>> {CTRL}+{C} C:\>_ May jython has to be started with the -D option? ... *truncateMUCH* ... Ok, gimme a minute to figure out ... (Starting DOS-Box.) C:\>jython Jython 2.0 on java1.3.0 (JIT: null) Type "copyrigth", ... etc. >>> from org.python.util import PythonInterpreter >>> inter = PythonInterpreter >>> inter.initialize("old", "new", "") Traceback (innermost last): File "<console>", line 1, in ? TypeError: initialize(): 1st arg can't be coerced to java.util.Properties >>> _ ... this! Erm, bingo?! Let me have a looong and close look to that and await my report on this topic soon. And last but not least a hopingly simple question. Why are so much people using two single quotes instead of a quotation mark (like ''this'') or different quotes (like `this') instead of two identical ones to distinguish some kind of text (e.g. strings)? I'm wondering every time I see it. TIA "Terrifying newbie using python/jython" Joern. :-) |
From: Charles C. <cc...@ps...> - 2001-07-24 14:24:15
|
> You might check the java faq at www.afu.com, particularly section 8, #17 (RE:trapping ctrl-C in java). Charlie > Is there some way to provide signal handling capability from > Jython? (in particular for Solaris) |
From: syKim <re...@ne...> - 2001-07-24 05:36:18
|
hello. I'm trying applet program.. my applet program use inner class extending & method overriding sample code : --------------------------------------------------------------- class TestEditorKit(HTMLEditorKit): def getViewFactory(self): return self.TestFactory() class TestFactory(HTMLEditorKit.HTMLFactory): def create(self,e): o = e.getAttributes().getAttribute(StyleConstants.NameAttribute) if o == HTML.Tag.INPUT: return html_event.TestFormView(e) return HTMLEditorKit.HTMLFactory.create(self,e) class TestFormView(FormView): def __init__(self,e): FormView.__init__(self,e) def test(self): print 'hello' def actionPerformed(self,e): self.test() ------------------------------------------------------------------ but, in 2.0 it's not work. (It doesn't make xxx$HTMLFactory) then i try jython 2.1a2, although it makes xxx$HTMLFactory but it occur error then i test simply applet, it occur same error in every applet program. the error message is : ------------------------------------------------------------------- Java Traceback: at org.python.core.Py.JavaError(Py.java) at org.python.core.Py.JavaError(Py.java) at org.python.core.PyJavaClass.initialize(PyJavaClass.java) at org.python.core.PyJavaClass.lookupGivingClass(PyJavaClass.java) at org.python.core.PyClass.lookup(PyClass.java) at org.python.core.PyJavaClass.__findattr__(PyJavaClass.java) at org.python.core.PyObject.__getattr__(PyObject.java) at org.python.core.Py.initExc(Py.java) at org.python.core.Py.initClassExceptions(Py.java) at org.python.core.PySystemState.initialize(PySystemState.java) at org.python.core.Py.initProperties(Py.java) at org.python.core.Py.initProxy(Py.java) at html_event.__initProxy__(html_event.java:271) at html_event.<init>(html_event.java:249) at java.lang.Class.newInstance0(Native Method) at java.lang.Class.newInstance(Unknown Source) at sun.applet.AppletPanel.createApplet(Unknown Source) at sun.plugin.AppletViewer.createApplet(Unknown Source) at sun.applet.AppletPanel.runLoader(Unknown Source) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Traceback (innermost last): (no code object) at line 0 java.lang.NoClassDefFoundError: org/python/util/PyMetaClass at org.python.core.Py.makeClass(Py.java) at org.python.core.Py.makeClass(Py.java) at org.python.core.exceptions.buildClass(exceptions.java) at org.python.core.exceptions.classDictInit(exceptions.java) at java.lang.reflect.Method.invoke(Native Method) at org.python.core.PyJavaClass.initialize(PyJavaClass.java) at org.python.core.PyJavaClass.lookupGivingClass(PyJavaClass.java) at org.python.core.PyClass.lookup(PyClass.java) at org.python.core.PyJavaClass.__findattr__(PyJavaClass.java) at org.python.core.PyObject.__getattr__(PyObject.java) at org.python.core.Py.initExc(Py.java) at org.python.core.Py.initClassExceptions(Py.java) at org.python.core.PySystemState.initialize(PySystemState.java) at org.python.core.Py.initProperties(Py.java) at org.python.core.Py.initProxy(Py.java) at html_event.__initProxy__(html_event.java:271) at html_event.<init>(html_event.java:249) at java.lang.Class.newInstance0(Native Method) at java.lang.Class.newInstance(Unknown Source) at sun.applet.AppletPanel.createApplet(Unknown Source) at sun.plugin.AppletViewer.createApplet(Unknown Source) at sun.applet.AppletPanel.runLoader(Unknown Source) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: org/python/util/PyMetaClass at org.python.core.Py.JavaError(Py.java) at org.python.core.Py.JavaError(Py.java) at org.python.core.PyJavaClass.initialize(PyJavaClass.java) at org.python.core.PyJavaClass.lookupGivingClass(PyJavaClass.java) at org.python.core.PyClass.lookup(PyClass.java) at org.python.core.PyJavaClass.__findattr__(PyJavaClass.java) at org.python.core.PyObject.__getattr__(PyObject.java) at org.python.core.Py.initExc(Py.java) at org.python.core.Py.initClassExceptions(Py.java) at org.python.core.PySystemState.initialize(PySystemState.java) at org.python.core.Py.initProperties(Py.java) at org.python.core.Py.initProxy(Py.java) at html_event.__initProxy__(html_event.java:271) at html_event.<init>(html_event.java:249) at java.lang.Class.newInstance0(Native Method) at java.lang.Class.newInstance(Unknown Source) at sun.applet.AppletPanel.createApplet(Unknown Source) at sun.plugin.AppletViewer.createApplet(Unknown Source) at sun.applet.AppletPanel.runLoader(Unknown Source) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) ------------------------------------------------------------------- i'm using jdk1.3.1 & jython 2.1a2 & windows 98 (i tested under windows2000) it works well just using <jython excutionfilename> but in case jythonc it's not work. my method is : jythonc -c -d -w . -j html_event.jar html_event.py thanks p.s : if you want my test source, i'll attatch it |
From: Jeff D. <js...@sy...> - 2001-07-24 03:48:32
|
Here is a difficult one for me as somone who has netiter implemented a signal handler in any language other than Perl and has never been exposed to JNI. Python provides the signal(signum, handler) method to set a handler for a particular signal. However, as java does not support signals in the core language, a "native method" must be used to implement signal handlers. Is there some way to provide signal handling capability from Jython? (in particular for Solaris) |
From: Ype K. <yk...@xs...> - 2001-07-23 18:31:43
|
Joern, I was going to remark that I could not import python files with upper case extension *.PY into 21a1 (see discussion on jython-dev) but then I saw a Javaism: <snip> > >After that and adding the code to set the python.path within the script, >too, I've started the AdventNet SimulationToolkit again. This message was >written to the log-file of the SimulationToolkit: > >Traceback (innermost last): > (no code object) at line 0 > File "D:\AdventNet\simulator\mibs\_behavior_scripts_\script.py", line 1 > Properties props = new Properties(); > ^ >SyntaxError: invalid syntax >Exception while executing the Python Script In python you cannot declare variables to be of a specific type. Also the new operator is not available, you simply call the class: import java props = java.util.Properties() or from java.util import Properties props = Properties() <snip> > >TIA for any help >Joern (At his wits end) It's fun at both ends, Ype |
From: dman <ds...@ri...> - 2001-07-23 14:53:25
|
On Mon, Jul 23, 2001 at 12:20:38PM +0200, Kevin McNamee wrote: | Thanks, your example was very useful. | | If I call MyThread().run() and I am not in the event-dispatching thread, | everything works fine. I can do long tasks and call invokeLater to update | the GUI with each result. | | If I call MyThread().run() when a button is pressed, then | isEventDispatchThread() returns true and the updater function is called | directly. This is because button events are handled in the | event-dispatching thread, but the result is that the GUI is not updated | until the button event finishes :( | | What I am doing wrong? You want to /start/, not /run/ MyThread from the button event handler. When you start() a thread it actually creates the new thread, then runs it. The run() method doesn't return until your long work is done, but start() returns immediately. HTH, -D |
From: Joern E. <Joe...@mi...> - 2001-07-23 12:45:07
|
> [Joern Eckhoff] > > >While working in a DOS-Box import works really fine. But writing a script > >which imports the same pakages throws an exception. > > It sounds like a embedding problem. Try to check the value of sys.path > at the beginning of your script. > > If you are doing the embedding take a look at this FAQ answer for how to > set up a usefull python.path. > > http://www.jython.org/cgi-bin/faqw.py?req=show&file=faq06.002.htp > > Otherwise you can always add entries to sys.path from within your > script. > > regards, > finn Hi again, thanks, finn, for the hint, but ... it doesn't work yet. I've read the site you've quoted above and the according site at jython.com. I've tried to find the registry file, but wasn't able to do so. Actually it isn't neccessary at all, right? I'm working on WinNT and a name .jython for a file isn't allowed (Message: You must type a filename). So I suggest it's the file called registry at c:\program files\jython as stated in the docs of jython (It took half a day to find the hint for that. It's placed _very_ unfavourable). Even after adding an own line specifying the path matching my system it doesn't work. This is what I've added to c:\program files\jython\registry: # this is how to specify the path at my computer. Joern python.path=c:\\program files\\jython;c:\\program files\\jython\\lib After that and adding the code to set the python.path within the script, too, I've started the AdventNet SimulationToolkit again. This message was written to the log-file of the SimulationToolkit: Traceback (innermost last): (no code object) at line 0 File "D:\AdventNet\simulator\mibs\_behavior_scripts_\script.py", line 1 Properties props = new Properties(); ^ SyntaxError: invalid syntax Exception while executing the Python Script But ... erm ... the registry-file is updated, so why can't I remove the code specifying the path in the script? Well, after removing the code the path could not be found, therefore string could not be imported. Environmet is set: PYTHONPATH=c:\program files\jython;c:\program files\jython\lib ... Path within script is set: Properties props = new Properties(); props.setProperty("python.path", "c:\Program Files\Jython;c:\Program Files\Jython\lib"); PythonInterpreter.initialize(System.getProperties(), props, new String[] {""}); ... and line to file registry has been added: # this is how to specify the path at my computer. Joern python.path=c:\\program files\\jython;c:\\program files\\jython\\lib So, what to do next, IOW: What am I doing wrong? It seems to me that the Properties could not be found, i.e. jython could not resolve the line Properties props = new Properties() - but how? TIA for any help Joern (At his wits end) |
From: Mark R. <blo...@ho...> - 2001-07-23 11:50:56
|
thanks alot, got it working now, not sure I am entirely sure how or why but it does ;). It turns out that what I thought was a Graphics object was a Graphics2D object already and I was making work for myself (as you so cunningly percieved) cheers blobby p.s. is it possible to reply from the mailing site webpage, cos have only seen an option to reply to the author? On Wed, Jul 18, 2001 at 05:48:34PM +0000, Mark Robinson wrote: | cheers, I had intended to send it to the list, but I just cocked it all up | ;) | | What I am actually trying to do is in order to gain some familiarity with | jython I am rewriting a java prog I have in a book in jython. In the java | example it was typed exactly as in my first example i.e. | | g2 = (Graphics2D)g Ok, In jython that would be spelled g2 = g | it seems to work in java...guess I will have to keep tinkering to work out | how jython wants to do it If Java didn't give you a ClassCastException then then Jython should work just fine with it. Try adding print g.__class__ to see what class (type) g really is, prior to trying to use a Graphics2D method on it. -D _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp |
From: Kevin M. <kev...@er...> - 2001-07-23 10:20:45
|
Thanks, your example was very useful. If I call MyThread().run() and I am not in the event-dispatching thread, everything works fine. I can do long tasks and call invokeLater to update the GUI with each result. If I call MyThread().run() when a button is pressed, then isEventDispatchThread() returns true and the updater function is called directly. This is because button events are handled in the event-dispatching thread, but the result is that the GUI is not updated until the button event finishes :( What I am doing wrong? /Kevin On Thu, 19 Jul 2001, D-Man wrote: > On Thu, Jul 19, 2001 at 03:57:38PM +0200, Kevin McNamee wrote: > | > | I am trying to use threads so that I can revalidate some panes while > | performing a series of long tasks, i.e. > | > | long task > | update & revalidate pane > | long task > | update & revalidate pane > | etc. > > Ok. You have this loop in a thread (some subclass of > java.lang.Thread). When you want to update the GUI you update it via > the SwingUtilities class. Ex : > > class MyThread( java.lang.Thread ) : > def run( self ) : > for ... : > ... > > # now update the GUI, create an java.lang.Runnable that > # does the work > class updater( java.lang.Runnable ) : > def run( self ) : > <update the gui here> > > if javax.swing.SwingUtilities.isEventDispatchThread() : > # we are already in the AWT_EventQueue thread, it is > # safe to touch the GUI > updater().run() > else : > # request that the updater be run in the > # AWT_EventQueue thread > javax.swing.SwingUtilities.invokeLater( updater() ) > > > > HTH, > -D > > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > http://lists.sourceforge.net/lists/listinfo/jython-users > _________________________________________________ Name/Title : Kevin McNamee, Software Consultant Phone : +46 13 32 1165 E-Mail : kev...@er... |
From: Charles C. <cc...@ps...> - 2001-07-20 22:58:31
|
Hi, i have an application which runs fine on Linux, and when i try to run it on win98 and win2k it always gives a java.lang.ClassFormatError when attempting to import org/postgresql/Driver, which is under the directory that i invoke the application from. I read on deja.com that it might be due to exceptionally large .class files, but the same dist of jdk (1.3) on Linux doesn't complain. I'd really appreciate some help on this one! Thanks, Charles Cosse |
From: Samuele P. <pe...@in...> - 2001-07-20 18:56:52
|
Hi. [D-Man] > > FYI, the backquotes call str() (or is it repr()? They are very similar > anyways). So the following is identical, but slightly more verbose : > FYI repr <wink> Samuele Pedroni. |
From: D-Man <ds...@ri...> - 2001-07-20 18:42:20
|
On Fri, Jul 20, 2001 at 06:31:37PM +0200, Joern Eckhoff wrote: | > Joern Eckhoff wrote: | > > | > > ... | > > Or any hint how to convert an INT to a | > > STRING without using this intricately solution? | > | > Why can't you just use the back-quotes?: | > | > >>> a=123 | > >>> print 'test' + `a` | > test123 | > >>> | > | > (the BACK-Quotes are below the tilde '~' on my keyboard). | | MY computer says: | | >>> a=123 | >>> print 'test'+'a' | testa | >>> _ | | :-( Yeah, with single quotes not backquotes :-). | ... *truncate* ... eeerm, one moment, please ... | | >>> a=123 | >>> print 'test'+`a` | test123 | >>> _ FYI, the backquotes call str() (or is it repr()? They are very similar anyways). So the following is identical, but slightly more verbose : >>> a=123 >>> print 'test' + str( a ) test123 >>> -D |
From: Joern E. <Joe...@mi...> - 2001-07-20 16:33:38
|
> Joern Eckhoff wrote: > > > > ... > > Or any hint how to convert an INT to a > > STRING without using this intricately solution? > > Why can't you just use the back-quotes?: > > >>> a=123 > >>> print 'test' + `a` > test123 > >>> > > (the BACK-Quotes are below the tilde '~' on my keyboard). > __o > Jim Adrig _ \<,_ MY computer says: >>> a=123 >>> print 'test'+'a' testa >>> _ :-( ... *truncate* ... eeerm, one moment, please ... >>> a=123 >>> print 'test'+`a` test123 >>> _ Bin-GO! Exactly that's what I wanted. Thank you very much - weekend's saved. But at my computer the back-quotes are above the ~ (1st left from backspace) and have to be used in this way: 1. press [shift] and hold it 2. press the quote one time (nothing happens) 3. press space (the backquote appears) Misterious, misterious, ... But the import doesn't work at all now. Next rescuer, please. :-) Yours sincerely, Joern |