This is why I think the “:quit” console command cannot be utilised for this:
OpenMOLE>try {
| throw new Exception("runtime error")
| } catch {
| :quit 1
<console>:4: error: illegal start of simple expression
:quit 1
^
OpenMOLE>
That is why I was wondering if maybe you would need some global setting which
let’s users of the console request you to handle all exceptions and quit with
non-zero exit code if one is caught. This would always make sense in headless
batch mode, but I would also want it when I pipe in the OpenMOLE script via
STDIN (which could also be made explicit via let’s say “-s -” or “-s stdin” or
similar).
> On 28 Apr 2015, at 18:40, Andreas Schuh <[email protected]> wrote:
>
> Hi Romain,
>
> if it is possible to invoke “:quit” within a Scala code block, this would be
> fine. Not sure if that is possible, though. Right now, I am having some
> troubles getting a working OpenMOLE build again after I update the master
> branch and cannot try it out. I was experiencing some issues with my plugin
> that I believe used to work before. But with the most recent master branch my
> plugin doesn’t work b/c of changes of InputOutputBuilder and the snapshot
> MAVEN .jar files not being in sync with these most recent changes.
>
> If you could update the MAVEN snapshot archives which I compile my plugin
> against, I should be able to run my code in the latest OpenMOLE master branch
> version and try out the recent return code related changes.
>
> Thanks,
> Andreas
>
>> On 28 Apr 2015, at 18:34, Romain Reuillon <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>> Hi Andreas,
>>
>> I just pushed some code so the console should return a non-0 return code in
>> case of compilation error. For runtime errors so, you should wrap your code
>> in a try catch and use the ":quit erno" command to get an non 0 return code.
>> Would that suite your requierements?
>>
>> Romain
>>
>> Le 23/04/2015 15:51, Andreas Schuh a écrit :
>>> It turns out for the first purpose, to quit when no appropriate arguments
>>> were supplied, I should just check these in my wrapping application
>>> *before* starting OpenMOLE console process at all… sorry I didn’t see this
>>> earlier.
>>>
>>> On the other hand, I would like to be able to catch errors in the script
>>> and if one is encountered exit with non-zero return code. The problem with
>>> :quit is that it cannot be part of a conditional branch, e.g.,
>>>
>>> if (args.length == 0) :quit 1
>>>
>>> doesn’t work b/c :quit is not actually a Scala function, but a special
>>> console command.
>>>
>>> Is it feasible to have something similar to Bash’s “set -e” which would
>>> make the OpenMOLE process quit as soon as it encounters an error in one of
>>> the statements or catches an unhandled exception ?
>>>
>>> If it’s too complicated or requires more than just small changes, I can
>>> life with checking all arguments in my wrapper App before starting the
>>> OpenMOLE console.
>>>
>>>> On 23 Apr 2015, at 11:22, Romain Reuillon <[email protected]
>>>> <mailto:[email protected]>> wrote:
>>>>
>>>> Yep, I am placing much hopes in this JSR:
>>>> https://jcp.org/en/jsr/detail?id=376
>>>> <https://jcp.org/en/jsr/detail?id=376>, that will make it possible...
>>>>
>>>> Le 23/04/2015 12:20, Andreas Schuh a écrit :
>>>>> Thanks, Romain, that’ll do. I think in the long run it would anyway be
>>>>> nicer to be able to use OpenMOLE as library. Then this wouldn’t be needed
>>>>> any longer.
>>>>>
>>>>>> On 23 Apr 2015, at 10:41, Romain Reuillon <[email protected]
>>>>>> <mailto:[email protected]>> wrote:
>>>>>>
>>>>>> Hi Andreas,
>>>>>>
>>>>>> I just pushed code so you may now pass a return code to the quit command:
>>>>>> :q 14 will exit OpenMOLE and you'll get the 14 exit code for the
>>>>>> openmole process.
>>>>>>
>>>>>> This is a bit hacky though and depends on some scala console internal
>>>>>> behaviour, I hope it will not be too hard to maintain in the long run.
>>>>>>
>>>>>> cheers,
>>>>>> Romain
>>>>>>
>>>>>> Le 22/04/2015 18:19, Andreas Schuh a écrit :
>>>>>>> Sorry, wanted to include more specifics on my intention… a wrong
>>>>>>> argument would be for example one that doesn’t exist in the
>>>>>>> configuration file or simply no argument at all. In that case I would
>>>>>>> rather print a help screen and exit. In a way I would like to use an
>>>>>>> OpenMOLE script within the REPL as in any other scripting language. If
>>>>>>> I could execute my plugin code without the OpenMOLE console (REPL) but
>>>>>>> directly via a library call, that would be best of course...
>>>>>>>
>>>>>>> Within the REPL, exceptions are caught and the next instruction is read
>>>>>>> from STDIN and executed. In my case, I would prefer if the execution
>>>>>>> would stop then and the console quit with error code instead.
>>>>>>>
>>>>>>>> On 22 Apr 2015, at 17:16, Andreas Schuh <[email protected]
>>>>>>>> <mailto:[email protected]>> wrote:
>>>>>>>>
>>>>>>>> Not sure if that would be enough. An “exit” command that can be passed
>>>>>>>> a return code for the OpenMOLE console would be nice.
>>>>>>>>
>>>>>>>> Here’s my main function where I execute OpenMOLE as a subprocess:
>>>>>>>> https://github.com/schuhschuh/REPEAT/blob/a8ebb2ca826616fca66fcd91832dc87ed585a2ff/src/main/scala/com/andreasschuh/repeat/app/Main.scala#L41
>>>>>>>>
>>>>>>>> <https://github.com/schuhschuh/REPEAT/blob/a8ebb2ca826616fca66fcd91832dc87ed585a2ff/src/main/scala/com/andreasschuh/repeat/app/Main.scala#L41>
>>>>>>>>
>>>>>>>>> On 22 Apr 2015, at 17:13, Romain Reuillon <[email protected]
>>>>>>>>> <mailto:[email protected]>> wrote:
>>>>>>>>>
>>>>>>>>> .... actually returning at the end of the start method would be ok.
>>>>>>>>>
>>>>>>>>> Le 22/04/2015 18:11, Romain Reuillon a écrit :
>>>>>>>>>> Hi Andreas,
>>>>>>>>>>
>>>>>>>>>> would you like to be able to set the retrun code it from a script ?
>>>>>>>>>> What does an incorect argument mean in your case?
>>>>>>>>>>
>>>>>>>>>> I would say, this post is a good starting point to implement such a
>>>>>>>>>> feature into openmole:
>>>>>>>>>> http://stackoverflow.com/questions/6431119/control-over-exit-codes-in-a-osgi-shutdown
>>>>>>>>>>
>>>>>>>>>> <http://stackoverflow.com/questions/6431119/control-over-exit-codes-in-a-osgi-shutdown>,
>>>>>>>>>> we could add a command in the console to achieve that.
>>>>>>>>>>
>>>>>>>>>> Romain
>>>>>>>>>>
>>>>>>>>>> Le 22/04/2015 17:38, Andreas Schuh a écrit :
>>>>>>>>>>> Hi,
>>>>>>>>>>>
>>>>>>>>>>> I was wondering if it is somehow possible to have a OpenMOLE batch
>>>>>>>>>>> script (read either from file or STDIN), terminate the console with
>>>>>>>>>>> a non-zero exit code ? In my particular case, I start a workflow
>>>>>>>>>>> execution within an application that wraps the OpenMOLE console
>>>>>>>>>>> execution. Users need not be to be aware that they are running
>>>>>>>>>>> OpenMOLE… if some error occurs or when the user forgot some command
>>>>>>>>>>> arguments, I want to be able to print an error message and exit
>>>>>>>>>>> (the console) with non-zero exit code.
>>>>>>>>>>>
>>>>>>>>>>> Andreas
>>>>>>>>>>> _______________________________________________
>>>>>>>>>>> OpenMOLE-users mailing list
>>>>>>>>>>> [email protected] <mailto:[email protected]>
>>>>>>>>>>> http://fedex.iscpif.fr/mailman/listinfo/openmole-users
>>>>>>>>>>> <http://fedex.iscpif.fr/mailman/listinfo/openmole-users>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> _______________________________________________
>>>>>>>>>> OpenMOLE-users mailing list
>>>>>>>>>> [email protected] <mailto:[email protected]>
>>>>>>>>>> http://fedex.iscpif.fr/mailman/listinfo/openmole-users
>>>>>>>>>> <http://fedex.iscpif.fr/mailman/listinfo/openmole-users>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
_______________________________________________
OpenMOLE-users mailing list
[email protected]
http://fedex.iscpif.fr/mailman/listinfo/openmole-users