-
Notifications
You must be signed in to change notification settings - Fork 43
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
Allow tftp client to be imported as a library #15
base: master
Are you sure you want to change the base?
Conversation
README.rst
Outdated
|
||
pTFTPd TFTP client can also be imported and used within a Python script. | ||
|
||
```from ptftpd import tftpclient |
There was a problem hiding this comment.
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.
There was a problem hiding this 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!
@@ -709,6 +709,11 @@ def usage(): | |||
print(' This will discard other TFTP option values.') | |||
print() | |||
|
|||
def client(host=_PTFTP_DEFAULT_HOST, port=_PTFTP_DEFAULT_PORT, | |||
mode=_PTFTP_DEFAULT_MODE, exts={}, rfc1350=False): |
There was a problem hiding this comment.
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}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/exts/opts/
.format(self.PTFTP_STATE.filesize, | ||
self.__get_speed(self.PTFTP_STATE.filesize, | ||
transfer_time))) | ||
.format(self.PTFTP_STATE.filesize, transfer_speed)) | ||
self.PTFTP_STATE.file.close() |
There was a problem hiding this comment.
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)?
Client Usable as a Library
Allows the ptftpd client tool to be imported as a library and integrated into other Python libraries.
Usage