1
+ # coding: utf-8
1
2
# vim: ts=4 sw=4 et ai:
3
+ from __future__ import print_function , unicode_literals
4
+
2
5
"""This module implements all state handling during uploads and downloads, the
3
6
main interface to which being the TftpState base class.
4
7
25
28
###############################################################################
26
29
27
30
28
- class TftpState :
31
+ class TftpState ( object ) :
29
32
"""The base class for the states."""
30
33
31
34
def __init__ (self , context ):
@@ -48,7 +51,7 @@ def handleOACK(self, pkt):
48
51
# Set options to OACK options
49
52
self .context .options = pkt .options
50
53
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 ])
52
55
else :
53
56
log .error ("Failed to negotiate options" )
54
57
raise TftpException ("Failed to negotiate options" )
@@ -168,7 +171,7 @@ def sendOACK(self):
168
171
def resendLast (self ):
169
172
"""Resend the last sent packet due to a timeout."""
170
173
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 )
172
175
self .context .metrics .resent_bytes += len (self .context .last_pkt .buffer )
173
176
self .context .metrics .add_dup (self .context .last_pkt )
174
177
sendto_port = self .context .tidport
@@ -335,7 +338,7 @@ def handle(self, pkt, raddress, rport):
335
338
else :
336
339
log .warning ("File not found: %s" , path )
337
340
self .sendError (TftpErrors .FileNotFound )
338
- raise TftpException (f "File not found: { path } " )
341
+ raise TftpException ("File not found: %s" % ( path ,) )
339
342
340
343
# Options negotiation.
341
344
if sendoack and "tsize" in self .context .options :
@@ -630,7 +633,7 @@ def handle(self, pkt, raddress, rport):
630
633
if pkt .errorcode == TftpErrors .FileNotFound :
631
634
raise TftpFileNotFoundError ("File not found" )
632
635
else :
633
- raise TftpException (f "Received ERR from server: { pkt } " )
636
+ raise TftpException ("Received ERR from server: %s" % ( pkt ,) )
634
637
635
638
else :
636
639
self .sendError (TftpErrors .IllegalTftpOp )
0 commit comments