From 918a1fca2372b53024e65dfe7d083160b81322bb Mon Sep 17 00:00:00 2001 From: Rob Kinninmont Date: Thu, 30 Nov 2006 19:53:08 -0700 Subject: [PATCH] added 'debugshell' module a convenient dumping ground for tools for manhole environment --- allmydata/manhole.py | 11 ++++++++--- debugshell.py | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 debugshell.py 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)) + -- 2.45.2