Hi Azat!

2013/2/1 Azat Galiev <[email protected]>:
> Thanks for answer!
>
> Here is full script:
>
> -------------------------------------------
> #!/usr/bin/env liquidsoap
>
> set("init.daemon", true)
> set("init.daemon.change_user", true)
> set("init.daemon.change_user.user", "liquidsoap")
> set("init.daemon.change_user.group", "liquidsoap")
> set("server.telnet", true)
>
> def stop_after_current =
>         raw_output = get_process_lines("./stop_after_current.py")
>         stop = list.hd(raw_output)
>         if stop == "true" then
>                 {false}
>         else
>                 {true}
>         end
> end

You're having a case of wrong functional scope here.. :-) Let me explain:

{true} is a shortcut for the simply function fun () -> true, i.e. a
function that takes no argument and always returns true.

Now, in the code above, the body of your function is only executed
once, at startup, and returns either {true} or {false}.

This means that your switching function will be fixed and one of
{true} or {false} during the execution of the script, which is not
what you want to..

Instead, you just need to change the scope of your function as follows:

def stop_after_current() =
        raw_output = get_process_lines("./stop_after_current.py")
        stop = list.hd(raw_output)
        if stop == "true" then
                false
        else
                true
        end
end

Do you see the difference?

Hope this helps!
Romain

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_jan
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to