示例#1
0
def step_impl(context, command, name):
    logfile = _get_logfile(context)

    c = LocalRun(context.reactor, command, logfile=logfile)

    def on_exit(): context.results[name] = c.result
    c.register_exit_monitor(on_exit)

    context.executions[name] = c
示例#2
0
def step_impl(context, command, name):
    logfile = _get_logfile(context)

    c = LocalRun(context.reactor, command, logfile=logfile)

    def _on_exit(run):
        context.results[name] = c.result
    c.register_exit_monitor(_on_exit)

    context.executions[name] = c
示例#3
0
import logging
from yassh import Reactor, RemoteRun, RemoteConfiguration, LocalRun

logging.basicConfig(level=logging.DEBUG)

r = Reactor()
remote = RemoteConfiguration(host='localhost', username='******')
c1 = RemoteRun(r, remote, 'sleep 5')
c2 = LocalRun(r, 'echo ok')
c3 = RemoteRun(r, remote, 'echo "finished" && sleep 1')


def start_c2():
    # Start cmd2 when cmd1 complete
    c2.start()
c1.register_exit_monitor(start_c2)


def start_c3():
    # Start cmd3 when cmd2 complete
    c3.start()
c2.register_monitor(u'ok', start_c3)


def on_c3_finished():
    # Print dummy message when c3 is near terminaison
    print('c3 almost finished')
c3.register_monitor(u'finished', on_c3_finished)


# Start first task
示例#4
0
import logging
from yassh import Reactor, RemoteRun, RemoteConfiguration, LocalRun

logging.basicConfig(level=logging.DEBUG)

r = Reactor()
remote = RemoteConfiguration(host='localhost', username='******')
c1 = RemoteRun(r, remote, 'sleep 5')
c2 = LocalRun(r, 'echo ok')
c3 = RemoteRun(r, remote, 'echo "finished" && sleep 1')


def start_c2():
    # Start cmd2 when cmd1 complete
    c2.start()


c1.register_exit_monitor(start_c2)


def start_c3():
    # Start cmd3 when cmd2 complete
    c3.start()


c2.register_monitor(u'ok', start_c3)


def on_c3_finished():
    # Print dummy message when c3 is near terminaison
    print('c3 almost finished')
示例#5
0
import logging
from yassh import Reactor, RemoteRun, LocalRun

logging.basicConfig(level=logging.DEBUG)

r = Reactor()
c1 = RemoteRun(r, "localhost", "user", "sleep 5")
c2 = LocalRun(r, "echo ok")
c3 = RemoteRun(r, "localhost", "user", 'echo "finished" && sleep 1')

# Start cmd2 when cmd1 complete
def start_c2():
    c2.start()


c1.register_exit_monitor(start_c2)

# Start cmd3 when cmd2 complete
def start_c3():
    c3.start()


c2.register_monitor(u"ok", start_c3)

# Print dummy message when c3 is near terminaison
def on_c3_finished():
    print("c3 almost finished")


c3.register_monitor(u"finished", on_c3_finished)
示例#6
0
import logging
from yassh import Reactor, RemoteRun, LocalRun

logging.basicConfig(level=logging.DEBUG)

r = Reactor()
c1 = LocalRun(r, 'sleep 5')
c2 = LocalRun(r, 'echo ok')
c3 = LocalRun(r, 'echo "finished" && sleep 1')

for c in [c1, c2, c3]:
    # Raise if the process failed.
    def raise_on_failure():
        if not c.result:
            raise Exception('{0} failed'.format(c))

    c.register_exit_monitor(raise_on_failure)
    c.start()

# Infinite
timeout = -1
while r.run(timeout) > 0:
    pass