diff options
author | Sebastian Koslowski <koslowski@kit.edu> | 2013-11-24 20:23:39 +0100 |
---|---|---|
committer | Martin Braun <martin.braun@kit.edu> | 2013-11-27 22:33:04 +0100 |
commit | fa5480e8bccec39278e9c5f81c09d1e702fd0fd7 (patch) | |
tree | 15d398b9828da5586944157857189de78f2a126f /gr-utils/python/modtool/modtool_base.py | |
parent | 77b36be049ed864beaf450413e4b960d909d6f8a (diff) |
modtool: no more exit() in modtool package
Conflicts:
gr-utils/python/modtool/modtool_newmod.py
Diffstat (limited to 'gr-utils/python/modtool/modtool_base.py')
-rw-r--r-- | gr-utils/python/modtool/modtool_base.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/gr-utils/python/modtool/modtool_base.py b/gr-utils/python/modtool/modtool_base.py index 86cbd8f420..768bce0f77 100644 --- a/gr-utils/python/modtool/modtool_base.py +++ b/gr-utils/python/modtool/modtool_base.py @@ -22,11 +22,14 @@ import os import re -import sys from optparse import OptionParser, OptionGroup from util_functions import get_modname -from templates import Templates + + +class ModToolException(BaseException): + """ Standard exception for modtool classes. """ + pass class ModTool(object): @@ -41,8 +44,6 @@ class ModTool(object): self._has_subdirs[subdir] = False self._skip_subdirs[subdir] = False self.parser = self.setup_parser() - self.args = None - self.options = None self._dir = None def setup_parser(self): @@ -72,20 +73,17 @@ class ModTool(object): parser.add_option_group(ogroup) return parser - def setup(self): + def setup(self, options, args): """ Initialise all internal variables, such as the module name etc. """ - (options, self.args) = self.parser.parse_args() self._dir = options.directory if not self._check_directory(self._dir): - print "No GNU Radio module found in the given directory. Quitting." - sys.exit(1) + raise ModToolException('No GNU Radio module found in the given directory.') if options.module_name is not None: self._info['modname'] = options.module_name else: self._info['modname'] = get_modname() if self._info['modname'] is None: - print "No GNU Radio module found in the given directory. Quitting." - sys.exit(1) + raise ModToolException('No GNU Radio module found in the given directory.') print "GNU Radio module name identified: " + self._info['modname'] if self._info['version'] == '36' and ( os.path.isdir(os.path.join('include', self._info['modname'])) or @@ -101,7 +99,6 @@ class ModTool(object): if options.skip_grc or not self._has_subdirs['grc']: self._skip_subdirs['grc'] = True self._info['blockname'] = options.block_name - self.options = options self._setup_files() self._info['yes'] = options.yes @@ -171,6 +168,7 @@ class ModTool(object): """ Override this. """ pass + def get_class_dict(the_globals): " Return a dictionary of the available commands in the form command->class " classdict = {} |