The g.execute_shell_commands function executes a list of shell commands, 
each in a separate processes.
*Important*: unlike subprocess.call, each command in the list is a separate 
command (commands are not concatenated).

This function waits for each command to complete, unless the command starts 
with '&'. For example::

    g.execute_shell_commands(['echo hello','echo world','&pwd'])

Here it is::

    def execute_shell_commands(commands,trace = False):
        '''
        Execute each shell command in a separate process.
        Wait for each command to complete, except those starting with '&'
        '''
        for command in commands:
            wait = not command.startswith('&')
            if command.startswith('&'): command = command[1:].strip()
            if trace: g.trace('wait',wait,'command',command)
            proc = subprocess.Popen(command,shell=True)
            if wait: proc.communicate()

I have used g.execute_shell_command to great effect in @button make-sphinx 
in LeoDocs.leo. 
I'll discuss this next in a reply to the thread "@button make-html 
@key=Alt-period".

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to