From: Rob Kinninmont Date: Fri, 1 Dec 2006 02:53:08 +0000 (-0700) Subject: added 'debugshell' module a convenient dumping ground for tools for manhole environment X-Git-Tag: tahoe_v0.1.0-0-UNSTABLE~518 X-Git-Url: https://git.rkrishnan.org/(%5B%5E?a=commitdiff_plain;h=918a1fca2372b53024e65dfe7d083160b81322bb;p=tahoe-lafs%2Ftahoe-lafs.git added 'debugshell' module a convenient dumping ground for tools for manhole environment --- diff --git a/allmydata/manhole.py b/allmydata/manhole.py index dfc7af3f..02daaf5b 100644 --- a/allmydata/manhole.py +++ b/allmydata/manhole.py @@ -133,9 +133,14 @@ class _BaseManhole(service.MultiService): def makeNamespace(): # close over 'self' so we can get access to .parent later - namespace = { - 'app': self.parent, - } + import types + import debugshell + debugshell.app = self.parent # make client/queen accesible via 'app' + namespace = {} + for sym in dir(debugshell): + if sym.startswith('__') and sym.endswith('__'): + continue + namespace[sym] = getattr(debugshell, sym) return namespace def makeProtocol(): diff --git a/debugshell.py b/debugshell.py new file mode 100644 index 00000000..130c9099 --- /dev/null +++ b/debugshell.py @@ -0,0 +1,17 @@ +import os + +def get_random_bucket_on(nodeid, size=200): + d = app.get_remote_service(nodeid, 'storageserver') + def get_bucket(rss): + return rss.callRemote('allocate_bucket', + verifierid=os.urandom(20), + bucket_num=26, + size=size, + leaser=app.tub.tubID, + ) + d.addCallback(get_bucket) + return d + +def write_to_bucket(bucket, bytes=100): + return bucket.callRemote('write', data=os.urandom(bytes)) +