From 15bbb728e82a63937ee421bb9c70eb02ad8d1ad3 Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Thu, 12 Jan 2023 21:09:11 +0100 Subject: [PATCH] cleanup --- src/p1st/test.py | 35 ++--------------------------------- src/p1st/transfer_inform.py | 33 --------------------------------- 2 files changed, 2 insertions(+), 66 deletions(-) delete mode 100644 src/p1st/transfer_inform.py diff --git a/src/p1st/test.py b/src/p1st/test.py index 12bf5c6..416563c 100644 --- a/src/p1st/test.py +++ b/src/p1st/test.py @@ -1,15 +1,11 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -import os -import shlex import shutil -import socket from pathlib import Path from p1st.exec_capture import execute_capture from p1st.exec_print_capture import execute_print_capture from p1st.exec_produce_chunks import execute_produce_chunks -from p1st.transfer_inform import transfer_inform def test(): @@ -43,33 +39,6 @@ def test2(): returncode, out, err = execute_print_capture(['ls', '/foo/bar']) -def test4(): - _init(4) - - transfer_inform( - ['ls', 'test/4-rsync-error'], # rsync src to dst - ['ls', 'test/4-ssh-error'], # ssh target-pc 'echo "OK" | nc -U "/path/to/unix-socket"' - Path('test/4-UNIX-socket') - ) - - -def _test5_chunk_transfer_fun(chunk_file: Path, - chunk_number: int, - eof: bool, - concat_script: Path, - remote_target_file: Path): - rsync_cmd = [str(concat_script), str(chunk_file), str(remote_target_file)] - inform_cmd = ['ls', - chunk_file.parent.joinpath(f'5.remote.EOF={eof}'), - ] - - transfer_inform( - rsync_cmd=rsync_cmd, - inform_cmd=inform_cmd, - user_input_file=chunk_file.parent.joinpath(f'5.SOCKET'), - ) - - def test8(): repo_name = 'subprocess_util' @@ -108,9 +77,9 @@ def test9(): def test10(): _init(10) - source_file = Path('src/p1st/transfer_inform.py') + source_file = Path('src/p1st/exec_capture.py') chunk_dir = Path('test') - target_file = Path('test/transfer_inform.py') + target_file = Path('test/exec_capture.py') def get_chunk_path(chunk_no: int): return chunk_dir.joinpath(f'{source_file.name}.CHUNK.{chunk_no}') diff --git a/src/p1st/transfer_inform.py b/src/p1st/transfer_inform.py deleted file mode 100644 index a97ad67..0000000 --- a/src/p1st/transfer_inform.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -from pathlib import Path - -from p1st.repeat import repeat_until_successful - - -def transfer_inform(rsync_cmd: list[str], - inform_cmd: list[str], - user_input_file: Path): - """ - First, this method transfers files to a remote pc. - - Then, it informs the remote pc. - - If some error occurs during the above steps, - it waits for user input (via a UNIX-socket) and repeats the failed step. - - :param rsync_cmd: - :param inform_cmd: - :param user_input_file: - :return: - """ - - # - rsync to remote pc - # - catch error - # - wait until user input, then repeat - repeat_until_successful(rsync_cmd, user_input_file) - - # - inform remote pc about complete rsync - # - catch error - # - wait until user input, then repeat - repeat_until_successful(inform_cmd, user_input_file)