diff options
author | Johnathan Corgan <johnathan@corganlabs.com> | 2016-08-03 09:45:14 -0700 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2016-08-03 09:45:14 -0700 |
commit | 124c641c12c091368bf79c6fa612eded9de8e2f4 (patch) | |
tree | 14962dc9814712df2bf2708d4d83c8624f870156 | |
parent | a6e3db2db0ac46b560820ecc8d8691c22fecb793 (diff) | |
parent | b18c00c327446c1c2c7431f304f60f7537564bea (diff) |
Merge remote-tracking branch 'gnuradio-wg-grc/master_grcwg'
-rw-r--r-- | grc/core/Config.py | 13 | ||||
-rw-r--r-- | grc/core/Constants.py | 1 | ||||
-rw-r--r-- | grc/core/Platform.py | 9 | ||||
-rw-r--r-- | grc/grc.conf.in | 1 |
4 files changed, 17 insertions, 7 deletions
diff --git a/grc/core/Config.py b/grc/core/Config.py index ac38d9978c..78ff344998 100644 --- a/grc/core/Config.py +++ b/grc/core/Config.py @@ -20,6 +20,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA import os from os.path import expanduser, normpath, expandvars, exists +from . import Constants + class Config(object): @@ -28,7 +30,7 @@ class Config(object): license = __doc__.strip() website = 'http://gnuradio.org' - hier_block_lib_dir = os.environ.get('GRC_HIER_PATH', expanduser('~/.grc_gnuradio')) + hier_block_lib_dir = os.environ.get('GRC_HIER_PATH', Constants.DEFAULT_HIER_BLOCK_LIB_DIR) def __init__(self, prefs_file, version, version_parts=None): self.prefs = prefs_file @@ -53,3 +55,12 @@ class Config(object): for path in collected_paths if exists(path)] return valid_paths + + @property + def default_flow_graph(self): + user_default = ( + os.environ.get('GRC_DEFAULT_FLOW_GRAPH') or + self.prefs.get_string('grc', 'default_flow_graph', '') or + os.path.join(self.hier_block_lib_dir, 'default_flow_graph.grc') + ) + return user_default if exists(user_default) else Constants.DEFAULT_FLOW_GRAPH diff --git a/grc/core/Constants.py b/grc/core/Constants.py index eeb1d7f848..61a44d0c78 100644 --- a/grc/core/Constants.py +++ b/grc/core/Constants.py @@ -27,6 +27,7 @@ FLOW_GRAPH_DTD = os.path.join(DATA_DIR, 'flow_graph.dtd') BLOCK_TREE_DTD = os.path.join(DATA_DIR, 'block_tree.dtd') BLOCK_DTD = os.path.join(DATA_DIR, 'block.dtd') DEFAULT_FLOW_GRAPH = os.path.join(DATA_DIR, 'default_flow_graph.grc') +DEFAULT_HIER_BLOCK_LIB_DIR = os.path.expanduser('~/.grc_gnuradio') DOMAIN_DTD = os.path.join(DATA_DIR, 'domain.dtd') # File format versions: diff --git a/grc/core/Platform.py b/grc/core/Platform.py index 9b25e67d65..0dc6eb055a 100644 --- a/grc/core/Platform.py +++ b/grc/core/Platform.py @@ -60,9 +60,6 @@ class Platform(Element): callback_finished=lambda: self.block_docstrings_loaded_callback() ) - self._block_dtd = Constants.BLOCK_DTD - self._default_flow_graph = Constants.DEFAULT_FLOW_GRAPH - # Create a dummy flow graph for the blocks self._flow_graph = Element(self) self._flow_graph.connections = [] @@ -188,7 +185,7 @@ class Platform(Element): def load_block_xml(self, xml_file): """Load block description from xml file""" # Validate and import - ParseXML.validate_dtd(xml_file, self._block_dtd) + ParseXML.validate_dtd(xml_file, Constants.BLOCK_DTD) n = ParseXML.from_file(xml_file).find('block') n['block_wrapper_path'] = xml_file # inject block wrapper path # Get block instance and add it to the list of blocks @@ -291,8 +288,8 @@ class Platform(Element): nested data @throws exception if the validation fails """ - flow_graph_file = flow_graph_file or self._default_flow_graph - open(flow_graph_file, 'r') # Test open + flow_graph_file = flow_graph_file or self.config.default_flow_graph + open(flow_graph_file, 'r').close() # Test open ParseXML.validate_dtd(flow_graph_file, Constants.FLOW_GRAPH_DTD) return ParseXML.from_file(flow_graph_file) diff --git a/grc/grc.conf.in b/grc/grc.conf.in index 71c4f63bca..1dbb13bfaa 100644 --- a/grc/grc.conf.in +++ b/grc/grc.conf.in @@ -5,6 +5,7 @@ [grc] global_blocks_path = @blocksdir@ local_blocks_path = +default_flow_graph = xterm_executable = @GRC_XTERM_EXE@ canvas_font_size = 8 canvas_default_size = 1280, 1024 |