diff --git a/Makefile b/Makefile index eafe956..811bdff 100644 --- a/Makefile +++ b/Makefile @@ -19,3 +19,6 @@ tftpy-doc: clean: rm -rf dist src tftpy-doc* MANIFEST + +flakes: + pyflakes bin/*.py tftpy/*.py diff --git a/bin/tftpy_server.py b/bin/tftpy_server.py index b8aec50..6a1d3a3 100755 --- a/bin/tftpy_server.py +++ b/bin/tftpy_server.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -import sys, logging, os +import sys, logging from optparse import OptionParser import tftpy diff --git a/tftpy/TftpClient.py b/tftpy/TftpClient.py index b8cfa34..16753f1 100644 --- a/tftpy/TftpClient.py +++ b/tftpy/TftpClient.py @@ -2,10 +2,9 @@ instance of the client, and then use its upload or download method. Logging is performed via a standard logging object set in TftpShared.""" -import time, types +import types from TftpShared import * from TftpPacketTypes import * -from TftpPacketFactory import TftpPacketFactory from TftpContexts import TftpContextClientDownload, TftpContextClientUpload class TftpClient(TftpSession): diff --git a/tftpy/TftpContexts.py b/tftpy/TftpContexts.py index b317c5e..a76b686 100644 --- a/tftpy/TftpContexts.py +++ b/tftpy/TftpContexts.py @@ -155,7 +155,7 @@ class TftpContext(object): something, and dispatch appropriate action to that response.""" try: (buffer, (raddress, rport)) = self.sock.recvfrom(MAX_BLKSIZE) - except socket.timeout, err: + except socket.timeout: log.warn("Timeout waiting for traffic, retrying...") raise TftpTimeout, "Timed-out waiting for traffic" diff --git a/tftpy/TftpPacketTypes.py b/tftpy/TftpPacketTypes.py index 14cbd90..e02381f 100644 --- a/tftpy/TftpPacketTypes.py +++ b/tftpy/TftpPacketTypes.py @@ -44,7 +44,6 @@ class TftpPacketWithOptions(object): """This method decodes the section of the buffer that contains an unknown number of options. It returns a dictionary of option names and values.""" - nulls = 0 format = "!" options = {} diff --git a/tftpy/TftpServer.py b/tftpy/TftpServer.py index 1efaba2..364227c 100644 --- a/tftpy/TftpServer.py +++ b/tftpy/TftpServer.py @@ -3,7 +3,7 @@ instance of the server, and then run the listen() method to listen for client requests. Logging is performed via a standard logging object set in TftpShared.""" -import socket, os, re, time, random +import socket, os, time import select from TftpShared import * from TftpPacketTypes import * @@ -94,7 +94,6 @@ class TftpServer(TftpSession): log.debug("Read %d bytes" % len(buffer)) - recvpkt = tftp_factory.parse(buffer) # Forge a session key based on the client's IP and port, # which should safely work through NAT. key = "%s:%s" % (raddress, rport) diff --git a/tftpy/TftpStates.py b/tftpy/TftpStates.py index 1e903e7..716220a 100644 --- a/tftpy/TftpStates.py +++ b/tftpy/TftpStates.py @@ -423,7 +423,7 @@ class TftpStateSentWRQ(TftpState): log.info("Received OACK from server") try: self.handleOACK(pkt) - except TftpException, err: + except TftpException: log.error("Failed to negotiate options") self.sendError(TftpErrors.FailedNegotiation) raise