Josh Juneau | 1 Sep 15:20
Picon

Reminder -- Jython Monthly Interview of Jim Baker

Reminder -- Time is running out for the Jython Monthly question and
answer session
with Jim Baker.

He has agreed to answer questions from the community for our
newsletter. Gather your best questions and post them to the wiki at
the URL below. If you have issues posting the questions on the wiki
page, then please email them to me so that they can be included. The
deadline for posting questions is September 19th. After that time, Jim Baker
will choose which ones he wishes to answer and we will
include them in the next distribution.

Please post your questions for Jim at:
http://wiki.python.org/jython/JythonMonthly/Interviews/August2008/JimBaker
and feel free to include your name/email address if you'd like.

Thanks in advance for your participation...this is a great opportunity
for the Jython community.

Special thanks to Jim Baker for his time!

--

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

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
(Continue reading)

Dave Kuhlman | 1 Sep 19:35
Gravatar

Re: Please explain how to get imports to work for embedded Jython in a .jar

> From: Greg Scott <gregory.scott99 <at> imperial.ac.uk>
> To: Dave Kuhlman <dkuhlman <at> rexx.com>
> Sent: Sunday, August 31, 2008 1:22:54 PM
> Subject: RE: Please help with embedded Jython with .JAR question
>
> Hi Dave
>
> Thank you so much for this. But remember, my completed project is not of
> this form because the jython.jar is included in the classpath. The program
> remember is executed from a normal .class file and the Jython embedded via
> JS223. So there are 2 or more jars involved. I have tried putting a Lib
> directory in my My.jar but this is nothing to do with the library/jar of
> jython.jar which is included. Are you saying I have to alter the actual
> jython.jar to get this to work? Surely not?
>

Greg -

I believe that I've given you about as much help as I am capable
of.  I'm someone who has been able to come up with a few recipes
that, I hope, handle a reasonable number of common cases, but who
does not really understand the underlying theory well enough to go
much further.

I'm not saying that you *have to* modify the jython.jar.  But,
creating a replacement for it (which is what the stand-alone jar
is) might be one approach to filling your need.

And, if not, here are several questions that might suggest a
solution:
(Continue reading)

Oti | 3 Sep 22:43
Picon
Gravatar

Re: TypeError question

Hi Heshan,

just a guess: I assume that the getDictionary() method of Processor
wants a String as argument.

Then you could use:
  String stt = "Processor.getDictionary(\"" + filePath +"\")";
or:
  String stt = "Processor.getDictionary('" + filePath +"')";
instead of:
  String stt = "Processor.getDictionary(" + filePath +")";

(basically surround the filePath with single or double quotes.

Hope this helps,
Oti.

On Mon, Aug 25, 2008 at 10:45 AM, Heshan Suriyaarachchi
<heshan.suri <at> gmail.com> wrote:
> Hi,
>     I need to analyse a python script(annotationScript.py) from another
> python script(Processor) within java.
> 1). I did like below and it gave an error. It is  confusing for me because
> when I called the method using python it worked without errors. Can anyone
> help me to overcome this error.
>
> //java code
>         interp.exec("import annotationScript");
>         interp.exec("import Processor");
>         String stt = "Processor.getDictionary(annotationScript)";
(Continue reading)

Alan Kennedy | 4 Sep 14:15
Favicon

Re: Trapping errors in scripts at runtime.

[David]
> Can anyone suggest a way of trapping exceptions in runtime script execution ?

Is this what you mean?

//============== CatchExceptions.java =====================
import org.python.core.*;
import org.python.util.PythonInterpreter;

public class CatchExceptions
{

  public static void runDodgyCode ( PythonInterpreter interp, String
codeString )
  {
    try
    {
      interp.exec(codeString);
    }
    catch (PyException pyx)
    {
      if (pyx.type == Py.IndexError)
        System.err.println("This code >>>"+codeString+"<<< gave an
index error");
      if (pyx.type == Py.KeyError)
        System.err.println("This code >>>"+codeString+"<<< gave a key error");
      if (pyx.type == Py.SyntaxError)
        System.err.println("This code >>>"+codeString+"<<< gave a
syntax error");
      if (pyx.type == Py.ZeroDivisionError)
(Continue reading)

Jeff Emanuel | 4 Sep 16:20
Favicon

Re: Trapping errors in scripts at runtime.

No, he means something like this:

  // codeString defines a Jython class implementating of a Java interface
  // and creates an instance of the class.
  interp.exec(codeString);
  AnInterface obj = 
(AnInterface)interp.get("obj").__tojava__(AnInterface.class);

  // Later.
  try {
    obj.someMethodWithBadJythonImplementation();
  } catch (PyException pyEx) {
    // Does catching PyException here work?
  }

Alan Kennedy wrote:
> [David]
>   
>> Can anyone suggest a way of trapping exceptions in runtime script execution ?
>>     
>
> Is this what you mean?
>
> //============== CatchExceptions.java =====================
> import org.python.core.*;
> import org.python.util.PythonInterpreter;
>
> public class CatchExceptions
> {
>
(Continue reading)

Alan Kennedy | 4 Sep 17:34
Favicon

Re: Trapping errors in scripts at runtime.

[Jeff]
> No, he means something like this:
>
>  // codeString defines a Jython class implementating of a Java interface
>  // and creates an instance of the class.

OK, then here is the code that he needs.

//============================================================
import org.python.core.*;
import org.python.util.PythonInterpreter;

public class CatchExceptions
{

  public static Object compileCodeAndGetClass (
      PythonInterpreter interp,
      String            codeString,
      String            targetClassName,
      String            name)
    throws Exception
  {
    interp.exec(codeString);
    PyObject pyObj = (PyObject)interp.get(name).__call__();
    if (pyObj == null)
      throw new Exception("Cannot find definition of '"+
        name+"' class");
    Class targetClass = Class.forName(targetClassName);
    Object jObj = pyObj.__tojava__(targetClass);
    if (jObj == Py.NoConversion)
(Continue reading)

Oti | 4 Sep 17:55
Picon
Gravatar

Re: Packaging and deployment

On Sun, Aug 24, 2008 at 8:51 PM, JLIST <jlist9 <at> gmail.com> wrote:
> Hello Leo,
>> I'm pretty sure it will work without the $py.class files. I think that
>> it is the "Lib/" directory though, with a capital 'L'.
>
> I see. Thanks. In this case, I suppose Jython will compile them
> on the fly in a temp directory?
>
> Jack

Hi Jack,

it will compile into memory only, AFAICT.

best wishes,
Oti.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Picon

UnsatisfiedLinkError Issue


Hi folks,

When I build jython from trunk on my linux box and try to run the interpreter, I get a:

jython-svn/trunk/jython/dist$ ./bin/jython
Exception in thread "main" java.lang.UnsatisfiedLinkError: no JavaReadline in java.library.path
...
i tought that my LD_LIBRARY_PATH was wrong, but it contains '/usr/lib/jni', the directory that contains libJavaReadline.so.

The standard Jython interpreter (2.2.1 from the installer) runs just fine but displays the same error when I set the LD_LIBRARY_PATH is to ''.

Any idea what could be the reason for this error except for a wrong LD_LIBRARY_PATH ?

Cheers,

SB


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
James Pettit | 5 Sep 09:33
Picon

Killing a runaway PythonInterpreter

This is partially in reference to "RE: [Jython-users] kill a timed out python script in multithreade d Jython environment". I have a PythonInterpreter that has executed a script (via execfile) with a "while" loop that never ends.

I'd like some way for the controlling thread to kill the interpreter (so I can start a new one, with a modified version of the script). The link given in that post, <
http://sourceforge.net/mailarchive/message.php?msg_id=6315806>, is inactive, and is the last bit of info I could find on the subject. I've tried "cleanup" in PythonInterpreter, and "exit" in PySystemState... no luck. Of course, killing the process works, so something can stop the dang thing. Any hints?
- James
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
Picon

Jython developer build 'UnsatisfiedLinkError' issue


Hello all,

I've tracked down the 'JavaReadline UnsatisfiedLinkedError' issue I experience with the current jython trunk (Linux box, developer build).

Basically,

    $ java -cp $CP org.python.util.jython

works without error, but

    $ java -Xbootclasspath/a:"$CP" org.python.util.jython

raises the link error, and this latter scheme is used in the new jython bash script.

Does anyone experience the same issue ? Shall we go back (at least partially for the readline lib) to the old '-cp' way of doing things ?

Cheers,

SB



Sébastien Boisgérault wrote:

Hi folks,

When I build jython from trunk on my linux box and try to run the interpreter, I get a:

jython-svn/trunk/jython/dist$ ./bin/jython
Exception in thread "main" java.lang.UnsatisfiedLinkError: no JavaReadline in java.library.path
...
i tought that my LD_LIBRARY_PATH was wrong, but it contains '/usr/lib/jni', the directory that contains libJavaReadline.so.

The standard Jython interpreter (2.2.1 from the installer) runs just fine but displays the same error when I set the LD_LIBRARY_PATH is to ''.

Any idea what could be the reason for this error except for a wrong LD_LIBRARY_PATH ?

Cheers,

SB


------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Jython-users mailing list Jython-users <at> lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jython-users

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Jython-dev mailing list
Jython-dev <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-dev

Gmane