From: Daniel L. <da...@br...> - 2001-05-07 17:48:34
|
I tried with both Jython 2.0 and Jython 2.1a1, and I get the following: Jython 2.1a1 on java1.3.0 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> import os >>> os.environ['path'] Traceback (innermost last): File "<console>", line 1, in ? KeyError: path Then just to check: >>> os.environ {} >>> Is it unimplemented or is my installation corrupt or incomplete? Here is how Python 2.1 that installed from source works: Python 2.1 (#1, 04/28/01, 16:09:19) [GCC Apple DevKit-based CPP 6.0alpha] on darwin1 Type "copyright", "credits" or "license" for more information. >>> import os >>> os.environ['PATH'] '~/bin/powerpc-apple-macos:/Users/daniello/bin:/usr/local/bin:/usr/bin:/bin: /usr/local/sbin:/usr/sbin:/sbin:.' >>> os.environ {'JAVA_HOME': '/Library/Java/Home', 'OSTYPE': 'macos', 'MANPATH': '~/man:/usr/local/share/man:/usr/share/man', 'DL_ENVIRONMENT_MINE_SET': '1', 'TERM_PROGRAM_VERSION': '41', '__CF_USER_TEXT_ENCODING': '0x1F5:0:0', 'PATH': '~/bin/powerpc-apple-macos:/Users/daniello/bin:/usr/local/bin:/usr/bin:/bin: /usr/local/sbin:/usr/sbin:/sbin:.', 'VENDOR': 'apple', 'SHLVL': '1', 'ANT_HOME': '/opt/ant', 'PWD': '/opt/jython/Doc', 'SHELL': '/bin/tcsh', 'TERM': 'vt100', 'TERMCAP': 'd0|vt100|vt100-am|vt100am|dec vt100:\t:do=^J:co#100:li#40:cl=\\E[;H\\E[2J:sf=2*\\ED:\t:le=^H:bs:am:cm=5\\E [%i%d;%dH:nd=2\\E[C:up=2\\E[A:\t:ce=3\\E[K:cd=50\\E[J:so=2\\E[7m:se=2\\E[m:u s=2\\E[4m:ue=2\\E[m:\t:md=2\\E[1m:mr=2\\E[7m:mb=2\\E[5m:me=2\\E[m:\t:rf=/usr /share/tabset/vt100:\t:rs=\\E>\\E[?3l\\E[?4l\\E[?5l\\E[?7h\\E[?8h\\E[;r\\E[0 m\\E(B\\E)B\\E[2J:\t:ks=\\E[?1h\\E=:ke=\\E[?1l\\E>:\t:ku=\\EOA:kd=\\EOB:kr=\ \EOC:kl=\\EOD:kb=^H:\t:ho=\\E[H:k1=\\EOP:k2=\\EOQ:k3=\\EOR:k4=\\EOS:pt:sr=2* \\EM:vt#3:xn:\t:sc=\\E7:rc=\\E8:cs=\\E[%i%d;%dr:', 'LANG': 'en_US', 'TERM_PROGRAM': 'Apple_Terminal', 'DL_RC_SET': '1', 'HOME': '/Users/daniello', 'USER': 'daniello', 'LOGNAME': 'daniello', 'HOST': 'localhost', 'DL_PATH_SET': '1', 'HOSTTYPE': 'macintosh', 'CLASSPATH': '/opt/xerces/xerces.jar:/opt/apachexml/bsf.jar:/opt/apachexml/bsfengines.jar :/opt/apachexml/smtp.jar:/opt/apachexml/pop3.jar:/opt/apachexml/xmisoap.jar: /opt/jdom/lib/collections.jar:/opt/saxon/saxon.jar:/opt/saxon/saxon-fop.jar' , 'ENV_SET': '', 'MACHTYPE': 'powerpc', 'GROUP': 'staff'} >>> My environment: Mac OS X 10.0.2 with 512 MB java version "1.3.0" Java(TM) 2 Runtime Environment, Standard Edition (build 1.3) Java HotSpot(TM) Client VM (build 1.3.0, mixed mode) |
From: brian z. <bz...@zi...> - 2001-05-07 18:40:57
|
It's not implemented in Jython because the JVM does not provide access to the environment. You'd have to write JNI code to get such a facility (I think Finn wrote such a module once). The closest you get is System.getProperties(), which is not really the same thing. brian At 10:47 AM 5/7/2001 -0700, Daniel Lord wrote: >I tried with both Jython 2.0 and Jython 2.1a1, and I get the following: > >Jython 2.1a1 on java1.3.0 (JIT: null) >Type "copyright", "credits" or "license" for more information. >>>> import os >>>> os.environ['path'] >Traceback (innermost last): > File "<console>", line 1, in ? >KeyError: path > >Then just to check: > >>>> os.environ >{} >>>> > >Is it unimplemented or is my installation corrupt or incomplete? > >Here is how Python 2.1 that installed from source works: >Python 2.1 (#1, 04/28/01, 16:09:19) >[GCC Apple DevKit-based CPP 6.0alpha] on darwin1 >Type "copyright", "credits" or "license" for more information. >>>> import os >>>> os.environ['PATH'] >'~/bin/powerpc-apple-macos:/Users/daniello/bin:/usr/local/bin:/usr/bin:/bin: >/usr/local/sbin:/usr/sbin:/sbin:.' >>>> os.environ >{'JAVA_HOME': '/Library/Java/Home', 'OSTYPE': 'macos', 'MANPATH': >'~/man:/usr/local/share/man:/usr/share/man', 'DL_ENVIRONMENT_MINE_SET': '1', >'TERM_PROGRAM_VERSION': '41', '__CF_USER_TEXT_ENCODING': '0x1F5:0:0', >'PATH': >'~/bin/powerpc-apple-macos:/Users/daniello/bin:/usr/local/bin:/usr/bin:/bin: >/usr/local/sbin:/usr/sbin:/sbin:.', 'VENDOR': 'apple', 'SHLVL': '1', >'ANT_HOME': '/opt/ant', 'PWD': '/opt/jython/Doc', 'SHELL': '/bin/tcsh', >'TERM': 'vt100', 'TERMCAP': 'd0|vt100|vt100-am|vt100am|dec >vt100:\t:do=^J:co#100:li#40:cl=\\E[;H\\E[2J:sf=2*\\ED:\t:le=^H:bs:am:cm=5\\E >[%i%d;%dH:nd=2\\E[C:up=2\\E[A:\t:ce=3\\E[K:cd=50\\E[J:so=2\\E[7m:se=2\\E[m:u >s=2\\E[4m:ue=2\\E[m:\t:md=2\\E[1m:mr=2\\E[7m:mb=2\\E[5m:me=2\\E[m:\t:rf=/usr >/share/tabset/vt100:\t:rs=\\E>\\E[?3l\\E[?4l\\E[?5l\\E[?7h\\E[?8h\\E[;r\\E[0 >m\\E(B\\E)B\\E[2J:\t:ks=\\E[?1h\\E=:ke=\\E[?1l\\E>:\t:ku=\\EOA:kd=\\EOB:kr=\ >\EOC:kl=\\EOD:kb=^H:\t:ho=\\E[H:k1=\\EOP:k2=\\EOQ:k3=\\EOR:k4=\\EOS:pt:sr=2* >\\EM:vt#3:xn:\t:sc=\\E7:rc=\\E8:cs=\\E[%i%d;%dr:', 'LANG': 'en_US', >'TERM_PROGRAM': 'Apple_Terminal', 'DL_RC_SET': '1', 'HOME': >'/Users/daniello', 'USER': 'daniello', 'LOGNAME': 'daniello', 'HOST': >'localhost', 'DL_PATH_SET': '1', 'HOSTTYPE': 'macintosh', 'CLASSPATH': >'/opt/xerces/xerces.jar:/opt/apachexml/bsf.jar:/opt/apachexml/bsfengines.jar >:/opt/apachexml/smtp.jar:/opt/apachexml/pop3.jar:/opt/apachexml/xmisoap.jar: >/opt/jdom/lib/collections.jar:/opt/saxon/saxon.jar:/opt/saxon/saxon-fop.jar' >, 'ENV_SET': '', 'MACHTYPE': 'powerpc', 'GROUP': 'staff'} >>>> > >My environment: > >Mac OS X 10.0.2 with 512 MB >java version "1.3.0" >Java(TM) 2 Runtime Environment, Standard Edition (build 1.3) >Java HotSpot(TM) Client VM (build 1.3.0, mixed mode) > > > >_______________________________________________ >Jython-users mailing list >Jyt...@li... >http://lists.sourceforge.net/lists/listinfo/jython-users |
From: John M. <joh...@ya...> - 2001-05-08 12:18:09
|
I've tried Finn's package under UNIX. I was impressed! The only mystery is why he doesn't promote it more. --- brian zimmer <bz...@zi...> wrote: > It's not implemented in Jython because the JVM does not provide > access to the environment. You'd have to write JNI code to get such > a facility (I think Finn wrote such a module once). The closest you > get is System.getProperties(), which is not really the same thing. > > brian > > At 10:47 AM 5/7/2001 -0700, Daniel Lord wrote: > >I tried with both Jython 2.0 and Jython 2.1a1, and I get the > following: > > > >Jython 2.1a1 on java1.3.0 (JIT: null) > >Type "copyright", "credits" or "license" for more information. > >>>> import os > >>>> os.environ['path'] > >Traceback (innermost last): > > File "<console>", line 1, in ? > >KeyError: path > > > >Then just to check: > > > >>>> os.environ > >{} > >>>> > > > >Is it unimplemented or is my installation corrupt or incomplete? > > > >Here is how Python 2.1 that installed from source works: > >Python 2.1 (#1, 04/28/01, 16:09:19) > >[GCC Apple DevKit-based CPP 6.0alpha] on darwin1 > >Type "copyright", "credits" or "license" for more information. > >>>> import os > >>>> os.environ['PATH'] > >'~/bin/powerpc-apple-macos:/Users/daniello/bin:/usr/local/bin:/usr/bin:/bin: > >/usr/local/sbin:/usr/sbin:/sbin:.' > >>>> os.environ > >{'JAVA_HOME': '/Library/Java/Home', 'OSTYPE': 'macos', 'MANPATH': > >'~/man:/usr/local/share/man:/usr/share/man', > 'DL_ENVIRONMENT_MINE_SET': '1', > >'TERM_PROGRAM_VERSION': '41', '__CF_USER_TEXT_ENCODING': > '0x1F5:0:0', > >'PATH': > >'~/bin/powerpc-apple-macos:/Users/daniello/bin:/usr/local/bin:/usr/bin:/bin: > >/usr/local/sbin:/usr/sbin:/sbin:.', 'VENDOR': 'apple', 'SHLVL': '1', > >'ANT_HOME': '/opt/ant', 'PWD': '/opt/jython/Doc', 'SHELL': > '/bin/tcsh', > >'TERM': 'vt100', 'TERMCAP': 'd0|vt100|vt100-am|vt100am|dec > >vt100:\t:do=^J:co#100:li#40:cl=\\E[;H\\E[2J:sf=2*\\ED:\t:le=^H:bs:am:cm=5\\E > >[%i%d;%dH:nd=2\\E[C:up=2\\E[A:\t:ce=3\\E[K:cd=50\\E[J:so=2\\E[7m:se=2\\E[m:u > >s=2\\E[4m:ue=2\\E[m:\t:md=2\\E[1m:mr=2\\E[7m:mb=2\\E[5m:me=2\\E[m:\t:rf=/usr > >/share/tabset/vt100:\t:rs=\\E>\\E[?3l\\E[?4l\\E[?5l\\E[?7h\\E[?8h\\E[;r\\E[0 > >m\\E(B\\E)B\\E[2J:\t:ks=\\E[?1h\\E=:ke=\\E[?1l\\E>:\t:ku=\\EOA:kd=\\EOB:kr=\ > >\EOC:kl=\\EOD:kb=^H:\t:ho=\\E[H:k1=\\EOP:k2=\\EOQ:k3=\\EOR:k4=\\EOS:pt:sr=2* > >\\EM:vt#3:xn:\t:sc=\\E7:rc=\\E8:cs=\\E[%i%d;%dr:', 'LANG': 'en_US', > >'TERM_PROGRAM': 'Apple_Terminal', 'DL_RC_SET': '1', 'HOME': > >'/Users/daniello', 'USER': 'daniello', 'LOGNAME': 'daniello', > 'HOST': > >'localhost', 'DL_PATH_SET': '1', 'HOSTTYPE': 'macintosh', > 'CLASSPATH': > >'/opt/xerces/xerces.jar:/opt/apachexml/bsf.jar:/opt/apachexml/bsfengines.jar > >:/opt/apachexml/smtp.jar:/opt/apachexml/pop3.jar:/opt/apachexml/xmisoap.jar: > >/opt/jdom/lib/collections.jar:/opt/saxon/saxon.jar:/opt/saxon/saxon-fop.jar' > >, 'ENV_SET': '', 'MACHTYPE': 'powerpc', 'GROUP': 'staff'} > >>>> > > > >My environment: > > > >Mac OS X 10.0.2 with 512 MB > >java version "1.3.0" > >Java(TM) 2 Runtime Environment, Standard Edition (build 1.3) > >Java HotSpot(TM) Client VM (build 1.3.0, mixed mode) > > > > > > > >_______________________________________________ > >Jython-users mailing list > >Jyt...@li... > >http://lists.sourceforge.net/lists/listinfo/jython-users > > > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > http://lists.sourceforge.net/lists/listinfo/jython-users __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ |
From: Adam B. <sir...@ya...> - 2001-05-08 18:11:18
|
Well, I've been playing with Jython a bit, and I still don't fully understand it. I'm even sad to say that I find the javadoc sadly lacking. I'm hoping, then, that some more knowledgable person can take pity on me and give me a hand. I'm going to describe what I want to do, in as much detail as I can think of, and I'm hoping someone can explain how to do it. I have a class written in Java with a few methods defined. I want the user of my program to be able to extend this class in Jython by writing a .py file with a known name. Then, when a certain event occurs in my program, I wish to load this class (including reloading it, if it has changed since the last time we used it), instantiate it, and call a method with a known name/signature (that is, one of the methods defined in the parent class). In addition, since there will be multiple python files floating around (that is, the user can define more than one class in python, although they all will extend the same java base class), I want to make sure there are no side effects; that is, I don't want definitions and such to hang around between calls to python classes. How should I even begin to do this? I don't know whether it is better to compile or interpret, in this case, even. Speed is actually a relatively important factor, which is a point for compiling, but only if there's a way to recompile and reload classes without restarting the VM (preferably a prettier way than the usual hack for doing this in java). On the other hand, while interpreting seems easier at first, I can't find a way to enforce the contract that the .py file contain only a class, and nothing else. Also, unless we create a new interpreter each time (which may, I wouldn't be surprised, take longer than just recompiling a class), I don't see a way to guarantee no side effects between calls. Whatever help or advice you can give would be appreciated. The more low-level (pseudocode, example code, whatever) the better. I'm 95% sure that what I'm asking for is possible, and 100% sure it should be possible, so if I find out that it's not, for whatever reason, I do intend to hack Jython until it is. If I end up doing this, I really will need all the detail I can get, before I try to grok the code on my own. Adam Berger __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ |