[pycopia] r738 committed - Add basic text file upload mothed. Zmodem doesn't always work.

3 views
Skip to first unread message

pyc...@googlecode.com

unread,
Aug 13, 2013, 9:49:06 PM8/13/13
to pyc...@googlegroups.com
Revision: 738
Author: keith.dart
Date: Tue Aug 13 18:48:53 2013
Log: Add basic text file upload mothed. Zmodem doesn't always work.

http://code.google.com/p/pycopia/source/detail?r=738

Modified:
/trunk/core/pycopia/inet/telnet.py

=======================================
--- /trunk/core/pycopia/inet/telnet.py Wed May 15 19:25:00 2013
+++ /trunk/core/pycopia/inet/telnet.py Tue Aug 13 18:48:53 2013
@@ -417,7 +417,7 @@
else:
raise TelnetError("Use of COM option when not negotiated.")

- def upload(self, filename):
+ def upload_zmodem(self, filename):
"""Call external ZMODEM program to upload a file.
Return an ExitStatus object that should indicate success or
failure.
"""
@@ -449,6 +449,16 @@
es.output = errout
return es

+ def upload(self, filename):
+ """Basic upload using cat.
+ """
+ text = open(filename).read()
+ sockfd = self.sock.fileno()
+ os.write(sockfd, "cat - > {}\r".format(os.path.basename(filename)))
+ os.write(sockfd, text)
+ os.write(sockfd, "\r" + chr(4))
+ return ExitStatus("cat", 0) # fake exitstatus to be compatible
with upload_zmodem.
+
# asyncio interface TODO
def readable(self):
return True
Reply all
Reply to author
Forward
0 new messages