summaryrefslogtreecommitdiffstats
path: root/gamechestcli/gamechest/runners/install.py
diff options
context:
space:
mode:
Diffstat (limited to 'gamechestcli/gamechest/runners/install.py')
-rw-r--r--gamechestcli/gamechest/runners/install.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/gamechestcli/gamechest/runners/install.py b/gamechestcli/gamechest/runners/install.py
new file mode 100644
index 0000000..a827e25
--- /dev/null
+++ b/gamechestcli/gamechest/runners/install.py
@@ -0,0 +1,42 @@
+import functools
+import os
+
+from .runnermulti import MultiSequencialRunnerBase
+from .download import Download
+from .extract import Extract
+from .remove import Remove
+
+
+class Install(MultiSequencialRunnerBase):
+
+ def __init__(self, source, dest):
+ filename = os.path.split(source)[1]
+ tmpdest = os.path.join(dest, f'{filename}.rsynctmp')
+ runners = [
+ functools.partial(Download, source, tmpdest),
+ functools.partial(Extract, tmpdest, dest),
+ functools.partial(Remove, tmpdest),
+ ]
+ super().__init__(runners)
+
+
+if __name__ == '__main__':
+ import sys
+ import contextlib
+ import time
+ import selectors
+ 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')