A remote process launcher.
Project description
yassh
Yassh is a python library used to run asynchronous, dependent remote and local tasks.
Usage
import logging
from yassh import Reactor, RemoteRun, RemoteConfiguration, LocalRun
logging.basicConfig(level=logging.DEBUG)
# Create a remote ; only host parameter is mandatory
remote = RemoteConfiguration(host='localhost', username='user')
# ssh_config(5) options can be set in RemoteConfiguration object
remote.set('Compression', 'yes')
remote.set('CompressionLevel', '9')
r = Reactor()
c1 = RemoteRun(r, remote, 'sleep 5')
c2 = LocalRun(r, 'echo ok')
c3 = RemoteRun(r, remote, 'echo "finished" && sleep 1')
def start_c2(run):
# Start cmd2 when cmd1 complete successfully
if run.result == 0:
c2.start()
c1.register_exit_monitor(start_c2)
def start_c3(run):
# Start cmd3 when cmd2 complete
c3.start()
c2.register_monitor(u'ok', start_c3)
def on_c3_finished(run):
# Print dummy message when c3 is near terminaison
print('c3 almost finished')
c3.register_monitor(u'finished', on_c3_finished)
# Start first task
c1.start()
# Infinite
timeout = -1
while r.run(timeout) > 0:
pass
Installation
To install latest release:
pip install yassh
To install latest code:
pip install git+https://github.com/enyx-opensource/yassh.git
Testing
Run from project root:
behave
License
MIT License (see LICENSE)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
yassh-2.0.1.tar.gz
(6.1 kB
view hashes)
Built Distribution
Close
Hashes for yassh-2.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24aa22ec13f440a6a7ffee625878563a627d5c4e798bc42d1803e0f85be760f1 |
|
MD5 | de5b30393d5fac7c9e857e9f9d7dbdf2 |
|
BLAKE2b-256 | f3251c5c0dc6a877122a36a412dcaacdc9fcba34bd3baaa4ff08fd3a0ab8723c |