diff options
author | Francesco Fiorentino <f.fiorentino@camlintechnologies.com> | 2015-07-17 17:20:09 +0100 |
---|---|---|
committer | Francesco Fiorentino <f.fiorentino@camlintechnologies.com> | 2015-07-21 11:52:15 +0100 |
commit | 04a93901d6e9138a0b68b6ea799eeffbc3c5eed7 (patch) | |
tree | 79d3dc4b5b2baac385b46d748f14561d996a1111 /tftpy/TftpClient.py | |
parent | adb8b1ed1ee9b604e24e0a00f41b7f37604f9bf6 (diff) | |
download | tftpy-04a93901d6e9138a0b68b6ea799eeffbc3c5eed7.tar.gz |
Release version 0.6.3_fork (forked version)
Contains:
Bug fixes in log.debug
Fixes in broken code
Fixes many PEP8 issues
Created testWin Unit for Win environment
Diffstat (limited to 'tftpy/TftpClient.py')
-rw-r--r-- | tftpy/TftpClient.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/tftpy/TftpClient.py b/tftpy/TftpClient.py index a935b34..a95d023 100644 --- a/tftpy/TftpClient.py +++ b/tftpy/TftpClient.py @@ -3,9 +3,15 @@ instance of the client, and then use its upload or download method. Logging is performed via a standard logging object set in TftpShared.""" import types -from TftpShared import * -from TftpPacketTypes import * -from TftpContexts import TftpContextClientDownload, TftpContextClientUpload +try: + from TftpShared import * + from TftpPacketTypes import * + from TftpContexts import TftpContextClientDownload, TftpContextClientUpload +except ImportError: + from tftpy.TftpShared import * + from tftpy.TftpPacketTypes import * + from tftpy.TftpContexts import TftpContextClientDownload, TftpContextClientUpload + class TftpClient(TftpSession): """This class is an implementation of a tftp client. Once instantiated, a @@ -19,11 +25,11 @@ class TftpClient(TftpSession): self.iport = port self.filename = None self.options = options - if self.options.has_key('blksize'): + if 'blksize' in self.options: size = self.options['blksize'] tftpassert(types.IntType == type(size), "blksize must be an int") if size < MIN_BLKSIZE or size > MAX_BLKSIZE: - raise TftpException, "Invalid blksize: %d" % size + raise TftpException("Invalid blksize: %d" % size) def download(self, filename, output, packethook=None, timeout=SOCK_TIMEOUT): """This method initiates a tftp download from the configured remote @@ -38,10 +44,8 @@ class TftpClient(TftpSession): Note: If output is a hyphen, stdout is used.""" # We're downloading. log.debug("Creating download context with the following params:") - log.debug("host = %s, port = %s, filename = %s, output = %s", - self.host, self.iport, filename, output) - log.debug("options = %s, packethook = %s, timeout = %s", - self.options, packethook, timeout) + log.debug("host = %s, port = %s, filename = %s" % (self.host, self.iport, filename)) + log.debug("options = %s, packethook = %s, timeout = %s" % (self.options, packethook, timeout)) self.context = TftpContextClientDownload(self.host, self.iport, filename, |