jakarta-bsf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mario Neè <mario....@xmoon.org>
Subject Re: Usage of Eval
Date Wed, 07 Jun 2006 10:11:14 GMT
If you want to try...
http://www.xmoon.org

<task>
   <code language="javascript | ruby | judoscript | beanshell | *jython*">
        Script code here
    </code>
</task>


Neil Benn ha scritto:
> Hello,
>  
>             I am working with BSF and Jython (I'll move onto other
> languages later - it's just the Jython/Python is the scriptng language I
> am most used to).  I'm trying to implement a simple script to run a
> method and get the result such as:
>  
> ---
> def test():
>             return 1
> test()
>  
> ---
>  
> I was hoping that when I eval that using:
>  
> ---
>  
> public void testRawJythonScript(){
>             String strScript = "def test():\n";
>             strScript += "\treturn 1\n";
>             strScript += "test()\n";
>             BSFManager objBM = new BSFManager();
>             try{
>                         Object objResult = objBM.eval("Jython", null, 0,
> 0, strScript);
>                         System.out.println(objResult);
>             }catch (BSFException eBSF){
>                         eBSF.printStackTrace();
>                         fail(eBSF.getMessage());
>             }
> }
>  
> ---
>  
>   I would get the number 1 back (well in a PyObject but still 1).
> However I get an exception:
>  
> ---
>  
> junit.framework.AssertionFailedError: exception from Jython: Traceback
> (innermost last):
>   (no code object) at line 0
>   File "<string>", line 1
>             def test():
>             ^
> SyntaxError: invalid syntax
>  
>             at junit.framework.Assert.fail(Assert.java:47)
>             at
> uk.co.ziath.datapaq.server.scripting.test.BSFScriptProcessorTest.testRaw
> JythonScript(BSFScriptProcessorTest.java:67)
>             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
>             at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
> Source)
>             at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> Source)
>             at java.lang.reflect.Method.invoke(Unknown Source)
>             at junit.framework.TestCase.runTest(TestCase.java:154)
>             at junit.framework.TestCase.runBare(TestCase.java:127)
>             at junit.framework.TestResult$1.protect(TestResult.java:106)
>             at
> junit.framework.TestResult.runProtected(TestResult.java:124)
>             at junit.framework.TestResult.run(TestResult.java:109)
>             at junit.framework.TestCase.run(TestCase.java:118)
>             at junit.framework.TestSuite.runTest(TestSuite.java:208)
>             at junit.framework.TestSuite.run(TestSuite.java:203)
>             at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
> stRunner.java:478)
>             at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
> ner.java:344)
>             at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
> nner.java:196)
>  
> ---
>  
>             In addition my System.out repeats the top message a few
> times, I've tried playing around with a few things but I can't
> understand why BSF/Jython thinks this is bad code.  I would be eternally
> grateful if someone could point me in the right direction! If this is
> better asked on the Jython Users board then please let me know - ta.
>  
>             Thanks in advance.        
>  
> Cheers,
>  
> Neil
>
>   


-- 
Mario Nee'
Web Developer

------------------------------
Neex
Via Vanzeghetto, 47
25031 Capriolo (BS) Italia
www.neex.it
------------------------------

CONFIDENZIALE: Questo messaggio e gli eventuali allegati sono confidenziali e riservati. Se
vi e' stato recapitato per errore e non siete fra i destinatari elencati, siete pregati di
darne immediatamente avviso al mittente. Le informazioni contenute non devono essere mostrate
ad altri, ne utilizzate, memorizzate o copiate in qualsiasi forma.
CONFIDENTIALITY : This  e-mail  and  any attachments are confidential and may be privileged.
If  you are not a named recipient, please notify the sender immediately and do not disclose
the contents to another person, use it for any purpose or store or copy the information in
any medium.


---------------------------------------------------------------------
To unsubscribe, e-mail: bsf-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bsf-user-help@jakarta.apache.org


Mime
View raw message