Commit e6ddc8b2 authored by Tim Peters's avatar Tim Peters

Whitespace normalization. Ran reindent.py over the entire source tree.

parent 4fba4521
This diff is collapsed.
......@@ -209,7 +209,7 @@ def demo_panels(win):
w5.addstr(mod[itmp])
pflush()
wait_a_while()
saywhat("m5; press any key to continue")
w4.move(curses.LINES / 6, 1)
w4.addstr(mod[itmp])
......@@ -218,7 +218,7 @@ def demo_panels(win):
w5.addstr(mod[itmp])
pflush()
wait_a_while()
saywhat("m4; press any key to continue")
p4.move(curses.LINES / 6, (itmp + 1) * curses.COLS / 8)
pflush()
......
......@@ -27,18 +27,18 @@ def main(win):
# Initialize it globally for convenience.
global stdscr
stdscr = win
if curses.has_colors():
bg = curses.COLOR_BLACK
curses.init_pair(1, curses.COLOR_BLUE, bg)
curses.init_pair(2, curses.COLOR_CYAN, bg)
curses.nl()
curses.noecho()
# XXX curs_set() always returns ERR
# curses.curs_set(0)
stdscr.timeout(0)
c = curses.COLS - 4
r = curses.LINES - 4
xpos = [0] * c
......@@ -46,38 +46,38 @@ def main(win):
for j in range(4, -1, -1):
xpos[j] = randrange(0, c) + 2
ypos[j] = randrange(0, r) + 2
j = 0
while 1:
x = randrange(0, c) + 2
y = randrange(0, r) + 2
stdscr.addch(y, x, ord('.'))
stdscr.addch(ypos[j], xpos[j], ord('o'))
j = next_j(j)
stdscr.addch(ypos[j], xpos[j], ord('O'))
j = next_j(j)
stdscr.addch( ypos[j] - 1, xpos[j], ord('-'))
stdscr.addstr(ypos[j], xpos[j] - 1, "|.|")
stdscr.addch( ypos[j] + 1, xpos[j], ord('-'))
j = next_j(j)
stdscr.addch( ypos[j] - 2, xpos[j], ord('-'))
stdscr.addstr(ypos[j] - 1, xpos[j] - 1, "/ \\")
stdscr.addstr(ypos[j], xpos[j] - 2, "| O |")
stdscr.addstr(ypos[j] + 1, xpos[j] - 1, "\\ /")
stdscr.addch( ypos[j] + 2, xpos[j], ord('-'))
j = next_j(j)
stdscr.addch( ypos[j] - 2, xpos[j], ord(' '))
stdscr.addstr(ypos[j] - 1, xpos[j] - 1, " ")
stdscr.addstr(ypos[j], xpos[j] - 2, " ")
stdscr.addstr(ypos[j] + 1, xpos[j] - 1, " ")
stdscr.addch( ypos[j] + 2, xpos[j], ord(' '))
xpos[j] = x
ypos[j] = y
......@@ -90,5 +90,5 @@ def main(win):
stdscr.nodelay(1)
curses.napms(50)
curses.wrapper(main)
......@@ -66,7 +66,7 @@ def dline(pair, from_x, from_y, x2, y2, ch):
def main(win):
global stdscr
stdscr = win
lastbeep = -1
my_bg = curses.COLOR_BLACK
......@@ -80,7 +80,7 @@ def main(win):
cx = (curses.COLS - 1) / 2
cy = curses.LINES / 2
ch = min( cy-1, int(cx / ASPECT) - 1)
ch = min( cy-1, int(cx / ASPECT) - 1)
mradius = (3 * ch) / 4
hradius = ch / 2
sradius = 5 * ch / 6
......@@ -95,7 +95,7 @@ def main(win):
"ASCII Clock by Howard Jones <ha.jones@ic.ac.uk>, 1994")
sradius = max(sradius-4, 8)
while 1:
curses.napms(1000)
......@@ -125,7 +125,7 @@ def main(win):
stdscr.attrset(curses.color_pair(1))
plot(cx + sdx, cy - sdy, ord('O'))
if curses.has_colors():
stdscr.attrset(curses.color_pair(0))
......
This diff is collapsed.
......@@ -6,8 +6,8 @@ def MDPrint(str):
outstr = ''
for i in str:
o = ord(i)
outstr = (outstr
+ string.hexdigits[(o >> 4) & 0xF]
outstr = (outstr
+ string.hexdigits[(o >> 4) & 0xF]
+ string.hexdigits[o & 0xF])
print outstr,
......@@ -97,8 +97,8 @@ def MDTestSuite():
MDString('abc')
MDString('message digest')
MDString(makestr(ord('a'), ord('z')))
MDString(makestr(ord('A'), ord('Z'))
+ makestr(ord('a'), ord('z'))
MDString(makestr(ord('A'), ord('Z'))
+ makestr(ord('a'), ord('z'))
+ makestr(ord('0'), ord('9')))
MDString((makestr(ord('1'), ord('9')) + '0') * 8)
......
......@@ -87,7 +87,7 @@ class EiffelMethodWrapper(MetaMethodWrapper):
if self.post:
apply(self.post, (Result,) + args, kw)
return Result
class EiffelHelper(MetaHelper):
__methodwrapper__ = EiffelMethodWrapper
......
......@@ -88,7 +88,7 @@ class MetaClass:
init = lambda: None
apply(init, args, kw)
return inst
Meta = MetaClass('Meta', (), {})
......@@ -116,5 +116,3 @@ def _test():
if __name__ == '__main__':
_test()
......@@ -125,7 +125,7 @@ def _testLock():
lock.release()
lock.acquire()
thread.start_new_thread(f1, (lock,)) # Adds 2
thread.start_new_thread(f1, (lock, f1)) # Adds 3
thread.start_new_thread(f2, (lock,)) # Adds 1
......
......@@ -142,4 +142,3 @@ def _test():
if __name__ == '__main__':
_test()
......@@ -48,7 +48,7 @@ class EiffelMetaClass1(EiffelBaseMetaClass):
method.__doc__ = func.__doc__
return method
make_eiffel_method = staticmethod(make_eiffel_method)
class EiffelMethodWrapper:
......@@ -66,7 +66,7 @@ class EiffelDescriptor(object):
self._func = func
self._pre = pre
self._post = post
self.__name__ = func.__name__
self.__doc__ = func.__doc__
......@@ -141,4 +141,3 @@ def _test(metaclass):
if __name__ == "__main__":
_test(EiffelMetaClass1)
_test(EiffelMetaClass2)
......@@ -175,4 +175,3 @@ def _test2():
if __name__ == '__main__':
_test()
_test2()
This diff is collapsed.
......@@ -12,118 +12,118 @@ VERBOSE = 1
class Client:
"""RPC Client class. No need to derive a class -- it's fully generic."""
def __init__(self, address, verbose = VERBOSE):
self._pre_init(address, verbose)
self._post_init()
def _pre_init(self, address, verbose = VERBOSE):
if type(address) == type(0):
address = ('', address)
self._address = address
self._verbose = verbose
if self._verbose: print "Connecting to %s ..." % repr(address)
self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._socket.connect(address)
if self._verbose: print "Connected."
self._lastid = 0 # Last id for which a reply has been received
self._nextid = 1 # Id of next request
self._replies = {} # Unprocessed replies
self._rf = self._socket.makefile('r')
self._wf = self._socket.makefile('w')
def _post_init(self):
self._methods = self._call('.methods')
def __del__(self):
self._close()
def _close(self):
if self._rf: self._rf.close()
self._rf = None
if self._wf: self._wf.close()
self._wf = None
if self._socket: self._socket.close()
self._socket = None
def __getattr__(self, name):
if name in self._methods:
method = _stub(self, name)
setattr(self, name, method) # XXX circular reference
return method
raise AttributeError, name
def _setverbose(self, verbose):
self._verbose = verbose
def _call(self, name, *args):
return self._vcall(name, args)
def _vcall(self, name, args):
return self._recv(self._vsend(name, args))
def _send(self, name, *args):
return self._vsend(name, args)
def _send_noreply(self, name, *args):
return self._vsend(name, args, 0)
def _vsend_noreply(self, name, args):
return self._vsend(name, args, 0)
def _vsend(self, name, args, wantreply = 1):
id = self._nextid
self._nextid = id+1
if not wantreply: id = -id
request = (name, args, id)
if self._verbose > 1: print "sending request: %s" % repr(request)
wp = pickle.Pickler(self._wf)
wp.dump(request)
return id
def _recv(self, id):
exception, value, rid = self._vrecv(id)
if rid != id:
raise RuntimeError, "request/reply id mismatch: %d/%d" % (id, rid)
if exception is None:
return value
x = exception
if hasattr(__builtin__, exception):
x = getattr(__builtin__, exception)
elif exception in ('posix.error', 'mac.error'):
x = os.error
if x == exception:
exception = x
raise exception, value
def _vrecv(self, id):
self._flush()
if self._replies.has_key(id):
if self._verbose > 1: print "retrieving previous reply, id = %d" % id
reply = self._replies[id]
del self._replies[id]
return reply
aid = abs(id)
while 1:
if self._verbose > 1: print "waiting for reply, id = %d" % id
rp = pickle.Unpickler(self._rf)
reply = rp.load()
del rp
if self._verbose > 1: print "got reply: %s" % repr(reply)
rid = reply[2]
arid = abs(rid)
if arid == aid:
if self._verbose > 1: print "got it"
return reply
self._replies[rid] = reply
if arid > aid:
if self._verbose > 1: print "got higher id, assume all ok"
return (None, None, id)
def _flush(self):
self._wf.flush()
"""RPC Client class. No need to derive a class -- it's fully generic."""
def __init__(self, address, verbose = VERBOSE):
self._pre_init(address, verbose)
self._post_init()
def _pre_init(self, address, verbose = VERBOSE):
if type(address) == type(0):
address = ('', address)
self._address = address
self._verbose = verbose
if self._verbose: print "Connecting to %s ..." % repr(address)
self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._socket.connect(address)
if self._verbose: print "Connected."
self._lastid = 0 # Last id for which a reply has been received
self._nextid = 1 # Id of next request
self._replies = {} # Unprocessed replies
self._rf = self._socket.makefile('r')
self._wf = self._socket.makefile('w')
def _post_init(self):
self._methods = self._call('.methods')
def __del__(self):
self._close()
def _close(self):
if self._rf: self._rf.close()
self._rf = None
if self._wf: self._wf.close()
self._wf = None
if self._socket: self._socket.close()
self._socket = None
def __getattr__(self, name):
if name in self._methods:
method = _stub(self, name)
setattr(self, name, method) # XXX circular reference
return method
raise AttributeError, name
def _setverbose(self, verbose):
self._verbose = verbose
def _call(self, name, *args):
return self._vcall(name, args)
def _vcall(self, name, args):
return self._recv(self._vsend(name, args))
def _send(self, name, *args):
return self._vsend(name, args)
def _send_noreply(self, name, *args):
return self._vsend(name, args, 0)
def _vsend_noreply(self, name, args):
return self._vsend(name, args, 0)
def _vsend(self, name, args, wantreply = 1):
id = self._nextid
self._nextid = id+1
if not wantreply: id = -id
request = (name, args, id)
if self._verbose > 1: print "sending request: %s" % repr(request)
wp = pickle.Pickler(self._wf)
wp.dump(request)
return id
def _recv(self, id):
exception, value, rid = self._vrecv(id)
if rid != id:
raise RuntimeError, "request/reply id mismatch: %d/%d" % (id, rid)
if exception is None:
return value
x = exception
if hasattr(__builtin__, exception):
x = getattr(__builtin__, exception)
elif exception in ('posix.error', 'mac.error'):
x = os.error
if x == exception:
exception = x
raise exception, value
def _vrecv(self, id):
self._flush()
if self._replies.has_key(id):
if self._verbose > 1: print "retrieving previous reply, id = %d" % id
reply = self._replies[id]
del self._replies[id]
return reply
aid = abs(id)
while 1:
if self._verbose > 1: print "waiting for reply, id = %d" % id
rp = pickle.Unpickler(self._rf)
reply = rp.load()
del rp
if self._verbose > 1: print "got reply: %s" % repr(reply)
rid = reply[2]
arid = abs(rid)
if arid == aid:
if self._verbose > 1: print "got it"
return reply
self._replies[rid] = reply
if arid > aid:
if self._verbose > 1: print "got higher id, assume all ok"
return (None, None, id)
def _flush(self):
self._wf.flush()
from security import Security
......@@ -131,28 +131,27 @@ from security import Security
class SecureClient(Client, Security):
def __init__(self, *args):
import string
apply(self._pre_init, args)
Security.__init__(self)
self._wf.flush()
line = self._rf.readline()
challenge = string.atoi(string.strip(line))
response = self._encode_challenge(challenge)
line = repr(long(response))
if line[-1] in 'Ll': line = line[:-1]
self._wf.write(line + '\n')
self._wf.flush()
self._post_init()
def __init__(self, *args):
import string
apply(self._pre_init, args)
Security.__init__(self)
self._wf.flush()
line = self._rf.readline()
challenge = string.atoi(string.strip(line))
response = self._encode_challenge(challenge)
line = repr(long(response))
if line[-1] in 'Ll': line = line[:-1]
self._wf.write(line + '\n')
self._wf.flush()
self._post_init()
class _stub:
"""Helper class for Client -- each instance serves as a method of the client."""
def __init__(self, client, name):
self._client = client
self._name = name
def __call__(self, *args):
return self._client._vcall(self._name, args)
"""Helper class for Client -- each instance serves as a method of the client."""
def __init__(self, client, name):
self._client = client
self._name = name
def __call__(self, *args):
return self._client._vcall(self._name, args)
......@@ -3,142 +3,142 @@
class CommandFrameWork:
"""Framework class for command line interfaces like CVS.
The general command line structure is
command [flags] subcommand [subflags] [argument] ...
There's a class variable GlobalFlags which specifies the
global flags options. Subcommands are defined by defining
methods named do_<subcommand>. Flags for the subcommand are
defined by defining class or instance variables named
flags_<subcommand>. If there's no command, method default()
is called. The __doc__ strings for the do_ methods are used
for the usage message, printed after the general usage message
which is the class variable UsageMessage. The class variable
PostUsageMessage is printed after all the do_ methods' __doc__
strings. The method's return value can be a suggested exit
status. [XXX Need to rewrite this to clarify it.]
Common usage is to derive a class, instantiate it, and then call its
run() method; by default this takes its arguments from sys.argv[1:].
"""
UsageMessage = \
"usage: (name)s [flags] subcommand [subflags] [argument] ..."
PostUsageMessage = None
GlobalFlags = ''
def __init__(self):
"""Constructor, present for completeness."""
pass
def run(self, args = None):
"""Process flags, subcommand and options, then run it."""
import getopt, sys
if args is None: args = sys.argv[1:]
try:
opts, args = getopt.getopt(args, self.GlobalFlags)
except getopt.error, msg:
return self.usage(msg)
self.options(opts)
if not args:
self.ready()
return self.default()
else:
cmd = args[0]
mname = 'do_' + cmd
fname = 'flags_' + cmd
try:
method = getattr(self, mname)
except AttributeError:
return self.usage("command %r unknown" % (cmd,))
try:
flags = getattr(self, fname)
except AttributeError:
flags = ''
try:
opts, args = getopt.getopt(args[1:], flags)
except getopt.error, msg:
return self.usage(
"subcommand %s: " % cmd + str(msg))
self.ready()
return method(opts, args)
def options(self, opts):
"""Process the options retrieved by getopt.
Override this if you have any options."""
if opts:
print "-"*40
print "Options:"
for o, a in opts:
print 'option', o, 'value', repr(a)
print "-"*40
def ready(self):
"""Called just before calling the subcommand."""
pass
def usage(self, msg = None):
"""Print usage message. Return suitable exit code (2)."""
if msg: print msg
print self.UsageMessage % {'name': self.__class__.__name__}
docstrings = {}
c = self.__class__
while 1:
for name in dir(c):
if name[:3] == 'do_':
if docstrings.has_key(name):
continue
try:
doc = getattr(c, name).__doc__
except:
doc = None
if doc:
docstrings[name] = doc
if not c.__bases__:
break
c = c.__bases__[0]
if docstrings:
print "where subcommand can be:"
names = docstrings.keys()
names.sort()
for name in names:
print docstrings[name]
if self.PostUsageMessage:
print self.PostUsageMessage
return 2
def default(self):
"""Default method, called when no subcommand is given.
You should always override this."""
print "Nobody expects the Spanish Inquisition!"
"""Framework class for command line interfaces like CVS.
The general command line structure is
command [flags] subcommand [subflags] [argument] ...
There's a class variable GlobalFlags which specifies the
global flags options. Subcommands are defined by defining
methods named do_<subcommand>. Flags for the subcommand are
defined by defining class or instance variables named
flags_<subcommand>. If there's no command, method default()
is called. The __doc__ strings for the do_ methods are used
for the usage message, printed after the general usage message
which is the class variable UsageMessage. The class variable
PostUsageMessage is printed after all the do_ methods' __doc__
strings. The method's return value can be a suggested exit
status. [XXX Need to rewrite this to clarify it.]
Common usage is to derive a class, instantiate it, and then call its
run() method; by default this takes its arguments from sys.argv[1:].
"""
UsageMessage = \
"usage: (name)s [flags] subcommand [subflags] [argument] ..."
PostUsageMessage = None
GlobalFlags = ''
def __init__(self):
"""Constructor, present for completeness."""
pass
def run(self, args = None):
"""Process flags, subcommand and options, then run it."""
import getopt, sys
if args is None: args = sys.argv[1:]
try:
opts, args = getopt.getopt(args, self.GlobalFlags)
except getopt.error, msg:
return self.usage(msg)
self.options(opts)
if not args:
self.ready()
return self.default()
else:
cmd = args[0]
mname = 'do_' + cmd
fname = 'flags_' + cmd
try:
method = getattr(self, mname)
except AttributeError:
return self.usage("command %r unknown" % (cmd,))
try:
flags = getattr(self, fname)
except AttributeError:
flags = ''
try:
opts, args = getopt.getopt(args[1:], flags)
except getopt.error, msg:
return self.usage(
"subcommand %s: " % cmd + str(msg))
self.ready()
return method(opts, args)
def options(self, opts):
"""Process the options retrieved by getopt.
Override this if you have any options."""
if opts:
print "-"*40
print "Options:"
for o, a in opts:
print 'option', o, 'value', repr(a)
print "-"*40
def ready(self):
"""Called just before calling the subcommand."""
pass
def usage(self, msg = None):
"""Print usage message. Return suitable exit code (2)."""
if msg: print msg
print self.UsageMessage % {'name': self.__class__.__name__}
docstrings = {}
c = self.__class__
while 1:
for name in dir(c):
if name[:3] == 'do_':
if docstrings.has_key(name):
continue
try:
doc = getattr(c, name).__doc__
except:
doc = None
if doc:
docstrings[name] = doc
if not c.__bases__:
break
c = c.__bases__[0]
if docstrings:
print "where subcommand can be:"
names = docstrings.keys()
names.sort()
for name in names:
print docstrings[name]
if self.PostUsageMessage:
print self.PostUsageMessage
return 2
def default(self):
"""Default method, called when no subcommand is given.
You should always override this."""
print "Nobody expects the Spanish Inquisition!"
def test():
"""Test script -- called when this module is run as a script."""
import sys
class Hello(CommandFrameWork):
def do_hello(self, opts, args):
"hello -- print 'hello world', needs no arguments"
print "Hello, world"
x = Hello()
tests = [
[],
['hello'],
['spam'],
['-x'],
['hello', '-x'],
None,
]
for t in tests:
print '-'*10, t, '-'*10
sts = x.run(t)
print "Exit status:", repr(sts)
"""Test script -- called when this module is run as a script."""
import sys
class Hello(CommandFrameWork):
def do_hello(self, opts, args):
"hello -- print 'hello world', needs no arguments"
print "Hello, world"
x = Hello()
tests = [
[],
['hello'],
['spam'],
['-x'],
['hello', '-x'],
None,
]
for t in tests:
print '-'*10, t, '-'*10
sts = x.run(t)
print "Exit status:", repr(sts)
if __name__ == '__main__':
test()
test()
......@@ -7,202 +7,202 @@ import time
import os
def main():
pwd = os.getcwd()
s = raw_input("chdir [%s] " % pwd)
if s:
os.chdir(s)
pwd = os.getcwd()
host = ask("host", 'voorn.cwi.nl')
port = 4127
verbose = 1
mode = ''
print """\
pwd = os.getcwd()
s = raw_input("chdir [%s] " % pwd)
if s:
os.chdir(s)
pwd = os.getcwd()
host = ask("host", 'voorn.cwi.nl')
port = 4127
verbose = 1
mode = ''
print """\
Mode should be a string of characters, indicating what to do with differences.
r - read different files to local file system
w - write different files to remote file system
c - create new files, either remote or local
d - delete disappearing files, either remote or local
"""
s = raw_input("mode [%s] " % mode)
if s: mode = s
address = (host, port)
t1 = time.time()
local = FSProxy.FSProxyLocal()
remote = FSProxy.FSProxyClient(address, verbose)
compare(local, remote, mode)
remote._close()
local._close()
t2 = time.time()
dt = t2-t1
mins, secs = divmod(dt, 60)
print mins, "minutes and", round(secs), "seconds"
raw_input("[Return to exit] ")
s = raw_input("mode [%s] " % mode)
if s: mode = s
address = (host, port)
t1 = time.time()
local = FSProxy.FSProxyLocal()
remote = FSProxy.FSProxyClient(address, verbose)
compare(local, remote, mode)
remote._close()
local._close()
t2 = time.time()
dt = t2-t1
mins, secs = divmod(dt, 60)
print mins, "minutes and", round(secs), "seconds"
raw_input("[Return to exit] ")
def ask(prompt, default):
s = raw_input("%s [%s] " % (prompt, default))
return s or default
s = raw_input("%s [%s] " % (prompt, default))
return s or default
def askint(prompt, default):
s = raw_input("%s [%s] " % (prompt, str(default)))
if s: return string.atoi(s)
return default
s = raw_input("%s [%s] " % (prompt, str(default)))
if s: return string.atoi(s)
return default
def compare(local, remote, mode):
print
print "PWD =", repr(os.getcwd())
sums_id = remote._send('sumlist')
subdirs_id = remote._send('listsubdirs')
remote._flush()
print "calculating local sums ..."
lsumdict = {}
for name, info in local.sumlist():
lsumdict[name] = info
print "getting remote sums ..."
sums = remote._recv(sums_id)
print "got", len(sums)
rsumdict = {}
for name, rsum in sums:
rsumdict[name] = rsum
if not lsumdict.has_key(name):
print repr(name), "only remote"
if 'r' in mode and 'c' in mode:
recvfile(local, remote, name)
else:
lsum = lsumdict[name]
if lsum != rsum:
print repr(name),
rmtime = remote.mtime(name)
lmtime = local.mtime(name)
if rmtime > lmtime:
print "remote newer",
if 'r' in mode:
recvfile(local, remote, name)
elif lmtime > rmtime:
print "local newer",
if 'w' in mode:
sendfile(local, remote, name)
else:
print "same mtime but different sum?!?!",
print
for name in lsumdict.keys():
if not rsumdict.keys():
print repr(name), "only locally",
fl()
if 'w' in mode and 'c' in mode:
sendfile(local, remote, name)
elif 'r' in mode and 'd' in mode:
os.unlink(name)
print "removed."
print
print "gettin subdirs ..."
subdirs = remote._recv(subdirs_id)
common = []
for name in subdirs:
if local.isdir(name):
print "Common subdirectory", repr(name)
common.append(name)
else:
print "Remote subdirectory", repr(name), "not found locally"
if 'r' in mode and 'c' in mode:
pr = "Create local subdirectory %s? [y] " % \
repr(name)
if 'y' in mode:
ok = 'y'
else:
ok = ask(pr, "y")
if ok[:1] in ('y', 'Y'):
local.mkdir(name)
print "Subdirectory %s made" % \
repr(name)
common.append(name)
lsubdirs = local.listsubdirs()
for name in lsubdirs:
if name not in subdirs:
print "Local subdirectory", repr(name), "not found remotely"
for name in common:
print "Entering subdirectory", repr(name)
local.cd(name)
remote.cd(name)
compare(local, remote, mode)
remote.back()
local.back()
print
print "PWD =", repr(os.getcwd())
sums_id = remote._send('sumlist')
subdirs_id = remote._send('listsubdirs')
remote._flush()
print "calculating local sums ..."
lsumdict = {}
for name, info in local.sumlist():
lsumdict[name] = info
print "getting remote sums ..."
sums = remote._recv(sums_id)
print "got", len(sums)
rsumdict = {}
for name, rsum in sums:
rsumdict[name] = rsum
if not lsumdict.has_key(name):
print repr(name), "only remote"
if 'r' in mode and 'c' in mode:
recvfile(local, remote, name)
else:
lsum = lsumdict[name]
if lsum != rsum:
print repr(name),
rmtime = remote.mtime(name)
lmtime = local.mtime(name)
if rmtime > lmtime:
print "remote newer",
if 'r' in mode:
recvfile(local, remote, name)
elif lmtime > rmtime:
print "local newer",
if 'w' in mode:
sendfile(local, remote, name)
else:
print "same mtime but different sum?!?!",
print
for name in lsumdict.keys():
if not rsumdict.keys():
print repr(name), "only locally",
fl()
if 'w' in mode and 'c' in mode:
sendfile(local, remote, name)
elif 'r' in mode and 'd' in mode:
os.unlink(name)
print "removed."
print
print "gettin subdirs ..."
subdirs = remote._recv(subdirs_id)
common = []
for name in subdirs:
if local.isdir(name):
print "Common subdirectory", repr(name)
common.append(name)
else:
print "Remote subdirectory", repr(name), "not found locally"
if 'r' in mode and 'c' in mode:
pr = "Create local subdirectory %s? [y] " % \
repr(name)
if 'y' in mode:
ok = 'y'
else:
ok = ask(pr, "y")
if ok[:1] in ('y', 'Y'):
local.mkdir(name)
print "Subdirectory %s made" % \
repr(name)
common.append(name)
lsubdirs = local.listsubdirs()
for name in lsubdirs:
if name not in subdirs:
print "Local subdirectory", repr(name), "not found remotely"
for name in common:
print "Entering subdirectory", repr(name)
local.cd(name)
remote.cd(name)
compare(local, remote, mode)
remote.back()
local.back()
def sendfile(local, remote, name):
try:
remote.create(name)
except (IOError, os.error), msg:
print "cannot create:", msg
return
print "sending ...",
fl()
data = open(name).read()
t1 = time.time()
remote._send_noreply('write', name, data)
remote._flush()
t2 = time.time()
dt = t2-t1
print len(data), "bytes in", round(dt), "seconds",
if dt:
print "i.e.", round(len(data)/dt), "bytes/sec",
print
try:
remote.create(name)
except (IOError, os.error), msg:
print "cannot create:", msg
return
print "sending ...",
fl()
data = open(name).read()
t1 = time.time()
remote._send_noreply('write', name, data)
remote._flush()
t2 = time.time()
dt = t2-t1
print len(data), "bytes in", round(dt), "seconds",
if dt:
print "i.e.", round(len(data)/dt), "bytes/sec",
print
def recvfile(local, remote, name):
ok = 0
try:
rv = recvfile_real(local, remote, name)
ok = 1
return rv
finally:
if not ok:
print "*** recvfile of %r failed, deleting" % (name,)
local.delete(name)
ok = 0
try:
rv = recvfile_real(local, remote, name)
ok = 1
return rv
finally:
if not ok:
print "*** recvfile of %r failed, deleting" % (name,)
local.delete(name)
def recvfile_real(local, remote, name):
try:
local.create(name)
except (IOError, os.error), msg:
print "cannot create:", msg
return
print "receiving ...",
fl()
f = open(name, 'w')
t1 = time.time()
length = 4*1024
offset = 0
id = remote._send('read', name, offset, length)
remote._flush()
while 1:
newoffset = offset + length
newid = remote._send('read', name, newoffset, length)
data = remote._recv(id)
id = newid
if not data: break
f.seek(offset)
f.write(data)
offset = newoffset
size = f.tell()
t2 = time.time()
f.close()
dt = t2-t1
print size, "bytes in", round(dt), "seconds",
if dt:
print "i.e.", int(size/dt), "bytes/sec",
print
remote._recv(id) # ignored
try:
local.create(name)
except (IOError, os.error), msg:
print "cannot create:", msg
return
print "receiving ...",
fl()
f = open(name, 'w')
t1 = time.time()
length = 4*1024
offset = 0
id = remote._send('read', name, offset, length)
remote._flush()
while 1:
newoffset = offset + length
newid = remote._send('read', name, newoffset, length)
data = remote._recv(id)
id = newid
if not data: break
f.seek(offset)
f.write(data)
offset = newoffset
size = f.tell()
t2 = time.time()
f.close()
dt = t2-t1
print size, "bytes in", round(dt), "seconds",
if dt:
print "i.e.", int(size/dt), "bytes/sec",
print
remote._recv(id) # ignored
def fl():
sys.stdout.flush()
sys.stdout.flush()
if __name__ == '__main__':
main()
main()
This diff is collapsed.
......@@ -22,25 +22,25 @@ a write lock is held.
- To set a read lock:
- acquire the meta-lock
- create the file "#cvs.rfl.<pid>"
- release the meta-lock
- acquire the meta-lock
- create the file "#cvs.rfl.<pid>"
- release the meta-lock
- To set a write lock:
- acquire the meta-lock
- check that there are no files called "#cvs.rfl.*"
- if there are, release the meta-lock, sleep, try again
- create the file "#cvs.wfl.<pid>"
- acquire the meta-lock
- check that there are no files called "#cvs.rfl.*"
- if there are, release the meta-lock, sleep, try again
- create the file "#cvs.wfl.<pid>"
- To release a write lock:
- remove the file "#cvs.wfl.<pid>"
- rmdir the meta-lock
- remove the file "#cvs.wfl.<pid>"
- rmdir the meta-lock
- To release a read lock:
- remove the file "#cvs.rfl.<pid>"
- remove the file "#cvs.rfl.<pid>"
Additional notes
......@@ -93,188 +93,188 @@ CVSWFL = "#cvs.wfl."
class Error:
def __init__(self, msg):
self.msg = msg
def __init__(self, msg):
self.msg = msg
def __repr__(self):
return repr(self.msg)
def __repr__(self):
return repr(self.msg)
def __str__(self):
return str(self.msg)
def __str__(self):
return str(self.msg)
class Locked(Error):
pass
pass
class Lock:
def __init__(self, repository = ".", delay = DELAY):
self.repository = repository
self.delay = delay
self.lockdir = None
self.lockfile = None
pid = repr(os.getpid())
self.cvslck = self.join(CVSLCK)
self.cvsrfl = self.join(CVSRFL + pid)
self.cvswfl = self.join(CVSWFL + pid)
def __del__(self):
print "__del__"
self.unlock()
def setlockdir(self):
while 1:
try:
self.lockdir = self.cvslck
os.mkdir(self.cvslck, 0777)
return
except os.error, msg:
self.lockdir = None
if msg[0] == EEXIST:
try:
st = os.stat(self.cvslck)
except os.error:
continue
self.sleep(st)
continue
raise Error("failed to lock %s: %s" % (
self.repository, msg))
def unlock(self):
self.unlockfile()
self.unlockdir()
def unlockfile(self):
if self.lockfile:
print "unlink", self.lockfile
try:
os.unlink(self.lockfile)
except os.error:
pass
self.lockfile = None
def unlockdir(self):
if self.lockdir:
print "rmdir", self.lockdir
try:
os.rmdir(self.lockdir)
except os.error:
pass
self.lockdir = None
def sleep(self, st):
sleep(st, self.repository, self.delay)
def join(self, name):
return os.path.join(self.repository, name)
def __init__(self, repository = ".", delay = DELAY):
self.repository = repository
self.delay = delay
self.lockdir = None
self.lockfile = None
pid = repr(os.getpid())
self.cvslck = self.join(CVSLCK)
self.cvsrfl = self.join(CVSRFL + pid)
self.cvswfl = self.join(CVSWFL + pid)
def __del__(self):
print "__del__"
self.unlock()
def setlockdir(self):
while 1:
try:
self.lockdir = self.cvslck
os.mkdir(self.cvslck, 0777)
return
except os.error, msg:
self.lockdir = None
if msg[0] == EEXIST:
try:
st = os.stat(self.cvslck)
except os.error:
continue
self.sleep(st)
continue
raise Error("failed to lock %s: %s" % (
self.repository, msg))
def unlock(self):
self.unlockfile()
self.unlockdir()
def unlockfile(self):
if self.lockfile:
print "unlink", self.lockfile
try:
os.unlink(self.lockfile)
except os.error:
pass
self.lockfile = None
def unlockdir(self):
if self.lockdir:
print "rmdir", self.lockdir
try:
os.rmdir(self.lockdir)
except os.error:
pass
self.lockdir = None
def sleep(self, st):
sleep(st, self.repository, self.delay)
def join(self, name):
return os.path.join(self.repository, name)
def sleep(st, repository, delay):
if delay <= 0:
raise Locked(st)
uid = st[stat.ST_UID]
try:
pwent = pwd.getpwuid(uid)
user = pwent[0]
except KeyError:
user = "uid %d" % uid
print "[%s]" % time.ctime(time.time())[11:19],
print "Waiting for %s's lock in" % user, repository
time.sleep(delay)
if delay <= 0:
raise Locked(st)
uid = st[stat.ST_UID]
try:
pwent = pwd.getpwuid(uid)
user = pwent[0]
except KeyError:
user = "uid %d" % uid
print "[%s]" % time.ctime(time.time())[11:19],
print "Waiting for %s's lock in" % user, repository
time.sleep(delay)
class ReadLock(Lock):
def __init__(self, repository, delay = DELAY):
Lock.__init__(self, repository, delay)
ok = 0
try:
self.setlockdir()
self.lockfile = self.cvsrfl
fp = open(self.lockfile, 'w')
fp.close()
ok = 1
finally:
if not ok:
self.unlockfile()
self.unlockdir()
def __init__(self, repository, delay = DELAY):
Lock.__init__(self, repository, delay)
ok = 0
try:
self.setlockdir()
self.lockfile = self.cvsrfl
fp = open(self.lockfile, 'w')
fp.close()
ok = 1
finally:
if not ok:
self.unlockfile()
self.unlockdir()
class WriteLock(Lock):
def __init__(self, repository, delay = DELAY):
Lock.__init__(self, repository, delay)
self.setlockdir()
while 1:
uid = self.readers_exist()
if not uid:
break
self.unlockdir()
self.sleep(uid)
self.lockfile = self.cvswfl
fp = open(self.lockfile, 'w')
fp.close()
def readers_exist(self):
n = len(CVSRFL)
for name in os.listdir(self.repository):
if name[:n] == CVSRFL:
try:
st = os.stat(self.join(name))
except os.error:
continue
return st
return None
def __init__(self, repository, delay = DELAY):
Lock.__init__(self, repository, delay)
self.setlockdir()
while 1:
uid = self.readers_exist()
if not uid:
break
self.unlockdir()
self.sleep(uid)
self.lockfile = self.cvswfl
fp = open(self.lockfile, 'w')
fp.close()
def readers_exist(self):
n = len(CVSRFL)
for name in os.listdir(self.repository):
if name[:n] == CVSRFL:
try:
st = os.stat(self.join(name))
except os.error:
continue
return st
return None
def MultipleWriteLock(repositories, delay = DELAY):
while 1:
locks = []
for r in repositories:
try:
locks.append(WriteLock(r, 0))
except Locked, instance:
del locks
break
else:
break
sleep(instance.msg, r, delay)
return list
while 1:
locks = []
for r in repositories:
try:
locks.append(WriteLock(r, 0))
except Locked, instance:
del locks
break
else:
break
sleep(instance.msg, r, delay)
return list
def test():
import sys
if sys.argv[1:]:
repository = sys.argv[1]
else:
repository = "."
rl = None
wl = None
try:
print "attempting write lock ..."
wl = WriteLock(repository)
print "got it."
wl.unlock()
print "attempting read lock ..."
rl = ReadLock(repository)
print "got it."
rl.unlock()
finally:
print [1]
sys.exc_traceback = None
print [2]
if rl:
rl.unlock()
print [3]
if wl:
wl.unlock()
print [4]
rl = None
print [5]
wl = None
print [6]
import sys
if sys.argv[1:]:
repository = sys.argv[1]
else:
repository = "."
rl = None
wl = None
try:
print "attempting write lock ..."
wl = WriteLock(repository)
print "got it."
wl.unlock()
print "attempting read lock ..."
rl = ReadLock(repository)
print "got it."
rl.unlock()
finally:
print [1]
sys.exc_traceback = None
print [2]
if rl:
rl.unlock()
print [3]
if wl:
wl.unlock()
print [4]
rl = None
print [5]
wl = None
print [6]
if __name__ == '__main__':
test()
test()
......@@ -3,17 +3,17 @@ import string
import rcvs
def main():
while 1:
try:
line = raw_input('$ ')
except EOFError:
break
words = string.split(line)
if not words:
continue
if words[0] != 'rcvs':
words.insert(0, 'rcvs')
sys.argv = words
rcvs.main()
while 1:
try:
line = raw_input('$ ')
except EOFError:
break
words = string.split(line)
if not words:
continue
if words[0] != 'rcvs':
words.insert(0, 'rcvs')
sys.argv = words
rcvs.main()
main()
......@@ -21,51 +21,51 @@ import client
class RCSProxyClient(client.SecureClient):
def __init__(self, address, verbose = client.VERBOSE):
client.SecureClient.__init__(self, address, verbose)
def __init__(self, address, verbose = client.VERBOSE):
client.SecureClient.__init__(self, address, verbose)
def openrcsclient(opts = []):
"open an RCSProxy client based on a list of options returned by getopt"
import RCSProxy
host = HOST
port = PORT
verbose = VERBOSE
local = LOCAL
directory = None
for o, a in opts:
if o == '-h':
host = a
if ':' in host:
i = string.find(host, ':')
host, p = host[:i], host[i+1:]
if p:
port = string.atoi(p)
if o == '-p':
port = string.atoi(a)
if o == '-d':
directory = a
if o == '-v':
verbose = verbose + 1
if o == '-q':
verbose = 0
if o == '-L':
local = 1
if local:
import RCSProxy
x = RCSProxy.RCSProxyLocal()
else:
address = (host, port)
x = RCSProxyClient(address, verbose)
if not directory:
try:
directory = open(os.path.join("CVS", "Repository")).readline()
except IOError:
pass
else:
if directory[-1] == '\n':
directory = directory[:-1]
if directory:
x.cd(directory)
return x
"open an RCSProxy client based on a list of options returned by getopt"
import RCSProxy
host = HOST
port = PORT
verbose = VERBOSE
local = LOCAL
directory = None
for o, a in opts:
if o == '-h':
host = a
if ':' in host:
i = string.find(host, ':')
host, p = host[:i], host[i+1:]
if p:
port = string.atoi(p)
if o == '-p':
port = string.atoi(a)
if o == '-d':
directory = a
if o == '-v':
verbose = verbose + 1
if o == '-q':
verbose = 0
if o == '-L':
local = 1
if local:
import RCSProxy
x = RCSProxy.RCSProxyLocal()
else:
address = (host, port)
x = RCSProxyClient(address, verbose)
if not directory:
try:
directory = open(os.path.join("CVS", "Repository")).readline()
except IOError:
pass
else:
if directory[-1] == '\n':
directory = directory[:-1]
if directory:
x.cd(directory)
return x
......@@ -83,7 +83,7 @@ class RCS:
if line[0] == '\t':
# XXX could be a lock or symbolic name
# Anything else?
continue
continue
i = string.find(line, ':')
if i > 0:
key, value = line[:i], string.strip(line[i+1:])
......@@ -287,7 +287,7 @@ class RCS:
if reason&0x80:
code = code + '(coredump)'
return code, signal
def _system(self, cmd):
"""INTERNAL: run COMMAND in a subshell.
......@@ -311,7 +311,7 @@ class RCS:
If a second PATTERN argument is given, only files matching it
are kept. No check for valid filenames is made.
"""
if pat:
def keep(name, pat = pat):
......
This diff is collapsed.
......@@ -11,150 +11,150 @@ import tempfile
from rcsclient import openrcsclient
def main():
sys.stdout = sys.stderr
try:
opts, rest = getopt.getopt(sys.argv[1:], 'h:p:d:qvL')
if not rest:
cmd = 'head'
else:
cmd, rest = rest[0], rest[1:]
if not commands.has_key(cmd):
raise getopt.error, "unknown command"
coptset, func = commands[cmd]
copts, files = getopt.getopt(rest, coptset)
except getopt.error, msg:
print msg
print "usage: rrcs [options] command [options] [file] ..."
print "where command can be:"
print " ci|put # checkin the given files"
print " co|get # checkout"
print " info # print header info"
print " head # print revision of head branch"
print " list # list filename if valid"
print " log # print full log"
print " diff # diff rcs file and work file"
print "if no files are given, all remote rcs files are assumed"
sys.exit(2)
x = openrcsclient(opts)
if not files:
files = x.listfiles()
for fn in files:
try:
func(x, copts, fn)
except (IOError, os.error), msg:
print "%s: %s" % (fn, msg)
sys.stdout = sys.stderr
try:
opts, rest = getopt.getopt(sys.argv[1:], 'h:p:d:qvL')
if not rest:
cmd = 'head'
else:
cmd, rest = rest[0], rest[1:]
if not commands.has_key(cmd):
raise getopt.error, "unknown command"
coptset, func = commands[cmd]
copts, files = getopt.getopt(rest, coptset)
except getopt.error, msg:
print msg
print "usage: rrcs [options] command [options] [file] ..."
print "where command can be:"
print " ci|put # checkin the given files"
print " co|get # checkout"
print " info # print header info"
print " head # print revision of head branch"
print " list # list filename if valid"
print " log # print full log"
print " diff # diff rcs file and work file"
print "if no files are given, all remote rcs files are assumed"
sys.exit(2)
x = openrcsclient(opts)
if not files:
files = x.listfiles()
for fn in files:
try:
func(x, copts, fn)
except (IOError, os.error), msg:
print "%s: %s" % (fn, msg)
def checkin(x, copts, fn):
f = open(fn)
data = f.read()
f.close()
new = not x.isvalid(fn)
if not new and same(x, copts, fn, data):
print "%s: unchanged since last checkin" % fn
return
print "Checking in", fn, "..."
message = asklogmessage(new)
messages = x.put(fn, data, message)
if messages:
print messages
f = open(fn)
data = f.read()
f.close()
new = not x.isvalid(fn)
if not new and same(x, copts, fn, data):
print "%s: unchanged since last checkin" % fn
return
print "Checking in", fn, "..."
message = asklogmessage(new)
messages = x.put(fn, data, message)
if messages:
print messages
def checkout(x, copts, fn):
data = x.get(fn)
f = open(fn, 'w')
f.write(data)
f.close()
data = x.get(fn)
f = open(fn, 'w')
f.write(data)
f.close()
def lock(x, copts, fn):
x.lock(fn)
x.lock(fn)
def unlock(x, copts, fn):
x.unlock(fn)
x.unlock(fn)
def info(x, copts, fn):
dict = x.info(fn)
keys = dict.keys()
keys.sort()
for key in keys:
print key + ':', dict[key]
print '='*70
dict = x.info(fn)
keys = dict.keys()
keys.sort()
for key in keys:
print key + ':', dict[key]
print '='*70
def head(x, copts, fn):
head = x.head(fn)
print fn, head
head = x.head(fn)
print fn, head
def list(x, copts, fn):
if x.isvalid(fn):
print fn
if x.isvalid(fn):
print fn
def log(x, copts, fn):
flags = ''
for o, a in copts:
flags = flags + ' ' + o + a
flags = flags[1:]
messages = x.log(fn, flags)
print messages
flags = ''
for o, a in copts:
flags = flags + ' ' + o + a
flags = flags[1:]
messages = x.log(fn, flags)
print messages
def diff(x, copts, fn):
if same(x, copts, fn):
return
flags = ''
for o, a in copts:
flags = flags + ' ' + o + a
flags = flags[1:]
data = x.get(fn)
tf = tempfile.NamedTemporaryFile()
tf.write(data)
tf.flush()
print 'diff %s -r%s %s' % (flags, x.head(fn), fn)
sts = os.system('diff %s %s %s' % (flags, tf.name, fn))
if sts:
print '='*70
if same(x, copts, fn):
return
flags = ''
for o, a in copts:
flags = flags + ' ' + o + a
flags = flags[1:]
data = x.get(fn)
tf = tempfile.NamedTemporaryFile()
tf.write(data)
tf.flush()
print 'diff %s -r%s %s' % (flags, x.head(fn), fn)
sts = os.system('diff %s %s %s' % (flags, tf.name, fn))
if sts:
print '='*70
def same(x, copts, fn, data = None):
if data is None:
f = open(fn)
data = f.read()
f.close()
lsum = md5.new(data).digest()
rsum = x.sum(fn)
return lsum == rsum
if data is None:
f = open(fn)
data = f.read()
f.close()
lsum = md5.new(data).digest()
rsum = x.sum(fn)
return lsum == rsum
def asklogmessage(new):
if new:
print "enter description,",
else:
print "enter log message,",
print "terminate with single '.' or end of file:"
if new:
print "NOTE: This is NOT the log message!"
message = ""
while 1:
sys.stderr.write(">> ")
sys.stderr.flush()
line = sys.stdin.readline()
if not line or line == '.\n': break
message = message + line
return message
if new:
print "enter description,",
else:
print "enter log message,",
print "terminate with single '.' or end of file:"
if new:
print "NOTE: This is NOT the log message!"
message = ""
while 1:
sys.stderr.write(">> ")
sys.stderr.flush()
line = sys.stdin.readline()
if not line or line == '.\n': break
message = message + line
return message
def remove(fn):
try:
os.unlink(fn)
except os.error:
pass
try:
os.unlink(fn)
except os.error:
pass
commands = {
'ci': ('', checkin),
'put': ('', checkin),
'co': ('', checkout),
'get': ('', checkout),
'info': ('', info),
'head': ('', head),
'list': ('', list),
'lock': ('', lock),
'unlock': ('', unlock),
'log': ('bhLRtd:l:r:s:w:V:', log),
'diff': ('c', diff),
}
'ci': ('', checkin),
'put': ('', checkin),
'co': ('', checkout),
'get': ('', checkout),
'info': ('', info),
'head': ('', head),
'list': ('', list),
'lock': ('', lock),
'unlock': ('', unlock),
'log': ('bhLRtd:l:r:s:w:V:', log),
'diff': ('c', diff),
}
if __name__ == '__main__':
main()
main()
class Security:
def __init__(self):
import os
env = os.environ
if env.has_key('PYTHON_KEYFILE'):
keyfile = env['PYTHON_KEYFILE']
else:
keyfile = '.python_keyfile'
if env.has_key('HOME'):
keyfile = os.path.join(env['HOME'], keyfile)
if not os.path.exists(keyfile):
import sys
for dir in sys.path:
kf = os.path.join(dir, keyfile)
if os.path.exists(kf):
keyfile = kf
break
try:
self._key = eval(open(keyfile).readline())
except IOError:
raise IOError, "python keyfile %s: cannot open" % keyfile
def __init__(self):
import os
env = os.environ
if env.has_key('PYTHON_KEYFILE'):
keyfile = env['PYTHON_KEYFILE']
else:
keyfile = '.python_keyfile'
if env.has_key('HOME'):
keyfile = os.path.join(env['HOME'], keyfile)
if not os.path.exists(keyfile):
import sys
for dir in sys.path:
kf = os.path.join(dir, keyfile)
if os.path.exists(kf):
keyfile = kf
break
try:
self._key = eval(open(keyfile).readline())
except IOError:
raise IOError, "python keyfile %s: cannot open" % keyfile
def _generate_challenge(self):
import random
return random.randint(100, 100000)
def _generate_challenge(self):
import random
return random.randint(100, 100000)
def _compare_challenge_response(self, challenge, response):
return self._encode_challenge(challenge) == response
def _compare_challenge_response(self, challenge, response):
return self._encode_challenge(challenge) == response
def _encode_challenge(self, challenge):
p, m = self._key
return pow(long(challenge), p, m)
def _encode_challenge(self, challenge):
p, m = self._key
return pow(long(challenge), p, m)
This diff is collapsed.
......@@ -2,23 +2,23 @@ import time
import FSProxy
def main():
t1 = time.time()
#proxy = FSProxy.FSProxyClient(('voorn.cwi.nl', 4127))
proxy = FSProxy.FSProxyLocal()
sumtree(proxy)
proxy._close()
t2 = time.time()
print t2-t1, "seconds"
raw_input("[Return to exit] ")
t1 = time.time()
#proxy = FSProxy.FSProxyClient(('voorn.cwi.nl', 4127))
proxy = FSProxy.FSProxyLocal()
sumtree(proxy)
proxy._close()
t2 = time.time()
print t2-t1, "seconds"
raw_input("[Return to exit] ")
def sumtree(proxy):
print "PWD =", proxy.pwd()
files = proxy.listfiles()
proxy.infolist(files)
subdirs = proxy.listsubdirs()
for name in subdirs:
proxy.cd(name)
sumtree(proxy)
proxy.back()
print "PWD =", proxy.pwd()
files = proxy.listfiles()
proxy.infolist(files)
subdirs = proxy.listsubdirs()
for name in subdirs:
proxy.cd(name)
sumtree(proxy)
proxy.back()
main()
......@@ -4,19 +4,19 @@
import sys, os, time
def TSTART():
global t0, t1
u, s, cu, cs = os.times()
t0 = u+cu, s+cs, time.time()
global t0, t1
u, s, cu, cs = os.times()
t0 = u+cu, s+cs, time.time()
def TSTOP(*label):
global t0, t1
u, s, cu, cs = os.times()
t1 = u+cu, s+cs, time.time()
tt = []
for i in range(3):
tt.append(t1[i] - t0[i])
[u, s, r] = tt
msg = ''
for x in label: msg = msg + (x + ' ')
msg = msg + '%r user, %r sys, %r real\n' % (u, s, r)
sys.stderr.write(msg)
global t0, t1
u, s, cu, cs = os.times()
t1 = u+cu, s+cs, time.time()
tt = []
for i in range(3):
tt.append(t1[i] - t0[i])
[u, s, r] = tt
msg = ''
for x in label: msg = msg + (x + ' ')
msg = msg + '%r user, %r sys, %r real\n' % (u, s, r)
sys.stderr.write(msg)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -8,13 +8,13 @@
import sys, os
def main():
for p in sys.argv[1:]:
makedirs(p)
for p in sys.argv[1:]:
makedirs(p)
def makedirs(p):
if p and not os.path.isdir(p):
head, tail = os.path.split(p)
makedirs(head)
os.mkdir(p, 0777)
if p and not os.path.isdir(p):
head, tail = os.path.split(p)
makedirs(head)
os.mkdir(p, 0777)
main()
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment