aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/ui
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-12-14 23:15:58 -0500
committerW. Trevor King <wking@drexel.edu>2009-12-14 23:15:58 -0500
commit1b9c628529848af370adbc67b5ba298236a1b86d (patch)
treedd16c447d971297637b59128c383c942a5578d1e /libbe/ui
parent0786fc6693e40cdfaca7876b504acb3e5e7dc4d2 (diff)
downloadbugseverywhere-1b9c628529848af370adbc67b5ba298236a1b86d.tar.gz
Transitioned severity to Command-format, also added Command._get_*()
The old .requires_* thing was rediculous. The new ._get_*() callbacks allow the caller to provide a means for getting the expensive structures, which the command can use, or not, as required. This will also make it easier to implement the completion callbacks. The callbacks should probably have matching .set_*() methods, to avoid the current cache tweaking cmd._storage = ... etc. But that can wait for now...
Diffstat (limited to 'libbe/ui')
-rwxr-xr-xlibbe/ui/command_line.py23
-rw-r--r--libbe/ui/util/cmdutil.py14
2 files changed, 6 insertions, 31 deletions
diff --git a/libbe/ui/command_line.py b/libbe/ui/command_line.py
index 84f9450..0aa34f7 100755
--- a/libbe/ui/command_line.py
+++ b/libbe/ui/command_line.py
@@ -264,29 +264,18 @@ def main():
print e
return 1
Class = getattr(module, command_name.capitalize())
- command = Class()
- command.ui = self
+ def gucs():
+ return libbe.storage.get_storage(options['repo'])
+ command = Class(get_unconnected_storage=gucs, ui=ui)
parser = CmdOptionParser(command)
- storage = None
- bugdir = None
- if command.requires_bugdir == True:
- assert command.requires_unconnected_storage == False
- storage = libbe.storage.get_storage(options['repo'])
- storage.connect()
- bugdir = libbe.bugdir.BugDir(storage, from_storage=True)
- elif command.requires_storage == True \
- or command.requires_unconnected_storage == True:
- storage = libbe.storage.get_storage(options['repo'])
- if command.requires_unconnected_storage == False:
- storage.connect()
try:
options,args = parser.parse_args(args[1:])
- command.run(storage, bugdir, options, args)
+ command.run(options, args)
except CallbackExit:
- if storage != None: storage.disconnect()
+ command.cleanup()
return 0
except libbe.command.UserError, e:
- if storage != None: storage.disconnect()
+ command.cleanup()
print 'ERROR:\n', e
return 1
if storage != None: storage.disconnect()
diff --git a/libbe/ui/util/cmdutil.py b/libbe/ui/util/cmdutil.py
index 86ff9fc..f2eb5b9 100644
--- a/libbe/ui/util/cmdutil.py
+++ b/libbe/ui/util/cmdutil.py
@@ -59,20 +59,6 @@ def execute(cmd, args,
def restrict_file_access(bugdir, path):
- """
- Check that the file at path is inside bugdir.root. This is
- important if you allow other users to execute becommands with your
- username (e.g. if you're running be-handle-mail through your
- ~/.procmailrc). If this check wasn't made, a user could e.g.
- run
- be commit -b ~/.ssh/id_rsa "Hack to expose ssh key"
- which would expose your ssh key to anyone who could read the VCS
- log.
- """
- in_root = bugdir.vcs.path_in_root(path, bugdir.root)
- if in_root == False:
- raise UserError('file access restricted!\n %s not in %s'
- % (path, bugdir.root))
def parse_id(id):
"""