commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r8651 - in grc/trunk: scripts src/grc src/grc/elements


From: jblum
Subject: [Commit-gnuradio] r8651 - in grc/trunk: scripts src/grc src/grc/elements src/grc/gui src/grc_gnuradio src/grc_gnuradio/data
Date: Sun, 22 Jun 2008 04:22:56 -0600 (MDT)

Author: jblum
Date: 2008-06-22 04:22:55 -0600 (Sun, 22 Jun 2008)
New Revision: 8651

Modified:
   grc/trunk/scripts/usrp_diagnostics
   grc/trunk/src/grc/ActionHandler.py
   grc/trunk/src/grc/Constants.py
   grc/trunk/src/grc/Preferences.py
   grc/trunk/src/grc/converter.py
   grc/trunk/src/grc/elements/Platform.py
   grc/trunk/src/grc/gui/FileDialogs.py
   grc/trunk/src/grc/gui/NotebookPage.py
   grc/trunk/src/grc_gnuradio/Generator.py
   grc/trunk/src/grc_gnuradio/Platform.py
   grc/trunk/src/grc_gnuradio/data/flow_graph.tmpl
Log:
switch to os.path.join, some file load/save fixes

Modified: grc/trunk/scripts/usrp_diagnostics
===================================================================
--- grc/trunk/scripts/usrp_diagnostics  2008-06-21 21:40:37 UTC (rev 8650)
+++ grc/trunk/scripts/usrp_diagnostics  2008-06-22 10:22:55 UTC (rev 8651)
@@ -22,6 +22,7 @@
 address@hidden Josh Blum
 
 from gnuradio import usrp
+import os
 
 import pygtk
 pygtk.require('2.0')
@@ -30,7 +31,7 @@
 from grc.gui.Dialogs import TextDisplay
 
 from grc_gnuradio.Platform import Platform
-platform = Platform('/usrp/usrp_diagnostics.xml')
+platform = Platform(os.path.join('usrp', 'usrp_diagnostics.xml'))
 
 from grc.gui.elements.Platform import Platform
 platform = Platform(platform)

Modified: grc/trunk/src/grc/ActionHandler.py
===================================================================
--- grc/trunk/src/grc/ActionHandler.py  2008-06-21 21:40:37 UTC (rev 8650)
+++ grc/trunk/src/grc/ActionHandler.py  2008-06-22 10:22:55 UTC (rev 8651)
@@ -171,7 +171,8 @@
                        ): get_action_from_name(action).set_sensitive(True)     
        
                        if not self.init_file_paths and 
Preferences.restore_files(): self.init_file_paths = Preferences.files_open()
                        if not self.init_file_paths: self.init_file_paths = ['']
-                       for file_path in self.init_file_paths: 
self.main_window.new_page(file_path) #load pages from file paths
+                       for file_path in self.init_file_paths: 
+                               if file_path: 
self.main_window.new_page(file_path) #load pages from file paths
                        if Preferences.file_open() in self.init_file_paths: 
self.main_window.new_page(Preferences.file_open(), show=True)
                        if not self.get_page(): self.main_window.new_page() 
#ensure that at least a blank page exists
                elif state == APPLICATION_QUIT:
@@ -271,7 +272,7 @@
                elif state == FLOW_GRAPH_NEW:
                        self.main_window.new_page()
                elif state == FLOW_GRAPH_OPEN:
-                       file_paths = 
gui.OpenFlowGraphFileDialog(self.get_flow_graph() and 
self.get_page().get_file_path() or '').run()
+                       file_paths = 
gui.OpenFlowGraphFileDialog(self.get_page().get_file_path()).run()
                        if file_paths: #open a new page for each file, show 
only the first
                                for i,file_path in enumerate(file_paths):
                                        self.main_window.new_page(file_path, 
show=(i==0))

Modified: grc/trunk/src/grc/Constants.py
===================================================================
--- grc/trunk/src/grc/Constants.py      2008-06-21 21:40:37 UTC (rev 8650)
+++ grc/trunk/src/grc/Constants.py      2008-06-22 10:22:55 UTC (rev 8651)
@@ -139,7 +139,7 @@
 SRC_DIR = os.path.abspath(os.path.dirname(__file__))
 
 ##Location of external data files.
-DATA_DIR = os.path.abspath(SRC_DIR + '/data/')
+DATA_DIR = os.path.join(SRC_DIR, 'data')
 
 ##The default file extension for flow graphs.
 FLOW_GRAPH_FILE_EXTENSION = '.grc.xml'
@@ -148,12 +148,12 @@
 IMAGE_FILE_EXTENSION = '.png'
 
 ##The default path for the open/save dialogs.
-DEFAULT_FILE_PATH = os.path.expanduser('~') + '/'
+DEFAULT_FILE_PATH = os.path.expanduser('~')
 
 ##The default icon for the gtk windows.
-PY_GTK_ICON = os.path.abspath(DATA_DIR + '/grc-icon-256.png')
+PY_GTK_ICON = os.path.join(DATA_DIR, 'grc-icon-256.png')
 
 ##The default user preferences file.
-PREFERENCES_FILE_PATH = os.path.abspath(DEFAULT_FILE_PATH + '/.grc.xml')
+PREFERENCES_FILE_PATH = os.path.join(DEFAULT_FILE_PATH, '.grc.xml')
 address@hidden
 

Modified: grc/trunk/src/grc/Preferences.py
===================================================================
--- grc/trunk/src/grc/Preferences.py    2008-06-21 21:40:37 UTC (rev 8650)
+++ grc/trunk/src/grc/Preferences.py    2008-06-22 10:22:55 UTC (rev 8651)
@@ -23,9 +23,10 @@
 from Constants import PREFERENCES_FILE_PATH, DATA_DIR
 import ParseXML
 import Messages
+import os
 
 from grc_gnuradio.Platform import Platform
-platform = Platform('/preferences.xml')
+platform = Platform('preferences.xml')
 
 from grc.gui.elements.Platform import Platform
 platform = Platform(platform)
@@ -80,7 +81,7 @@
        Load the preferences from the preferences file.
        """
        try: 
-               ParseXML.validate_dtd(PREFERENCES_FILE_PATH, DATA_DIR + 
'/flow_graph.dtd')
+               ParseXML.validate_dtd(PREFERENCES_FILE_PATH, 
os.path.join(DATA_DIR, 'flow_graph.dtd'))
                n = ParseXML.from_file(PREFERENCES_FILE_PATH)
                block.import_data(n['block'])
        except: Messages.send_fail_load_preferences()           
@@ -103,11 +104,11 @@
        return restore_files_param.get_value() == 'yes' 
        
 def file_open(file=None):
-       if file: file_open_param.set_value(file)
+       if file is not None: file_open_param.set_value(file)
        else: return file_open_param.get_value()
 
 def files_open(files=None):
-       if files: files_open_param.set_value('\n'.join(files))
+       if files is not None: files_open_param.set_value('\n'.join(files))
        else: return files_open_param.get_value().split('\n')
        
 def show_reports_window():

Modified: grc/trunk/src/grc/converter.py
===================================================================
--- grc/trunk/src/grc/converter.py      2008-06-21 21:40:37 UTC (rev 8650)
+++ grc/trunk/src/grc/converter.py      2008-06-22 10:22:55 UTC (rev 8651)
@@ -76,7 +76,7 @@
        @param platform the grc gnuradio platform
        """
        try: #return if file passes validation
-               ParseXML.validate_dtd(file_path, DATA_DIR + '/flow_graph.dtd')
+               ParseXML.validate_dtd(file_path, os.path.join(DATA_DIR, 
'flow_graph.dtd'))
                return
        except: pass #convert
        ############################################################

Modified: grc/trunk/src/grc/elements/Platform.py
===================================================================
--- grc/trunk/src/grc/elements/Platform.py      2008-06-21 21:40:37 UTC (rev 
8650)
+++ grc/trunk/src/grc/elements/Platform.py      2008-06-22 10:22:55 UTC (rev 
8651)
@@ -56,11 +56,11 @@
                self._blocks = dict()
                self._blocks_n = dict()
                if load_one:
-                       self._load_block(self._path + '/blocks/' + load_one)    
+                       self._load_block(os.path.join(self._path, 'blocks', 
load_one))  
                else:
-                       for dirpath,dirnames,filenames in os.walk(self._path + 
'/blocks/'):
+                       for dirpath,dirnames,filenames in 
os.walk(os.path.join(self._path, 'blocks')):
                                for filename in filter(lambda f: 
f.endswith('.xml'), filenames):
-                                       self._load_block(dirpath + '/' + 
filename)                              
+                                       self._load_block(os.path.join(dirpath, 
filename))                               
        
        def _load_block(self, f):
                try: ParseXML.validate_dtd(f)
@@ -83,7 +83,7 @@
                
        def get_block_tree(self):
                f = self._block_tree
-               try: ParseXML.validate_dtd(f, DATA_DIR + '/block_tree.dtd')
+               try: ParseXML.validate_dtd(f, os.path.join(DATA_DIR, 
'block_tree.dtd'))
                except ParseXML.XMLSyntaxError, e: self._exit_with_error('Block 
tree "%s" failed: \n\t%s'%(f, e))
                n = ParseXML.from_file(f)['block_tree']
                return n

Modified: grc/trunk/src/grc/gui/FileDialogs.py
===================================================================
--- grc/trunk/src/grc/gui/FileDialogs.py        2008-06-21 21:40:37 UTC (rev 
8650)
+++ grc/trunk/src/grc/gui/FileDialogs.py        2008-06-22 10:22:55 UTC (rev 
8651)
@@ -85,7 +85,7 @@
                FileDialog constructor. 
                @param current_file_path the current directory or path to the 
open flow graph
                """
-               if not current_file_path: current_file_path = 
DEFAULT_FILE_PATH+NEW_FLOGRAPH_TITLE+FLOW_GRAPH_FILE_EXTENSION
+               if not current_file_path: current_file_path = 
path.join(DEFAULT_FILE_PATH, NEW_FLOGRAPH_TITLE + FLOW_GRAPH_FILE_EXTENSION)
                if self.type == OPEN_FLOW_GRAPH:
                        FileDialogHelper.__init__(self, 
gtk.FILE_CHOOSER_ACTION_OPEN, 'Open a Flow Graph from a File...')
                        self.add_and_set_filter(FLOW_GRAPH_FILE_FILTER)

Modified: grc/trunk/src/grc/gui/NotebookPage.py
===================================================================
--- grc/trunk/src/grc/gui/NotebookPage.py       2008-06-21 21:40:37 UTC (rev 
8650)
+++ grc/trunk/src/grc/gui/NotebookPage.py       2008-06-22 10:22:55 UTC (rev 
8651)
@@ -52,7 +52,7 @@
                from grc import converter
                converter.convert(file_path, flow_graph.get_parent())
                ############################################################
-               ParseXML.validate_dtd(file_path, DATA_DIR + '/flow_graph.dtd')
+               ParseXML.validate_dtd(file_path, os.path.join(DATA_DIR, 
'flow_graph.dtd'))
                initial_state = ParseXML.from_file(file_path)
                self.state_cache = StateCache(initial_state)                    
        
                self.set_saved(True)    

Modified: grc/trunk/src/grc_gnuradio/Generator.py
===================================================================
--- grc/trunk/src/grc_gnuradio/Generator.py     2008-06-21 21:40:37 UTC (rev 
8650)
+++ grc/trunk/src/grc_gnuradio/Generator.py     2008-06-22 10:22:55 UTC (rev 
8651)
@@ -32,9 +32,9 @@
 #>>> platform dependency! MacOS requires pythonw to run wx apps        #
 if sys.platform == 'darwin': PYEXEC = 'pythonw'
 
-PATH = os.path.dirname(__file__)
+PATH = os.path.abspath(os.path.dirname(__file__))
 
-FLOW_GRAPH_TEMPLATE = PATH + '/data/flow_graph.tmpl'
+FLOW_GRAPH_TEMPLATE = os.path.join(PATH, 'data', 'flow_graph.tmpl')
 
 class Generator(object):
        

Modified: grc/trunk/src/grc_gnuradio/Platform.py
===================================================================
--- grc/trunk/src/grc_gnuradio/Platform.py      2008-06-21 21:40:37 UTC (rev 
8650)
+++ grc/trunk/src/grc_gnuradio/Platform.py      2008-06-22 10:22:55 UTC (rev 
8651)
@@ -29,11 +29,11 @@
 from Param import Param as _Param
 from Generator import Generator
 
-PATH = os.path.dirname(__file__)
+PATH = os.path.abspath(os.path.dirname(__file__))
 
-BLOCK_TREE = PATH + '/data/block_tree.xml'
+BLOCK_TREE = os.path.join(PATH, 'data', 'block_tree.xml')
 
-DEFAULT_FLOW_GRAPH = PATH + '/data/default_flow_graph.grc.xml'
+DEFAULT_FLOW_GRAPH = os.path.join(PATH, 'data', 'default_flow_graph.grc.xml')
 
 class Platform(_Platform):
        

Modified: grc/trunk/src/grc_gnuradio/data/flow_graph.tmpl
===================================================================
--- grc/trunk/src/grc_gnuradio/data/flow_graph.tmpl     2008-06-21 21:40:37 UTC 
(rev 8650)
+++ grc/trunk/src/grc_gnuradio/data/flow_graph.tmpl     2008-06-22 10:22:55 UTC 
(rev 8651)
@@ -31,7 +31,7 @@
        #import os
        #from grc.Constants import MAIN_WINDOW_PREFIX,DATA_DIR
        ##set the icon for the wx app
-       #set $WX_APP_ICON = '"%s"'%os.path.abspath($DATA_DIR + 
'/grc-icon-32.png')
+       #set $WX_APP_ICON = '"%s"'%os.path.join($DATA_DIR, 'grc-icon-32.png')
        ##>>> platform dependency! wx under cygwin has issues with icon paths
        #if sys.platform == 'cygwin'
        #set $WX_APP_ICON = None





reply via email to

[Prev in Thread] Current Thread [Next in Thread]