-
Notifications
You must be signed in to change notification settings - Fork 45
Allow tftp client to be imported as a library #15
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
base: master
Are you sure you want to change the base?
Changes from all commits
6c21519
ea1abb1
b577c22
2913dac
02fe07e
38d717d
7f8f5ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -565,13 +565,13 @@ def get(self, args): | |
| .format(filename)) | ||
| return False | ||
|
|
||
| transfer_speed = self.__get_speed(self.PTFTP_STATE.filesize, transfer_time) | ||
|
|
||
| print('Transfer complete, {} bytes ({:.2f} kB/s)' | ||
| .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() | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| os.remove(self.PTFTP_STATE.file.name) | ||
| return True | ||
| return (self.PTFTP_STATE.filesize, transfer_speed) | ||
|
|
||
| def put(self, args): | ||
| """ | ||
|
|
@@ -627,11 +627,11 @@ def put(self, args): | |
| print('Error: {}'.format(errmsg)) | ||
| return False | ||
|
|
||
| transfer_speed = self.__get_speed(self.PTFTP_STATE.filesize, transfer_time) | ||
|
|
||
| print('Transfer complete, {} bytes ({:.2f} kB/s)' | ||
| .format(self.PTFTP_STATE.filesize, | ||
| self.__get_speed(self.PTFTP_STATE.filesize, | ||
| transfer_time))) | ||
| return True | ||
| .format(self.PTFTP_STATE.filesize, transfer_speed)) | ||
| return (self.PTFTP_STATE.filesize, transfer_speed) | ||
|
|
||
| def mode(self, args): | ||
| if len(args) > 1: | ||
|
|
@@ -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): | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/exts/opts/ |
||
| client = TFTPClient((host, port), exts, mode, rfc1350) | ||
| client.connect() | ||
| return client | ||
|
|
||
| def main(): | ||
| # TODO: convert to optparse | ||
|
|
||
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/