Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions examples/sftp_copy_file.py
Original file line number Diff line number Diff line change
@@ -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))
18 changes: 18 additions & 0 deletions examples/single_client.py
Original file line number Diff line number Diff line change
@@ -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())
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.*',
Expand Down