mirror of
https://codeberg.org/privacy1st/subprocess-util
synced 2024-12-22 22:06:05 +01:00
53 lines
1.4 KiB
Python
53 lines
1.4 KiB
Python
from pathlib import Path
|
|
|
|
from rsync_inform import rsync_inform
|
|
from subprocess_util import execute_print_capture
|
|
from subprocess_util1 import execute_capture
|
|
from subprocess_util_2 import execute_print_transfer_chunks
|
|
|
|
|
|
def test():
|
|
test1()
|
|
test2()
|
|
test3()
|
|
test4()
|
|
|
|
|
|
def test1():
|
|
print("TEST ZERO")
|
|
returncode, out, err = execute_capture(['ls', '-la'])
|
|
print(f'stdout:\n{out}\nstderr:\n{err}')
|
|
print()
|
|
returncode, out, err = execute_capture(['ls', '/foo/bar'])
|
|
print(f'stdout:\n{out}\nstderr:\n{err}')
|
|
|
|
|
|
def test2():
|
|
print("TEST ONE")
|
|
returncode, out, err = execute_print_capture(['ls', '-la'])
|
|
print()
|
|
returncode, out, err = execute_print_capture(['ls', '/foo/bar'])
|
|
|
|
|
|
def test3():
|
|
print("TEST TWO-1")
|
|
execute_print_capture(['rm', '-rf', 'test/1', 'test/2', 'test/3'])
|
|
returncode = execute_print_transfer_chunks(['ls', '-la'], Path('test/1'))
|
|
print("TEST TWO-2")
|
|
returncode = execute_print_transfer_chunks(['ls', '/foo/bar'], Path('test/2'))
|
|
print("TEST TWO-3")
|
|
returncode = execute_print_transfer_chunks(['cat', 'subprocess_util.py'], Path('test/3'),
|
|
chunk_size=1024)
|
|
|
|
|
|
def test4():
|
|
rsync_inform(
|
|
['ls', 'test/rsync-error'], # rsync src to dst
|
|
['ls', 'test/ssh-error'], # ssh target-pc 'echo "OK" | nc -U "/path/to/unix-socket"'
|
|
Path('test/unix-socket')
|
|
)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
test()
|