mirror of https://github.com/python/cpython.git
*** empty log message ***
This commit is contained in:
parent
9e80d6f125
commit
d55f4d1a76
|
@ -200,7 +200,7 @@ def browse_textfile(selector, host, port):
|
||||||
x = None
|
x = None
|
||||||
try:
|
try:
|
||||||
p = os.popen('${PAGER-more}', 'w')
|
p = os.popen('${PAGER-more}', 'w')
|
||||||
x = SaveLines().init(p)
|
x = SaveLines(p)
|
||||||
get_alt_textfile(selector, host, port, x.writeln)
|
get_alt_textfile(selector, host, port, x.writeln)
|
||||||
except IOError, msg:
|
except IOError, msg:
|
||||||
print 'IOError:', msg
|
print 'IOError:', msg
|
||||||
|
@ -209,7 +209,7 @@ def browse_textfile(selector, host, port):
|
||||||
f = open_savefile()
|
f = open_savefile()
|
||||||
if not f:
|
if not f:
|
||||||
return
|
return
|
||||||
x = SaveLines().init(f)
|
x = SaveLines(f)
|
||||||
try:
|
try:
|
||||||
get_alt_textfile(selector, host, port, x.writeln)
|
get_alt_textfile(selector, host, port, x.writeln)
|
||||||
print 'Done.'
|
print 'Done.'
|
||||||
|
@ -252,7 +252,7 @@ def browse_binary(selector, host, port):
|
||||||
f = open_savefile()
|
f = open_savefile()
|
||||||
if not f:
|
if not f:
|
||||||
return
|
return
|
||||||
x = SaveWithProgress().init(f)
|
x = SaveWithProgress(f)
|
||||||
get_alt_binary(selector, host, port, x.write, 8*1024)
|
get_alt_binary(selector, host, port, x.write, 8*1024)
|
||||||
x.close()
|
x.close()
|
||||||
|
|
||||||
|
@ -268,9 +268,8 @@ def browse_sound(selector, host, port):
|
||||||
|
|
||||||
# Class used to save lines, appending a newline to each line
|
# Class used to save lines, appending a newline to each line
|
||||||
class SaveLines:
|
class SaveLines:
|
||||||
def init(self, f):
|
def __init__(self, f):
|
||||||
self.f = f
|
self.f = f
|
||||||
return self
|
|
||||||
def writeln(self, line):
|
def writeln(self, line):
|
||||||
self.f.write(line + '\n')
|
self.f.write(line + '\n')
|
||||||
def close(self):
|
def close(self):
|
||||||
|
@ -280,9 +279,8 @@ def close(self):
|
||||||
|
|
||||||
# Class used to save data while showing progress
|
# Class used to save data while showing progress
|
||||||
class SaveWithProgress:
|
class SaveWithProgress:
|
||||||
def init(self, f):
|
def __init__(self, f):
|
||||||
self.f = f
|
self.f = f
|
||||||
return self
|
|
||||||
def write(self, data):
|
def write(self, data):
|
||||||
sys.stdout.write('#')
|
sys.stdout.write('#')
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
|
@ -9,5 +9,6 @@
|
||||||
s.bind('', MYPORT)
|
s.bind('', MYPORT)
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
data = s.recv(1500)
|
data, wherefrom = s.recvfrom(1500, 0)
|
||||||
|
sys.stderr.write(`wherefrom` + '\n')
|
||||||
sys.stdout.write(data)
|
sys.stdout.write(data)
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
# Global variables
|
# Global variables
|
||||||
|
|
||||||
class struct(): pass # Class to define featureless structures
|
class struct: pass # Class to define featureless structures
|
||||||
|
|
||||||
G = struct() # oHlds writable global variables
|
G = struct() # oHlds writable global variables
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,8 @@ def main():
|
||||||
mainloop.register(win)
|
mainloop.register(win)
|
||||||
mainloop.mainloop()
|
mainloop.mainloop()
|
||||||
|
|
||||||
def lpdispatch(type, win, detail):
|
def lpdispatch(event):
|
||||||
|
type, win, detail = event
|
||||||
if type == WE_CLOSE or type == WE_CHAR and detail in ('q', 'Q'):
|
if type == WE_CLOSE or type == WE_CHAR and detail in ('q', 'Q'):
|
||||||
mainloop.unregister(win)
|
mainloop.unregister(win)
|
||||||
elif type == WE_DRAW:
|
elif type == WE_DRAW:
|
||||||
|
|
|
@ -375,7 +375,7 @@ def do_exec(win):
|
||||||
save_stdout = sys.stdout
|
save_stdout = sys.stdout
|
||||||
save_stderr = sys.stderr
|
save_stderr = sys.stderr
|
||||||
try:
|
try:
|
||||||
sys.stdin = sys.stdout = sys.stderr = IOWindow().init(win)
|
sys.stdin = sys.stdout = sys.stderr = IOWindow(win)
|
||||||
win.busy = 1
|
win.busy = 1
|
||||||
try:
|
try:
|
||||||
exec(command, win.globals)
|
exec(command, win.globals)
|
||||||
|
@ -404,9 +404,8 @@ def do_exec(win):
|
||||||
#
|
#
|
||||||
class IOWindow:
|
class IOWindow:
|
||||||
#
|
#
|
||||||
def init(self, win):
|
def __init__(self, win):
|
||||||
self.win = win
|
self.win = win
|
||||||
return self
|
|
||||||
#
|
#
|
||||||
def readline(self, *unused_args):
|
def readline(self, *unused_args):
|
||||||
n = len(inputwindows)
|
n = len(inputwindows)
|
||||||
|
|
Loading…
Reference in New Issue