diff --git a/examples/sftp_copy_file.py b/examples/sftp_copy_file.py new file mode 100644 index 00000000..c5cb7bf3 --- /dev/null +++ b/examples/sftp_copy_file.py @@ -0,0 +1,21 @@ +import os +from gevent import joinall +from datetime import datetime +from pssh.clients import ParallelSSHClient + + +with open('file_copy', 'wb') as fh: + for _ in range(2000000): + fh.write(b'asdfa') + + +fileinfo = os.stat('file_copy') +client = ParallelSSHClient(['localhost']) +now = datetime.now() +cmd = client.copy_file('file_copy', '/tmp/file_copy') +joinall(cmd, raise_error=True) +taken = datetime.now() - now +mb_size = fileinfo.st_size / (1024000.0) +rate = mb_size / taken.total_seconds() +print("File size %sMB transfered in %s, transfer rate %s MB/s" % ( + mb_size, taken, rate)) diff --git a/examples/single_client.py b/examples/single_client.py new file mode 100644 index 00000000..0ab0fab5 --- /dev/null +++ b/examples/single_client.py @@ -0,0 +1,18 @@ +from pssh.clients import SSHClient +from datetime import datetime + + +host = 'localhost' +cmds = ['echo first command', + 'echo second command', + 'sleep 1; echo third command took one second', + ] +client = SSHClient(host) + +start = datetime.now() +for cmd in cmds: + out = client.run_command(cmd) + for line in out.stdout: + print(line) +end = datetime.now() +print("Took %s seconds" % (end - start).total_seconds()) diff --git a/setup.py b/setup.py index e487023c..ba14ff7b 100644 --- a/setup.py +++ b/setup.py @@ -31,6 +31,7 @@ author='Panos Kittenis', author_email='zuboci@yandex.com', url="https://github.com/ParallelSSH/parallel-ssh", + license='LGPLv2.1', packages=find_packages( '.', exclude=('embedded_server', 'embedded_server.*', 'tests', 'tests.*',