diff options
Diffstat (limited to 'grc/python/Platform.py')
-rw-r--r-- | grc/python/Platform.py | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/grc/python/Platform.py b/grc/python/Platform.py index feea81dae1..1497099f3f 100644 --- a/grc/python/Platform.py +++ b/grc/python/Platform.py @@ -18,7 +18,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ import os +import sys + from gnuradio import gr + from .. base.Platform import Platform as _Platform from .. gui.Platform import Platform as _GUIPlatform from FlowGraph import FlowGraph as _FlowGraph @@ -27,21 +30,26 @@ from Block import Block as _Block from Port import Port as _Port from Param import Param as _Param from Generator import Generator -from Constants import \ - HIER_BLOCKS_LIB_DIR, BLOCK_DTD, \ - DEFAULT_FLOW_GRAPH, BLOCKS_DIRS, PREFS_FILE -import Constants +from Constants import ( + HIER_BLOCKS_LIB_DIR, BLOCK_DTD, DEFAULT_FLOW_GRAPH, BLOCKS_DIRS, + PREFS_FILE, PREFS_FILE_OLD, CORE_TYPES +) + + +COLORS = [(name, color) for name, key, sizeof, color in CORE_TYPES] -COLORS = [(name, color) for name, key, sizeof, color in Constants.CORE_TYPES] class Platform(_Platform, _GUIPlatform): def __init__(self): """ Make a platform for gnuradio. """ - #ensure hier dir - if not os.path.exists(HIER_BLOCKS_LIB_DIR): os.mkdir(HIER_BLOCKS_LIB_DIR) - #init + # ensure hier and conf directories + if not os.path.exists(HIER_BLOCKS_LIB_DIR): + os.mkdir(HIER_BLOCKS_LIB_DIR) + if not os.path.exists(os.path.dirname(PREFS_FILE)): + os.mkdir(os.path.dirname(PREFS_FILE)) + # init _Platform.__init__( self, name='GNU Radio Companion', @@ -55,12 +63,23 @@ class Platform(_Platform, _GUIPlatform): generator=Generator, colors=COLORS, ) - + self._move_old_pref_file() _GUIPlatform.__init__( self, prefs_file=PREFS_FILE ) + @staticmethod + def _move_old_pref_file(): + if PREFS_FILE == PREFS_FILE_OLD: + return # prefs file overridden with env var + if os.path.exists(PREFS_FILE_OLD) and not os.path.exists(PREFS_FILE): + try: + import shutil + shutil.move(PREFS_FILE_OLD, PREFS_FILE) + except Exception as e: + print >> sys.stderr, e + ############################################## # Constructors ############################################## |