diff options
author | Sebastian Koslowski <koslowski@kit.edu> | 2015-02-12 10:05:21 +0100 |
---|---|---|
committer | Sebastian Koslowski <koslowski@kit.edu> | 2015-04-02 09:20:24 +0200 |
commit | 15417bdd699beef1905dd94b66ac39444b96d70d (patch) | |
tree | 28da885f91eb1386e13f874d76ec9e15e7c4d908 | |
parent | 10a434c2dacd64e28a5da7a0881d8fc957983ea7 (diff) |
grc: make use of GRC_HIER_PATH at runtime
-rw-r--r-- | grc/python/Generator.py | 6 | ||||
-rw-r--r-- | grc/python/flow_graph.tmpl | 7 |
2 files changed, 9 insertions, 4 deletions
diff --git a/grc/python/Generator.py b/grc/python/Generator.py index 7512cfb633..a263679a8e 100644 --- a/grc/python/Generator.py +++ b/grc/python/Generator.py @@ -219,8 +219,8 @@ class HierBlockGenerator(TopBlockGenerator): """ TopBlockGenerator.__init__(self, flow_graph, file_path) self._mode = HIER_BLOCK_FILE_MODE - self._file_path = os.path.join(HIER_BLOCKS_LIB_DIR, - self._flow_graph.get_option('id') + '.py') + self._file_name = self._flow_graph.get_option('id') + '.py' + self._file_path = os.path.join(HIER_BLOCKS_LIB_DIR, self._file_name) self._file_path_xml = self._file_path + '.xml' def get_file_path_xml(self): @@ -254,7 +254,7 @@ class HierBlockGenerator(TopBlockGenerator): self._flow_graph.get_option('id').replace('_', ' ').title() block_n['key'] = block_key block_n['category'] = self._flow_graph.get_option('category') - block_n['import'] = 'execfile("{0}")'.format(self.get_file_path()) + block_n['import'] = 'execfile(os.path.join(GRC_HIER_PATH, ' + repr(self._file_name) + '))' # make data if parameters: block_n['make'] = '{cls}(\n {kwargs},\n)'.format( diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl index 859611e528..a0de5d12bd 100644 --- a/grc/python/flow_graph.tmpl +++ b/grc/python/flow_graph.tmpl @@ -19,7 +19,7 @@ $code#slurp #import time #set $DIVIDER = '#'*50 $DIVIDER -# Gnuradio Python Flow Graph +# GNU Radio Python Flow Graph # Title: $title #if $flow_graph.get_option('author') # Author: $flow_graph.get_option('author') @@ -48,6 +48,11 @@ if __name__ == '__main__': ######################################################## ##Create Imports ######################################################## +#if any("GRC_HIER_PATH" in imp for imp in $imports) +import os +GRC_HIER_PATH = os.environ.get('GRC_HIER_PATH', os.path.expanduser('~/.grc_gnuradio')) + +#end if #for $imp in $imports $imp #end for |