[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 07/20: grc: move gui prefs file to ~/.gnura
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 07/20: grc: move gui prefs file to ~/.gnuradio/grc.conf |
Date: |
Fri, 28 Aug 2015 19:19:51 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit dda4f8306f194ff142d25bbedeb7ee5dabd0f523
Author: Sebastian Koslowski <address@hidden>
Date: Wed Aug 12 14:46:00 2015 +0200
grc: move gui prefs file to ~/.gnuradio/grc.conf
---
grc/python/Constants.py | 25 ++++++++++++++-----------
grc/python/Platform.py | 37 ++++++++++++++++++++++++++++---------
2 files changed, 42 insertions(+), 20 deletions(-)
diff --git a/grc/python/Constants.py b/grc/python/Constants.py
index 1df1fc4..02be22a 100644
--- a/grc/python/Constants.py
+++ b/grc/python/Constants.py
@@ -18,18 +18,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA
"""
import os
+from os.path import expanduser
import stat
from gnuradio import gr
_gr_prefs = gr.prefs()
-#setup paths
-PATH_SEP = {'/':':', '\\':';'}[os.path.sep]
-HIER_BLOCKS_LIB_DIR = os.environ.get('GRC_HIER_PATH',
- os.path.expanduser('~/.grc_gnuradio'))
-PREFS_FILE = os.environ.get('GRC_PREFS_PATH',
- os.path.join(os.path.expanduser('~/.grc')))
-BLOCKS_DIRS = filter( #filter blank strings
+# setup paths
+PATH_SEP = {'/': ':', '\\': ';'}[os.path.sep]
+
+HIER_BLOCKS_LIB_DIR = os.environ.get('GRC_HIER_PATH',
expanduser('~/.grc_gnuradio'))
+
+PREFS_FILE = os.environ.get('GRC_PREFS_PATH',
expanduser('~/.gnuradio/grc.conf'))
+PREFS_FILE_OLD = os.environ.get('GRC_PREFS_PATH', expanduser('~/.grc'))
+
+BLOCKS_DIRS = filter( # filter blank strings
lambda x: x, PATH_SEP.join([
os.environ.get('GRC_BLOCKS_PATH', ''),
_gr_prefs.get_string('grc', 'local_blocks_path', ''),
@@ -37,14 +40,14 @@ BLOCKS_DIRS = filter( #filter blank strings
]).split(PATH_SEP),
) + [HIER_BLOCKS_LIB_DIR]
-#user settings
+# user settings
XTERM_EXECUTABLE = _gr_prefs.get_string('grc', 'xterm_executable', 'xterm')
-#file creation modes
+# file creation modes
TOP_BLOCK_FILE_MODE = stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP | stat.S_IROTH
HIER_BLOCK_FILE_MODE = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP |
stat.S_IWGRP | stat.S_IROTH
-#data files
+# data files
DATA_DIR = os.path.dirname(__file__)
FLOW_GRAPH_TEMPLATE = os.path.join(DATA_DIR, 'flow_graph.tmpl')
BLOCK_DTD = os.path.join(DATA_DIR, 'block.dtd')
@@ -74,7 +77,7 @@ GRC_COLOR_GREY = '#BDBDBD'
GRC_COLOR_WHITE = '#FFFFFF'
-CORE_TYPES = ( #name, key, sizeof, color
+CORE_TYPES = ( # name, key, sizeof, color
('Complex Float 64', 'fc64', 16, GRC_COLOR_BROWN),
('Complex Float 32', 'fc32', 8, GRC_COLOR_BLUE),
('Complex Integer 64', 'sc64', 16, GRC_COLOR_LIGHT_GREEN),
diff --git a/grc/python/Platform.py b/grc/python/Platform.py
index feea81d..1497099 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
##############################################
- [Commit-gnuradio] [gnuradio] branch master updated (22e2f1a -> 68c6862), git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 02/20: Merge branch 'maint_grcwg' into master_grcwg, git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 01/20: qtgui: added trigger callbacks to GRC XML files, git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 06/20: grc: add warning for invalid xterm setting (fixes #828), git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 05/20: grc: rewrite Preferences.py, git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 16/20: Merge remote-tracking branch 'ckuethe/trap_import_errors', git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 17/20: Merge remote-tracking branch 'saikwolf/qt_themeing', git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 11/20: clarify missing module exception., git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 07/20: grc: move gui prefs file to ~/.gnuradio/grc.conf,
git <=
- [Commit-gnuradio] [gnuradio] 20/20: Merge branch 'maint', git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 19/20: Merge remote-tracking branch 'gnuradio-wg-grc/master_grcwg', git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 04/20: grc: clean-up ActionHandler.py imports, git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 14/20: Merge remote-tracking branch 'estatz/qtgui_trigger_callbacks', git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 13/20: grc: super-secret, git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 10/20: grc: show cmdline when xterm is used, git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 12/20: qtgui: Modified the qproperties to scale the colorbar title from the .qss file, git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 18/20: Merge remote-tracking branch 'sdh11/complexity', git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 15/20: Merge remote-tracking branch 'tom/docs/sphinx_update', git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 03/20: grc: have cmake find a xterm executable on UNIX, git, 2015/08/28