1+ # coding: utf-8
12# vim: ts=4 sw=4 et ai:
3+ from __future__ import print_function , unicode_literals
4+
25"""This module implements all state handling during uploads and downloads, the
36main interface to which being the TftpState base class.
47
2528###############################################################################
2629
2730
28- class TftpState :
31+ class TftpState ( object ) :
2932 """The base class for the states."""
3033
3134 def __init__ (self , context ):
@@ -48,7 +51,7 @@ def handleOACK(self, pkt):
4851 # Set options to OACK options
4952 self .context .options = pkt .options
5053 for key in self .context .options :
51- log .info (f " { key } = { self .context .options [key ]} " )
54+ log .info (" %s = %s" , key , self .context .options [key ])
5255 else :
5356 log .error ("Failed to negotiate options" )
5457 raise TftpException ("Failed to negotiate options" )
@@ -168,7 +171,7 @@ def sendOACK(self):
168171 def resendLast (self ):
169172 """Resend the last sent packet due to a timeout."""
170173 assert ( self .context .last_pkt is not None )
171- log .warning (f "Resending packet { self .context .last_pkt } on sessions { self } " )
174+ log .warning ("Resending packet %s on sessions %s" , self .context .last_pkt , self )
172175 self .context .metrics .resent_bytes += len (self .context .last_pkt .buffer )
173176 self .context .metrics .add_dup (self .context .last_pkt )
174177 sendto_port = self .context .tidport
@@ -335,7 +338,7 @@ def handle(self, pkt, raddress, rport):
335338 else :
336339 log .warning ("File not found: %s" , path )
337340 self .sendError (TftpErrors .FileNotFound )
338- raise TftpException (f "File not found: { path } " )
341+ raise TftpException ("File not found: %s" % ( path ,) )
339342
340343 # Options negotiation.
341344 if sendoack and "tsize" in self .context .options :
@@ -630,7 +633,7 @@ def handle(self, pkt, raddress, rport):
630633 if pkt .errorcode == TftpErrors .FileNotFound :
631634 raise TftpFileNotFoundError ("File not found" )
632635 else :
633- raise TftpException (f "Received ERR from server: { pkt } " )
636+ raise TftpException ("Received ERR from server: %s" % ( pkt ,) )
634637
635638 else :
636639 self .sendError (TftpErrors .IllegalTftpOp )
0 commit comments