Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def tftpassert(condition, msg):
"""This function is a simple utility that will check the condition
passed for a false state. If it finds one, it throws a TftpException
with the message passed. This just makes the code throughout cleaner
by refactoring."""
if not condition:
raise TftpException(msg)
UnknownTID = 5
FileAlreadyExists = 6
NoSuchUser = 7
FailedNegotiation = 8
class TftpException(Exception):
"""This class is the parent class of all exceptions regarding the handling
of the TFTP protocol."""
pass
class TftpTimeout(TftpException):
"""This class represents a timeout error waiting for a response from the
other end."""
pass
class TftpFileNotFoundError(TftpException):
"""This class represents an error condition where we received a file
not found error."""
pass
NotDefined = 0
FileNotFound = 1
AccessViolation = 2
DiskFull = 3
IllegalTftpOp = 4
UnknownTID = 5
FileAlreadyExists = 6
NoSuchUser = 7
FailedNegotiation = 8
class TftpException(Exception):
"""This class is the parent class of all exceptions regarding the handling
of the TFTP protocol."""
pass
class TftpTimeout(TftpException):
"""This class represents a timeout error waiting for a response from the
other end."""
pass
class TftpFileNotFoundError(TftpException):
"""This class represents an error condition where we received a file
not found error."""
pass
UnknownTID = 5
FileAlreadyExists = 6
NoSuchUser = 7
FailedNegotiation = 8
class TftpException(Exception):
"""This class is the parent class of all exceptions regarding the handling
of the TFTP protocol."""
pass
class TftpTimeout(TftpException):
"""This class represents a timeout error waiting for a response from the
other end."""
pass
class TftpFileNotFoundError(TftpException):
"""This class represents an error condition where we received a file
not found error."""
pass
def start_tftp():
global tftpy
import tftpy
try:
tftpy.TftpContextServer.start = start # Overwrite the function
tftpy.TftpContextServer.end = end # Overwrite the function
tftpy.TftpStateExpectACK.sendDAT = sendDAT
except NameError:
pass
log("start_tftp: Starting Up TFTPy")
#tftpy.setLogLevel(logging.DEBUG)
try:
server = tftpy.TftpServer(config.running["tftproot"], dyn_file_func=interceptor)
except tftpy.TftpShared.TftpException:
log("start_tftp: ERROR: TFTP Root path doesn't exist. Creating...")
os.system('mkdir -p ' + config.running["tftproot"])
server = tftpy.TftpServer(config.running["tftproot"], dyn_file_func=interceptor)
server.listen(listenip="", listenport=69)
log("start_tftp: Started up successfully")
def tftpassert(condition, msg):
"""This function is a simple utility that will check the condition
passed for a false state. If it finds one, it throws a TftpException
with the message passed. This just makes the code throughout cleaner
by refactoring."""
if not condition:
raise TftpException(msg)
NotDefined = 0
FileNotFound = 1
AccessViolation = 2
DiskFull = 3
IllegalTftpOp = 4
UnknownTID = 5
FileAlreadyExists = 6
NoSuchUser = 7
FailedNegotiation = 8
class TftpException(Exception):
"""This class is the parent class of all exceptions regarding the handling
of the TFTP protocol."""
pass
class TftpTimeout(TftpException):
"""This class represents a timeout error waiting for a response from the
other end."""
pass
class TftpFileNotFoundError(TftpException):
"""This class represents an error condition where we received a file
not found error."""
pass