msoulier / tftpy

Pure Python TFTP library
http://tftpy.sf.net
MIT License
172 stars 120 forks source link

TftpContext() #138

Closed JarrettNobles closed 1 year ago

JarrettNobles commented 1 year ago

Set the TFTP server address and filename

(this is an example IP not the actual one) tftp_server = "192.168.1.1" filename = "block.txt"

Create a TftpClient object

client = tftpy.TftpClient(tftp_server, 69)

Set the transfer mode to octet mode

transfer_mode = tftpy.TftpContext() transfer_mode.set_blksize(512) transfer_mode.set_timeout(5)

Upload the file using octet mode

client.upload(filename, filename, transfer_mode)

I am getting an error and a warning: The warning says that it cannot find the TftpContext in init.py in the library, The error I am getting is: AttributeError: module 'tftpy' has no attribute 'TftpContext'. I have tried to uninstall and reinstall the library but it is not seeing TftpContext method in the TftpContexts file. I even tried to import it directly "from tftpy.TftpContexts import TftpContext" but I was wondering if this was an error in the library? Thanks!

JarrettNobles commented 1 year ago

It was a possible syntax error, I had to change a line of code for it to work: transfer_mode = tftpy.TftpContexts.TftpContext(tftp_server, 69, timeout=5)