diff options
Diffstat (limited to 'Demo')
-rwxr-xr-x | Demo/pdist/cmptree.py | 5 | ||||
-rwxr-xr-x | Demo/pdist/mac.py | 11 | ||||
-rwxr-xr-x | Demo/pdist/rcvs.py | 7 | ||||
-rwxr-xr-x | Demo/pdist/sumtree.py | 5 | ||||
-rwxr-xr-x | Demo/scripts/unbirthday.py | 5 | ||||
-rwxr-xr-x | Demo/sockets/ftp.py | 8 | ||||
-rwxr-xr-x | Demo/sockets/gopher.py | 26 | ||||
-rwxr-xr-x | Demo/tkinter/guido/wish.py | 5 |
8 files changed, 51 insertions, 21 deletions
diff --git a/Demo/pdist/cmptree.py b/Demo/pdist/cmptree.py index f6c611f..fa06f5f 100755 --- a/Demo/pdist/cmptree.py +++ b/Demo/pdist/cmptree.py @@ -6,6 +6,11 @@ import FSProxy import time import os +def raw_input(prompt): + sys.stdout.write(prompt) + sys.stdout.flush() + return sys.stdin.readline() + def main(): pwd = os.getcwd() s = raw_input("chdir [%s] " % pwd) diff --git a/Demo/pdist/mac.py b/Demo/pdist/mac.py index 107113c..61cff09 100755 --- a/Demo/pdist/mac.py +++ b/Demo/pdist/mac.py @@ -1,14 +1,18 @@ import sys -import string import rcvs +def raw_input(prompt): + sys.stdout.write(prompt) + sys.stdout.flush() + return sys.stdin.readline() + def main(): while 1: try: line = raw_input('$ ') except EOFError: break - words = string.split(line) + words = line.split() if not words: continue if words[0] != 'rcvs': @@ -16,4 +20,5 @@ def main(): sys.argv = words rcvs.main() -main() +if __name__ == '__main__': + main() diff --git a/Demo/pdist/rcvs.py b/Demo/pdist/rcvs.py index 8b8bae6..ab1fd87 100755 --- a/Demo/pdist/rcvs.py +++ b/Demo/pdist/rcvs.py @@ -35,7 +35,6 @@ from cvslib import CVS, File import md5 import os -import string import sys from cmdfw import CommandFrameWork @@ -269,13 +268,13 @@ class RCVS(CVS): def mailinfo(self, files, message = ""): towhom = "sjoerd@cwi.nl, jack@cwi.nl" # XXX - mailtext = MAILFORM % (towhom, string.join(files), - string.join(files), message) + mailtext = MAILFORM % (towhom, ' '.join(files), + ' '.join(files), message) print '-'*70 print mailtext print '-'*70 ok = raw_input("OK to mail to %s? " % towhom) - if string.lower(string.strip(ok)) in ('y', 'ye', 'yes'): + if ok.lower().strip() in ('y', 'ye', 'yes'): p = os.popen(SENDMAIL, "w") p.write(mailtext) sts = p.close() diff --git a/Demo/pdist/sumtree.py b/Demo/pdist/sumtree.py index 9291a56..68224df 100755 --- a/Demo/pdist/sumtree.py +++ b/Demo/pdist/sumtree.py @@ -1,4 +1,5 @@ import time +import sys import FSProxy def main(): @@ -9,7 +10,9 @@ def main(): proxy._close() t2 = time.time() print t2-t1, "seconds" - raw_input("[Return to exit] ") + sys.stdout.write("[Return to exit] ") + sys.stdout.flush() + sys.stdin.readline() def sumtree(proxy): print "PWD =", proxy.pwd() diff --git a/Demo/scripts/unbirthday.py b/Demo/scripts/unbirthday.py index 2d0b8e5..94ad448 100755 --- a/Demo/scripts/unbirthday.py +++ b/Demo/scripts/unbirthday.py @@ -9,6 +9,11 @@ import sys import time import calendar +def raw_input(prompt): + sys.stdout.write(prompt) + sys.stdout.flush() + return sys.stdin.readline() + def main(): # Note that the range checks below also check for bad types, # e.g. 3.14 or (). However syntactically invalid replies diff --git a/Demo/sockets/ftp.py b/Demo/sockets/ftp.py index 6e9282a..eed45be 100755 --- a/Demo/sockets/ftp.py +++ b/Demo/sockets/ftp.py @@ -130,6 +130,11 @@ def getdata(r): sys.stdout.write(data) print '(end of data connection)' +def raw_input(prompt): + sys.stdout.write(prompt) + sys.stdout.flush() + return sys.stdin.readline() + # Get a command from the user. # def getcommand(): @@ -143,4 +148,5 @@ def getcommand(): # Call the main program. # -main() +if __name__ == '__main__': + main() diff --git a/Demo/sockets/gopher.py b/Demo/sockets/gopher.py index 34bcdf0..2488c81 100755 --- a/Demo/sockets/gopher.py +++ b/Demo/sockets/gopher.py @@ -4,7 +4,6 @@ # # Usage: gopher [ [selector] host [port] ] -import string import sys import os import socket @@ -42,7 +41,7 @@ def open_socket(host, port): if not port: port = DEF_PORT elif type(port) == type(''): - port = string.atoi(port) + port = int(port) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, port)) return s @@ -73,7 +72,7 @@ def get_menu(selector, host, port): print '(Empty line from server)' continue typechar = line[0] - parts = string.splitfields(line[1:], TAB) + parts = line[1:].split(TAB) if len(parts) < 4: print '(Bad line from server: %r)' % (line,) continue @@ -160,7 +159,7 @@ def browse_menu(selector, host, port): for i in range(len(list)): item = list[i] typechar, description = item[0], item[1] - print string.rjust(repr(i+1), 3) + ':', description, + print repr(i+1).rjust(3) + ':', description, if typename.has_key(typechar): print typename[typechar] else: @@ -175,8 +174,8 @@ def browse_menu(selector, host, port): if not str: return try: - choice = string.atoi(str) - except string.atoi_error: + choice = int(str) + except ValueError: print 'Choice must be a number; try again:' continue if not 0 < choice <= len(list): @@ -218,6 +217,11 @@ def browse_textfile(selector, host, port): print 'IOError:', msg x.close() +def raw_input(prompt): + sys.stdout.write(prompt) + sys.stdout.flush() + return sys.stdin.readline() + # Browse a search index def browse_search(selector, host, port): while 1: @@ -230,7 +234,7 @@ def browse_search(selector, host, port): except EOFError: print break - query = string.strip(query) + query = query.strip() if not query: break if '\t' in query: @@ -300,11 +304,11 @@ def open_savefile(): except EOFError: print return None - savefile = string.strip(savefile) + savefile = savefile.strip() if not savefile: return None if savefile[0] == '|': - cmd = string.strip(savefile[1:]) + cmd = savefile[1:].strip() try: p = os.popen(cmd, 'w') except IOError, msg: @@ -331,10 +335,10 @@ def test(): browser(sys.argv[1], sys.argv[2], sys.argv[3]) elif sys.argv[2:]: try: - port = string.atoi(sys.argv[2]) + port = int(sys.argv[2]) selector = '' host = sys.argv[1] - except string.atoi_error: + except ValueError: selector = sys.argv[1] host = sys.argv[2] port = '' diff --git a/Demo/tkinter/guido/wish.py b/Demo/tkinter/guido/wish.py index 0a61ad8..35e012c 100755 --- a/Demo/tkinter/guido/wish.py +++ b/Demo/tkinter/guido/wish.py @@ -2,6 +2,7 @@ import _tkinter import os +import sys tk = _tkinter.create(os.environ['DISPLAY'], 'wish', 'Tk', 1) tk.call('update') @@ -12,7 +13,9 @@ while 1: if cmd: prompt = '' else: prompt = '% ' try: - line = raw_input(prompt) + sys.stdout.write(prompt) + sys.stdout.flush() + line = sys.stdin.readline() except EOFError: break cmd = cmd + (line + '\n') |