diff --git a/bin/tftpy_client.py b/bin/tftpy_client.py index ce395cc..4671f6f 100755 --- a/bin/tftpy_client.py +++ b/bin/tftpy_client.py @@ -87,18 +87,22 @@ def main(): tclient = tftpy.TftpClient(options.host, int(options.port), tftp_options) - if(options.filename): - if not options.output: - options.output = os.path.basename(options.filename) - tclient.download(options.filename, - options.output, - progresshook) - elif(options.upload): - if not options.input: - options.input = os.path.basename(options.upload) - tclient.upload(options.upload, - options.input, - progresshook) + try: + if options.filename: + if not options.output: + options.output = os.path.basename(options.filename) + tclient.download(options.filename, + options.output, + progresshook) + elif options.upload: + if not options.input: + options.input = os.path.basename(options.upload) + tclient.upload(options.upload, + options.input, + progresshook) + except tftpy.TftpException, err: + sys.stderr.write("%s\n" % str(err)) + sys.exit(1) if __name__ == '__main__': main() diff --git a/tftpy/TftpClient.py b/tftpy/TftpClient.py index 0935c61..a840689 100644 --- a/tftpy/TftpClient.py +++ b/tftpy/TftpClient.py @@ -119,6 +119,12 @@ class TftpClient(TftpSession): if isinstance(recvpkt, TftpPacketDAT): logger.debug("recvpkt.blocknumber = %d" % recvpkt.blocknumber) logger.debug("curblock = %d" % curblock) + + if self.state.state == 'rrq' and self.options: + logger.info("no OACK, our options were ignored") + self.options = { 'blksize': DEF_BLKSIZE } + self.state.state = 'ack' + expected_block = curblock + 1 if expected_block > 65535: logger.debug("block number rollover to 0 again")