Skip to content

Updated CI cfg #164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 27, 2021
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
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ jobs:
./ci/build-manylinux.sh
- run:
name: sdist
command: python setup.py sdist
command: |
sudo chown circleci -R *
python setup.py sdist
- run:
name: Upload Wheels
command: |
Expand Down
24 changes: 13 additions & 11 deletions examples/sftp_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

"""Example script for SFTP write"""

from __future__ import print_function

import argparse
import socket
import os
import pwd
import sys
from datetime import datetime

from ssh2.session import Session
Expand All @@ -17,7 +13,7 @@
LIBSSH2_SFTP_S_IROTH


USERNAME = pwd.getpwuid(os.geteuid()).pw_name
USERNAME = os.getlogin()

parser = argparse.ArgumentParser()

Expand All @@ -32,6 +28,7 @@


def main():
buf_size = 1024 * 1024
args = parser.parse_args()
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((args.host, args.port))
Expand All @@ -40,18 +37,23 @@ def main():
s.agent_auth(args.user)
sftp = s.sftp_init()
mode = LIBSSH2_SFTP_S_IRUSR | \
LIBSSH2_SFTP_S_IWUSR | \
LIBSSH2_SFTP_S_IRGRP | \
LIBSSH2_SFTP_S_IROTH
LIBSSH2_SFTP_S_IWUSR | \
LIBSSH2_SFTP_S_IRGRP | \
LIBSSH2_SFTP_S_IROTH
f_flags = LIBSSH2_FXF_CREAT | LIBSSH2_FXF_WRITE
fileinfo = os.stat(args.source)
print("Starting copy of local file %s to remote %s:%s" % (
args.source, args.host, args.destination))
now = datetime.now()
with open(args.source, 'rb') as local_fh, \
with open(args.source, 'rb', buf_size) as local_fh, \
sftp.open(args.destination, f_flags, mode) as remote_fh:
for data in local_fh:
data = local_fh.read(buf_size)
while data:
remote_fh.write(data)
print("Finished writing remote file in %s" % (datetime.now() - now,))
data = local_fh.read(buf_size)
taken = datetime.now() - now
rate = (fileinfo.st_size / 1024000.0) / taken.total_seconds()
print(f"Finished writing remote file in {taken}, transfer rate {rate} MB/s")


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tag_prefix = ''
universal = 0

[flake8]
max-line-length = 80
max-line-length = 100
filename = *.pyx,*.px*
exclude = .eggs,*.egg,build
ignore = E901,E225,E226,E227,E999