summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Braun2013-01-28 11:48:10 +0100
committerMartin Braun2013-01-28 11:48:10 +0100
commit03f101f509818a22d9488b4e5d08b9f0cd2b3b26 (patch)
tree54fd7d49cfe092508cb730d61958ccc25e9350b2
parent179b6fc774e9053d95bc1ff98427cd618d99501f (diff)
downloadgnuradio-03f101f509818a22d9488b4e5d08b9f0cd2b3b26.tar.gz
gnuradio-03f101f509818a22d9488b4e5d08b9f0cd2b3b26.tar.bz2
gnuradio-03f101f509818a22d9488b4e5d08b9f0cd2b3b26.zip
modtool: newmod uses gr.prefs or --srcdir
-rw-r--r--gr-utils/src/python/modtool/modtool_newmod.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/gr-utils/src/python/modtool/modtool_newmod.py b/gr-utils/src/python/modtool/modtool_newmod.py
index 7a5f635dd..5e14493c3 100644
--- a/gr-utils/src/python/modtool/modtool_newmod.py
+++ b/gr-utils/src/python/modtool/modtool_newmod.py
@@ -24,6 +24,7 @@ import shutil
import os
import re
from optparse import OptionGroup
+from gnuradio import gr
from modtool_base import ModTool
class ModToolNewModule(ModTool):
@@ -38,6 +39,8 @@ class ModToolNewModule(ModTool):
parser = ModTool.setup_parser(self)
parser.usage = '%prog rm [options]. \n Call %prog without any options to run it interactively.'
ogroup = OptionGroup(parser, "New out-of-tree module options")
+ ogroup.add_option("--srcdir", type="string",
+ help="Source directory for the module template.")
parser.add_option_group(ogroup)
return parser
@@ -62,6 +65,12 @@ class ModToolNewModule(ModTool):
else:
print 'The given directory exists.'
exit(2)
+ 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)
def run(self):
"""
@@ -71,10 +80,10 @@ class ModToolNewModule(ModTool):
"""
print "Creating out-of-tree module in %s..." % self._dir,
try:
- shutil.copytree('/home/braun/.usrlocal/share/gnuradio/modtool/gr-newmod', self._dir)
+ shutil.copytree(self._srcdir, self._dir)
os.chdir(self._dir)
except OSError:
- print 'FAILED'
+ print 'Failed.'
print 'Could not create directory %s. Quitting.' % self._dir
exit(2)
for root, dirs, files in os.walk('.'):