diff options
Diffstat (limited to 'src/gamechest/runners/install.py')
| -rw-r--r-- | src/gamechest/runners/install.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/gamechest/runners/install.py b/src/gamechest/runners/install.py new file mode 100644 index 0000000..0b37304 --- /dev/null +++ b/src/gamechest/runners/install.py @@ -0,0 +1,40 @@ +import functools +from pathlib import Path + +from .download import Download +from .extract import Extract +from .remove import Remove +from .runnermulti import MultiSequencialRunnerBase + + +class Install(MultiSequencialRunnerBase): + + def __init__(self, source, dest): + tmpdest = Path(dest) / 'archive.rsynctmp' + runners = [ + functools.partial(Download, source, tmpdest), + functools.partial(Extract, tmpdest, dest), + functools.partial(Remove, tmpdest), + ] + super().__init__(runners) + + +if __name__ == '__main__': + import contextlib + import selectors + import sys + print('main test') + with contextlib.ExitStack() as stack: + stack.enter_context(contextlib.suppress(KeyboardInterrupt)) + runner = stack.enter_context(Install(sys.argv[1], sys.argv[2])) + selector = stack.enter_context(selectors.DefaultSelector()) + selector.register(runner.get_read_fd(), selectors.EVENT_READ) + last_progress = None + while (rc := runner.poll()) is None: + if selector.select(): + progress = runner.progress_read() + if progress != last_progress: + print(progress) + last_progress = progress + print('ended with code:', rc) + print('test main ended') |
