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_newmod.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_newmod.py')
-rw-r--r-- | gr-utils/python/modtool/modtool_newmod.py | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/gr-utils/python/modtool/modtool_newmod.py b/gr-utils/python/modtool/modtool_newmod.py index 6e55c5ea59..59818b1e62 100644 --- a/gr-utils/python/modtool/modtool_newmod.py +++ b/gr-utils/python/modtool/modtool_newmod.py @@ -25,7 +25,7 @@ import os import re from optparse import OptionGroup from gnuradio import gr -from modtool_base import ModTool +from modtool_base import ModTool, ModToolException class ModToolNewModule(ModTool): """ Create a new out-of-tree module """ @@ -44,17 +44,15 @@ class ModToolNewModule(ModTool): parser.add_option_group(ogroup) return parser - def setup(self): - (options, self.args) = self.parser.parse_args() + def setup(self, options, args): self._info['modname'] = options.module_name if self._info['modname'] is None: - if len(self.args) >= 2: - self._info['modname'] = self.args[1] + if len(args) >= 2: + self._info['modname'] = args[1] else: self._info['modname'] = raw_input('Name of the new module: ') if not re.match('[a-zA-Z0-9_]+$', self._info['modname']): - print 'Invalid module name.' - exit(2) + raise ModToolException('Invalid module name.') self._dir = options.directory if self._dir == '.': self._dir = './gr-%s' % self._info['modname'] @@ -63,14 +61,12 @@ class ModToolNewModule(ModTool): except OSError: pass # This is what should happen else: - print 'The given directory exists.' - exit(2) + raise ModToolException('The given directory exists.') if options.srcdir is None: options.srcdir = '/usr/local/share/gnuradio/modtool/gr-newmod' self._srcdir = gr.prefs().get_string('modtool', 'newmod_path', options.srcdir) if not os.path.isdir(self._srcdir): - print 'Error: Could not find gr-newmod source dir.' - exit(2) + raise ModToolException('Could not find gr-newmod source dir.') def run(self): """ @@ -83,9 +79,7 @@ class ModToolNewModule(ModTool): shutil.copytree(self._srcdir, self._dir) os.chdir(self._dir) except OSError: - print 'Failed.' - print 'Could not create directory %s. Quitting.' % self._dir - exit(2) + raise ModToolException('Could not create directory %s.' % self._dir) for root, dirs, files in os.walk('.'): for filename in files: f = os.path.join(root, filename) |