Skip to content

Allow tftp client to be imported as a library#15

Open
isaiahtaylor wants to merge 7 commits intompetazzoni:masterfrom
isaiahtaylor:master
Open

Allow tftp client to be imported as a library#15
isaiahtaylor wants to merge 7 commits intompetazzoni:masterfrom
isaiahtaylor:master

Conversation

@isaiahtaylor
Copy link
Copy Markdown

Client Usable as a Library

Allows the ptftpd client tool to be imported as a library and integrated into other Python libraries.

Usage

from ptftpd import tftpclient

client = tftpclient.client(host='tftpsite.com', exts={'windowsize': 4})

results = client.get(['-f', 'thefile.txt'])
### or
results = client.put(['thefile.txt'])

print(results[0] +  'kB')
# prints 55234 kB

print(results[1] + ' kB/s')
# prints 100 kB/s

README.rst Outdated

pTFTPd TFTP client can also be imported and used within a Python script.

```from ptftpd import tftpclient
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not how reStructuredText work for code blocks. See below in the "Installation" section for an example.

Copy link
Copy Markdown
Owner

@mpetazzoni mpetazzoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last few nits. Thanks!

print()

def client(host=_PTFTP_DEFAULT_HOST, port=_PTFTP_DEFAULT_PORT,
mode=_PTFTP_DEFAULT_MODE, exts={}, rfc1350=False):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/exts/opts/


from ptftpd import tftpclient

client = tftpclient.client(host='tftpsite.com', exts={'windowsize': 4})
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/exts/opts/

self.__get_speed(self.PTFTP_STATE.filesize,
transfer_time)))
.format(self.PTFTP_STATE.filesize, transfer_speed))
self.PTFTP_STATE.file.close()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're in there, would you mind moving this and the line below (the close and the remove) in a finally block of the try/except above (line 567)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants