[PATCH] Better error checking for external commands
Michael Ellerman
michael+bazaar at ellerman.id.au
Wed May 18 00:13:23 BST 2005
Hi Martin,
This just fixes a TODO you added to the external command stuff.
cheers
*** modified file 'bzrlib/commands.py'
--- bzrlib/commands.py
+++ bzrlib/commands.py
@@ -146,17 +146,24 @@
def __init__(self, path):
self.path = path
- # TODO: If either of these fail, we should detect that and
- # assume that path is not really a bzr plugin after all.
-
pipe = os.popen('%s --bzr-usage' % path, 'r')
self.takes_options = pipe.readline().split()
+
+ for opt in self.takes_options:
+ if not opt in OPTIONS:
+ bailout("Unknown option '%s' returned by external command %s"
+ % (opt, path))
+
+ # TODO: Is there any way to check takes_args is valid here?
self.takes_args = pipe.readline().split()
- pipe.close()
+
+ if pipe.close() is not None:
+ bailout("Failed funning '%s --bzr-usage'" % path)
pipe = os.popen('%s --bzr-help' % path, 'r')
self.__doc__ = pipe.read()
- pipe.close()
+ if pipe.close() is not None:
+ bailout("Failed funning '%s --bzr-help'" % path)
def __call__(self, options, arguments):
Command.__init__(self, options, arguments)
More information about the bazaar
mailing list