summaryrefslogtreecommitdiff
path: root/grc/python/Platform.py
diff options
context:
space:
mode:
authorSebastian Koslowski <koslowski@kit.edu>2015-08-12 14:46:00 +0200
committerSebastian Koslowski <koslowski@kit.edu>2015-08-13 14:00:00 +0200
commitdda4f8306f194ff142d25bbedeb7ee5dabd0f523 (patch)
tree65c556c2c9175801314ac9fb9b9550cdfaa2ebe0 /grc/python/Platform.py
parentce21c31af563bc669085cb1a0a711f58f40c8231 (diff)
grc: move gui prefs file to ~/.gnuradio/grc.conf
Diffstat (limited to 'grc/python/Platform.py')
-rw-r--r--grc/python/Platform.py37
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
##############################################