Uploaded image for project: 'Runtime'
  1. Runtime
  2. RUNTIME-3266

[ScriptTool] Be able to launch scripts asynchronously

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Major Major
    • 4.3.0
    • 4.3.0
    • None
    • None
    • 4.3 M5

        [RUNTIME-3266] [ScriptTool] Be able to launch scripts asynchronously

        Code & Functional review ok

        But a bug:

        The following script

        return contents([], selection)

        is working in the cms in synchrone but not in asynchrone.

        Le script que vous avez lancé le 28 novembre 2019 à 11:35:39 CET est terminé.
        La console de sortie est :
        
        ReferenceError: contents is not defined
        ReferenceError: contents is not defined
        at main(generated script:3:30-37)
        at :program(generated script:337:12083-12088)
        at org.graalvm.polyglot.Context.eval(Context.java:344)
        at org.ametys.plugins.core.ui.script.ScriptHandler.executeScript(ScriptHandler.java:329)
        at org.ametys.plugins.core.ui.script.ScriptHandler._executeAndSendMail(ScriptHandler.java:191)
        at org.ametys.plugins.core.ui.script.ScriptHandler.lambda$1(ScriptHandler.java:172)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
        
        

        Raphaël Franchet added a comment - Code & Functional review ok But a bug: The following script return contents([], selection) is working in the cms in synchrone but not in asynchrone. Le script que vous avez lancé le 28 novembre 2019 à 11:35:39 CET est terminé. La console de sortie est : ReferenceError: contents is not defined ReferenceError: contents is not defined at main(generated script:3:30-37) at :program(generated script:337:12083-12088) at org.graalvm.polyglot.Context.eval(Context.java:344) at org.ametys.plugins.core.ui.script.ScriptHandler.executeScript(ScriptHandler.java:329) at org.ametys.plugins.core.ui.script.ScriptHandler._executeAndSendMail(ScriptHandler.java:191) at org.ametys.plugins.core.ui.script.ScriptHandler.lambda$1(ScriptHandler.java:172) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834)

        Simon Prieul (Inactive) added a comment - - edited

        In console, there is the print and the return value with " around
        ?? In the mail,there is the print and the return value with NO " around??

        ?? We have to make this consistant by founding why there are " around in the console and doing the same in the mail??

        When the script fail, I receive a success mail with empty console.
        ?? I should receive an error mail with the exception visible??

        For both comments, the problem is that the console in the tool is formatted into HTML with Ametys.plugins.coreui.script.ScriptToolHelper#formatConsoleOutput
        But for the async execution, it is on server side, I cannot call client-side code or duplicate it

        What do you think we should do ? Maybe not format with JS code but with i18n catalogue to be common ? But the formatting options will be limited and the client side will be less beautiful than before..I don't know

        Simon Prieul (Inactive) added a comment - - edited In console, there is the print and the return value with " around ?? In the mail,there is the print and the return value with NO " around?? ?? We have to make this consistant by founding why there are " around in the console and doing the same in the mail?? When the script fail, I receive a success mail with empty console. ?? I should receive an error mail with the exception visible?? For both comments, the problem is that the console in the tool is formatted into HTML with Ametys.plugins.coreui.script.ScriptToolHelper#formatConsoleOutput But for the async execution, it is on server side, I cannot call client-side code or duplicate it What do you think we should do ? Maybe not format with JS code but with i18n catalogue to be common ? But the formatting options will be limited and the client side will be less beautiful than before..I don't know

        As in the back the "execute in background" button should be in a menu of the execute button

        Execute is a split button, with a menu with 2 options: Execute and Execute in background

        Raphaël Franchet added a comment - As in the back the "execute in background" button should be in a menu of the execute button Execute is a split button, with a menu with 2 options: Execute and Execute in background

        Raphaël Franchet added a comment - - edited

        When the script fail, I receive a success mail with empty console.
        I should receive an error mail with the exception visible

        Raphaël Franchet added a comment - - edited When the script fail, I receive a success mail with empty console. I should receive an error mail with the exception visible

        Raphaël Franchet added a comment - - edited

        In console, there is the print and the return value with " around
        In the mail,there is the print and the return value with NO " around

        We have to make this consistant by founding why there are " around in the console and doing the same in the mail

        Raphaël Franchet added a comment - - edited In console, there is the print and the return value with " around In the mail,there is the print and the return value with NO " around We have to make this consistant by founding why there are " around in the console and doing the same in the mail

        I do the functional review also

        Raphaël Franchet added a comment - I do the functional review also

          sprieul Simon Prieul (Inactive)
          sprieul Simon Prieul (Inactive)
          Votes:
          0 Vote for this issue
          Watchers:
          2 Start watching this issue

            Created:
            Updated:
            Resolved: