Changeset c155a16 in sasview for src/sas/sasgui/guiframe


Ignore:
Timestamp:
Apr 4, 2017 10:06:27 AM (7 years ago)
Author:
Ricardo Ferraz Leal <ricleal@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
463e7ffc
Parents:
6722fae
Message:

Logging is now logger

Location:
src/sas/sasgui/guiframe
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/guiframe/CategoryInstaller.py

    rddbac66 rc155a16  
    1616 
    1717USER_FILE = 'categories.json' 
     18 
     19logger = logging.getLogger() 
    1820 
    1921class CategoryInstaller: 
     
    114116    @staticmethod 
    115117    def get_default_file(): 
    116         logging.warning("CategoryInstaller.get_default_file is deprecated.") 
     118        logger.warning("CategoryInstaller.get_default_file is deprecated.") 
    117119 
    118120    @staticmethod 
     
    153155                        model_enabled_dict.pop(model_name) 
    154156                    except: 
    155                         logging.error("CategoryInstaller: %s", sys.exc_value) 
     157                        logger.error("CategoryInstaller: %s", sys.exc_value) 
    156158                else: 
    157159                    add_list.remove(model_name) 
  • src/sas/sasgui/guiframe/CategoryManager.py

    r212bfc2 rc155a16  
    2020from sas.sasgui.guiframe.CategoryInstaller import CategoryInstaller 
    2121IS_MAC = (sys.platform == 'darwin') 
     22 
     23logger = logging.getLogger() 
    2224 
    2325""" Notes 
     
    373375                    self.master_category_dict = json.load(f) 
    374376        except IOError: 
    375             logging.error('Problem reading in category file.') 
     377            logger.error('Problem reading in category file.') 
    376378 
    377379        self._regenerate_model_dict() 
  • src/sas/sasgui/guiframe/config.py

    rf9d1f60 rc155a16  
    77import sas.sasview 
    88import logging 
     9 
     10 
     11logger = logging.getLogger() 
     12 
    913 
    1014# Version of the application 
     
    5761 
    5862icon_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "images")) 
    59 logging.info("icon path: %s" % icon_path) 
     63logger.info("icon path: %s" % icon_path) 
    6064media_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "media")) 
    6165test_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "test")) 
  • src/sas/sasgui/guiframe/data_manager.py

    r2ffe241 rc155a16  
    2525from sas.sasgui.guiframe.dataFitting import Data2D 
    2626import time 
     27 
     28logger = logging.getLogger() 
    2729 
    2830class DataManager(object): 
     
    136138                msg = "Data manager already stores %s" % str(data.name) 
    137139                msg += "" 
    138                 logging.info(msg) 
     140                logger.info(msg) 
    139141                data_state = self.stored_data[id] 
    140142                data_state.data = data 
  • src/sas/sasgui/guiframe/documentation_window.py

    rd85c194 rc155a16  
    2020import urllib 
    2121import sys 
     22 
     23logger = logging.getLogger() 
    2224 
    2325SPHINX_DOC_ENV = "SASVIEW_DOC_PATH" 
     
    7173 
    7274        if not os.path.exists(file_path): 
    73             logging.error("Could not find Sphinx documentation at %s \ 
     75            logger.error("Could not find Sphinx documentation at %s \ 
    7476            -- has it been built?", file_path) 
    7577        elif WX_SUPPORTS_HTML2: 
     
    7981            self.Show() 
    8082        else: 
    81             logging.error("No html2 support, popping up a web browser") 
     83            logger.error("No html2 support, popping up a web browser") 
    8284            #For cases that do not build against current version dependency 
    8385            # Wx 3.0 we provide a webbrowser call - this is particularly for 
  • src/sas/sasgui/guiframe/gui_manager.py

    r73cbeec rc155a16  
    4848from matplotlib import _pylab_helpers 
    4949 
     50logger = logging.getLogger() 
     51 
    5052warnings.simplefilter("ignore") 
    5153 
     
    6466    if os.path.isfile(os.path.join(app_path, "custom_config.py")): 
    6567        app_path = os.path.abspath(app_path) 
    66         logging.info("Using application path: %s", app_path) 
     68        logger.info("Using application path: %s", app_path) 
    6769        return app_path 
    6870 
    6971    # Next, try the current working directory 
    7072    if os.path.isfile(os.path.join(os.getcwd(), "custom_config.py")): 
    71         logging.info("Using application path: %s", os.getcwd()) 
     73        logger.info("Using application path: %s", os.getcwd()) 
    7274        return os.path.abspath(os.getcwd()) 
    7375 
     
    7678    # clean all these module variables and put them into a config class 
    7779    # that can be passed by sasview.py. 
    78     logging.info(sys.executable) 
    79     logging.info(str(sys.argv)) 
     80    logger.info(sys.executable) 
     81    logger.info(str(sys.argv)) 
    8082    from sas import sasview as sasview 
    8183    app_path = os.path.dirname(sasview.__file__) 
    82     logging.info("Using application path: %s", app_path) 
     84    logger.info("Using application path: %s", app_path) 
    8385    return app_path 
    8486 
     
    104106        config_module = imp.load_module(file, fObj, path_config, descr) 
    105107    except: 
    106         logging.error("Error loading %s/%s: %s" % (path, file, sys.exc_value)) 
     108        logger.error("Error loading %s/%s: %s" % (path, file, sys.exc_value)) 
    107109    finally: 
    108110        if fObj is not None: 
    109111            fObj.close() 
    110     logging.info("GuiManager loaded %s/%s" % (path, file)) 
     112    logger.info("GuiManager loaded %s/%s" % (path, file)) 
    111113    return config_module 
    112114 
     
    125127        # Didn't find local config, load the default 
    126128        import sas.sasgui.guiframe.config as config 
    127         logging.info("using default local_config") 
     129        logger.info("using default local_config") 
    128130    else: 
    129         logging.info("found local_config in %s" % os.getcwd()) 
     131        logger.info("found local_config in %s" % os.getcwd()) 
    130132else: 
    131     logging.info("found local_config in %s" % PATH_APP) 
     133    logger.info("found local_config in %s" % PATH_APP) 
    132134 
    133135from sas.sasgui.guiframe.customdir import SetupCustom 
     
    138140    if custom_config is None: 
    139141        msgConfig = "Custom_config file was not imported" 
    140         logging.info(msgConfig) 
     142        logger.info(msgConfig) 
    141143    else: 
    142         logging.info("using custom_config in %s" % os.getcwd()) 
     144        logger.info("using custom_config in %s" % os.getcwd()) 
    143145else: 
    144     logging.info("using custom_config from %s" % c_conf_dir) 
     146    logger.info("using custom_config from %s" % c_conf_dir) 
    145147 
    146148# read some constants from config 
     
    374376                    frame.SetIcon(icon) 
    375377                except: 
    376                     logging.error("ViewerFrame.put_icon: could not set icon") 
     378                    logger.error("ViewerFrame.put_icon: could not set icon") 
    377379 
    378380    def get_client_size(self): 
     
    803805                                                str(self._input_file)) 
    804806            msg += str(sys.exc_value) + '\n' 
    805             logging.error(msg) 
     807            logger.error(msg) 
    806808        if self._data_panel is not None and len(self.plugins) > 0: 
    807809            self._data_panel.fill_cbox_analysis(self.plugins) 
     
    869871            if plugin.__class__ == item.__class__: 
    870872                msg = "Plugin %s already loaded" % plugin.sub_menu 
    871                 logging.info(msg) 
     873                logger.info(msg) 
    872874                is_loaded = True 
    873875        if not is_loaded: 
    874876            self.plugins.append(plugin) 
    875877            msg = "Plugin %s appended" % plugin.sub_menu 
    876             logging.info(msg) 
     878            logger.info(msg) 
    877879 
    878880    def _get_local_plugins(self): 
     
    894896                msg = "ViewerFrame._get_local_plugins:" 
    895897                msg += "cannot import dataloader plugin.\n %s" % sys.exc_value 
    896                 logging.error(msg) 
     898                logger.error(msg) 
    897899        if style2 == GUIFRAME.PLOTTING_ON: 
    898900            try: 
     
    904906                msg = "ViewerFrame._get_local_plugins:" 
    905907                msg += "cannot import plotting plugin.\n %s" % sys.exc_value 
    906                 logging.error(msg) 
     908                logger.error(msg) 
    907909 
    908910        return plugins 
     
    949951                                plugins.append(module.Plugin()) 
    950952                                msg = "Found plug-in: %s" % module.PLUGIN_ID 
    951                                 logging.info(msg) 
     953                                logger.info(msg) 
    952954                            except: 
    953955                                msg = "Error accessing PluginPanel" 
     
    956958                    except: 
    957959                        msg = "ViewerFrame._find_plugins: %s" % sys.exc_value 
    958                         logging.error(msg) 
     960                        logger.error(msg) 
    959961                    finally: 
    960962                        if file is not None: 
     
    963965            # Should raise and catch at a higher level and 
    964966            # display error on status bar 
    965             logging.error(sys.exc_value) 
     967            logger.error(sys.exc_value) 
    966968 
    967969        return plugins 
     
    13851387 
    13861388        if config._do_aboutbox: 
    1387             logging.info("Doing help menu") 
     1389            logger.info("Doing help menu") 
    13881390            wx_id = wx.NewId() 
    13891391            self._help_menu.Append(wx_id, '&About', 'Software information') 
     
    17461748                del self.panels[ID] 
    17471749        else: 
    1748             logging.error("delete_panel: No such plot id as %s" % ID) 
     1750            logger.error("delete_panel: No such plot id as %s" % ID) 
    17491751 
    17501752    def create_gui_data(self, data, path=None): 
     
    17631765            log_msg += "load: %s\n" % str(basename) 
    17641766            log_msg += "Try Data opening...." 
    1765             logging.error(log_msg) 
     1767            logger.error(log_msg) 
    17661768            return 
    17671769 
     
    18431845            log_msg += "load: %s\n" % str(path) 
    18441846            log_msg += "Try File opening ...." 
    1845             logging.error(log_msg) 
     1847            logger.error(log_msg) 
    18461848            return 
    18471849        log_msg = '' 
     
    18491851        error_message = "" 
    18501852        try: 
    1851             logging.info("Loading Data...:\n" + str(path) + "\n") 
     1853            logger.info("Loading Data...:\n" + str(path) + "\n") 
    18521854            temp = self.loader.load(path) 
    18531855            if temp.__class__.__name__ == "list": 
     
    18641866            error_message += " Data from cmd:\n %s\n" % str(path) 
    18651867            error_message += str(sys.exc_value) + "\n" 
    1866             logging.error(error_message) 
     1868            logger.error(error_message) 
    18671869 
    18681870    def load_folder(self, path): 
     
    18851887            error_message += " Data folder from cmd:\n %s\n" % str(path) 
    18861888            error_message += str(sys.exc_value) + "\n" 
    1887             logging.error(error_message) 
     1889            logger.error(error_message) 
    18881890 
    18891891    def _on_open_state_application(self, event): 
     
    20442046                msg += "and model selected. " 
    20452047                msg += "No project was saved to %s" % (str(path)) 
    2046                 logging.warning(msg) 
     2048                logger.warning(msg) 
    20472049                wx.PostEvent(self, StatusEvent(status=msg, info="error")) 
    20482050        except Exception: 
     
    21112113        #IF SAS_OPENCL is set, settings are stored in the custom config file 
    21122114        self._write_opencl_config_file() 
    2113         logging.info(" --- SasView session was closed --- \n") 
     2115        logger.info(" --- SasView session was closed --- \n") 
    21142116        wx.Exit() 
    21152117        sys.exit() 
     
    21402142            new_config_file.close() 
    21412143        else: 
    2142             logging.info("Failed to save OPENCL settings in custom config file") 
     2144            logger.info("Failed to save OPENCL settings in custom config file") 
    21432145 
    21442146 
     
    21572159                #  
    21582160                content = response.read().strip() 
    2159                 logging.info("Connected to www.sasview.org. Latest version: %s" 
     2161                logger.info("Connected to www.sasview.org. Latest version: %s" 
    21602162                             % (content)) 
    21612163                version_info = json.loads(content) 
    21622164            except: 
    2163                 logging.info("Failed to connect to www.sasview.org") 
     2165                logger.info("Failed to connect to www.sasview.org") 
    21642166        self._process_version(version_info, standalone=event is None) 
    21652167 
     
    22012203            msg = "guiframe: could not get latest application" 
    22022204            msg += " version number\n  %s" % sys.exc_value 
    2203             logging.error(msg) 
     2205            logger.error(msg) 
    22042206            if not standalone: 
    22052207                msg = "Could not connect to the application server." 
     
    22482250                    dialog.Show(True) 
    22492251                except: 
    2250                     logging.error("Error in _onTutorial: %s" % sys.exc_value) 
     2252                    logger.error("Error in _onTutorial: %s" % sys.exc_value) 
    22512253                    try: 
    22522254                        # Try an alternate method 
    2253                         logging.error( 
     2255                        logger.error( 
    22542256                            "Could not open the tutorial pdf, trying xhtml2pdf") 
    22552257                        from xhtml2pdf import pisa 
    22562258                        pisa.startViewer(path) 
    22572259                    except: 
    2258                         logging.error( 
     2260                        logger.error( 
    22592261                            "Could not open the tutorial pdf with xhtml2pdf") 
    22602262                        msg = "This feature requires 'PDF Viewer'\n" 
     
    22672269                    try: 
    22682270                        # Try an alternate method 
    2269                         logging.error( 
     2271                        logger.error( 
    22702272                            "Could not open the tutorial pdf, trying xhtml2pdf") 
    22712273                        from xhtml2pdf import pisa 
    22722274                        pisa.startViewer(path) 
    22732275                    except: 
    2274                         logging.error( 
     2276                        logger.error( 
    22752277                            "Could not open the tutorial pdf with xhtml2pdf") 
    22762278                        msg = "This feature requires the Preview application\n" 
     
    24112413        else: 
    24122414            msg = "Guiframe does not have a current perspective" 
    2413             logging.info(msg) 
     2415            logger.info(msg) 
    24142416 
    24152417    def set_theory(self, state_id, theory_id=None): 
     
    24222424            except: 
    24232425                msg = "Guiframe set_theory: \n" + str(sys.exc_value) 
    2424                 logging.info(msg) 
     2426                logger.info(msg) 
    24252427                wx.PostEvent(self, StatusEvent(status=msg, info="error")) 
    24262428        else: 
    24272429            msg = "Guiframe does not have a current perspective" 
    2428             logging.info(msg) 
     2430            logger.info(msg) 
    24292431 
    24302432    def plot_data(self, state_id, data_id=None, 
     
    25082510                                            action='remove')) 
    25092511        except: 
    2510             logging.error(sys.exc_value) 
     2512            logger.error(sys.exc_value) 
    25112513 
    25122514    def save_data1d(self, data, fname): 
     
    33063308            msg = "%s Could not load " % str(APPLICATION_NAME) 
    33073309            msg += "input file from command line.\n" 
    3308             logging.error(msg) 
     3310            logger.error(msg) 
    33093311        # Display a splash screen on top of the frame. 
    33103312        try: 
     
    33203322            msg = "Cannot display splash screen\n" 
    33213323            msg += str(sys.exc_value) 
    3322             logging.error(msg) 
     3324            logger.error(msg) 
    33233325            self.frame.Show() 
    33243326 
     
    33753377                            os.remove(file_path) 
    33763378                except: 
    3377                     logging.error("gui_manager.clean_plugin_models:\n  %s" 
     3379                    logger.error("gui_manager.clean_plugin_models:\n  %s" 
    33783380                                  % sys.exc_value) 
    33793381 
  • src/sas/sasgui/guiframe/gui_statusbar.py

    r3a22ce7 rc155a16  
    1212from sas.sasgui.guiframe.gui_style import GUIFRAME_ICON 
    1313 
     14logger = logging.getLogger() 
     15 
    1416# Number of fields on the status bar 
    1517NB_FIELDS = 4 
     
    7173            icon_type = event.info.lower() 
    7274            if icon_type == "warning": 
    73                 logging.warning(status) 
     75                logger.warning(status) 
    7476                color = (0, 0, 255) # blue 
    7577                icon_bmp = wx.ArtProvider.GetBitmap(wx.ART_WARNING, 
    7678                                                    wx.ART_TOOLBAR) 
    7779            if icon_type == "error": 
    78                 logging.error(status) 
     80                logger.error(status) 
    7981                color = (255, 0, 0) # red 
    8082                icon_bmp = wx.ArtProvider.GetBitmap(wx.ART_ERROR, 
  • src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py

    ra674d0b rc155a16  
    77import wx 
    88import logging 
     9 
     10logger = logging.getLogger() 
    911 
    1012from sas.sascalc.dataloader.loader import Loader 
     
    160162                message += "\tError: {0}\n".format(error_data) 
    161163        else: 
    162             logging.error("Loader returned an invalid object:\n %s" % str(item)) 
     164            logger.error("Loader returned an invalid object:\n %s" % str(item)) 
    163165            data_error = True 
    164166 
     
    182184                log_msg += "Please try to open that file from \"open project\"" 
    183185                log_msg += "or \"open analysis\" menu." 
    184                 logging.info(log_msg) 
     186                logger.info(log_msg) 
    185187                file_errors[basename] = [log_msg] 
    186188                continue 
     
    212214 
    213215            except: 
    214                 logging.error(sys.exc_value) 
     216                logger.error(sys.exc_value) 
    215217 
    216218                error_message = "The Data file you selected could not be loaded.\n" 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter1D.py

    r29e872e rc155a16  
    2424from appearanceDialog import appearanceDialog 
    2525from graphAppearance import graphAppearance 
     26 
     27logger = logging.getLogger() 
    2628 
    2729DEFAULT_QMAX = 0.05 
     
    242244                    wx.PostEvent(self.parent, StatusEvent(status=position)) 
    243245            except: 
    244                 logging.error(sys.exc_value) 
     246                logger.error(sys.exc_value) 
    245247            if not event.leftdown: 
    246248                # text event 
     
    255257                        self.canvas.draw() 
    256258                except: 
    257                     logging.error(sys.exc_value) 
     259                    logger.error(sys.exc_value) 
    258260                event.Skip() 
    259261                return 
     
    409411            self.q_ctrl[vl_ind].SetValue(str(pos_x)) 
    410412        except: 
    411             logging.error(sys.exc_value) 
     413            logger.error(sys.exc_value) 
    412414 
    413415    def set_resizing(self, resizing=False): 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter2D.py

    rb2b36932 rc155a16  
    3030from graphAppearance import graphAppearance 
    3131(InternalEvent, EVT_INTERNAL) = wx.lib.newevent.NewEvent() 
     32 
     33logger = logging.getLogger() 
    3234 
    3335DEFAULT_QMAX = 0.05 
     
    432434            except: 
    433435                msg = "Add Text: Error. Check your property values..." 
    434                 logging.error(msg) 
     436                logger.error(msg) 
    435437                if self.parent != None: 
    436438                    wx.PostEvent(self.parent, StatusEvent(status=msg)) 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/binder.py

    rd85c194 rc155a16  
    44import logging 
    55import sys 
     6 
     7logger = logging.getLogger() 
    68 
    79class Selection(object): 
     
    7072            canvas.mpl_disconnect(canvas.scroll_pick_id) 
    7173        except: 
    72             logging.error(sys.exc_value) 
     74            logger.error(sys.exc_value) 
    7375        self.canvas = canvas 
    7476        self.figure = figure 
  • src/sas/sasgui/guiframe/proxy.py

    rd85c194 rc155a16  
    66import logging 
    77import re 
     8 
     9 
     10logger = logging.getLogger() 
    811 
    912''' 
     
    7174        proxy_url_list = [] 
    7275        for this_pac_url in pac_urls_list: 
    73             logging.debug('Trying pac file (%s)...' % this_pac_url) 
     76            logger.debug('Trying pac file (%s)...' % this_pac_url) 
    7477            try: 
    7578                response = urllib2.urlopen( 
    7679                    this_pac_url, timeout=self.timeout) 
    77                 logging.debug('Succeeded (%s)...' % this_pac_url) 
     80                logger.debug('Succeeded (%s)...' % this_pac_url) 
    7881            except Exception: 
    79                 logging.debug('Failled (%s)...' % this_pac_url) 
     82                logger.debug('Failled (%s)...' % this_pac_url) 
    8083                continue 
    8184            pacStr = response.read() 
     
    120123        response = None 
    121124        try: 
    122             logging.debug("Trying Direct connection to %s..."%self.url) 
     125            logger.debug("Trying Direct connection to %s..."%self.url) 
    123126            response = urllib2.urlopen(req, timeout=self.timeout) 
    124127        except Exception, e: 
    125             logging.debug("Failed!") 
    126             logging.debug(e) 
     128            logger.debug("Failed!") 
     129            logger.debug(e) 
    127130            try: 
    128                 logging.debug("Trying to use system proxy if it exists...") 
     131                logger.debug("Trying to use system proxy if it exists...") 
    129132                self._set_proxy() 
    130133                response = urllib2.urlopen(req, timeout=self.timeout) 
    131134            except Exception, e: 
    132                 logging.debug("Failed!") 
    133                 logging.debug(e) 
     135                logger.debug("Failed!") 
     136                logger.debug(e) 
    134137                pac_urls = self._get_addresses_of_proxy_pac() 
    135138                proxy_urls = self._parse_proxy_pac(pac_urls) 
    136139                for proxy in proxy_urls: 
    137140                    try: 
    138                         logging.debug("Trying to use the proxy %s found in proxy.pac configuration"%proxy) 
     141                        logger.debug("Trying to use the proxy %s found in proxy.pac configuration"%proxy) 
    139142                        self._set_proxy(proxy) 
    140143                        response = urllib2.urlopen(req, timeout=self.timeout) 
    141144                    except Exception, e: 
    142                         logging.debug("Failed!") 
    143                         logging.debug(e) 
     145                        logger.debug("Failed!") 
     146                        logger.debug(e) 
    144147        if response is not None: 
    145             logging.debug("The connection to %s was successful."%self.url) 
     148            logger.debug("The connection to %s was successful."%self.url) 
    146149        else: 
    147             logging.warning("Connection to %s failed..."%self.url) 
     150            logger.warning("Connection to %s failed..."%self.url) 
    148151        return response 
    149152 
  • src/sas/sasgui/guiframe/report_dialog.py

    r6dd6e32 rc155a16  
    77import sys 
    88import wx.html as html 
     9 
     10logger = logging.getLogger() 
    911 
    1012ISPDF = False 
     
    135137            return pisaStatus.err 
    136138        except: 
    137             logging.error("Error creating pdf: %s" % sys.exc_value) 
     139            logger.error("Error creating pdf: %s" % sys.exc_value) 
    138140        return False 
    139141 
Note: See TracChangeset for help on using the changeset viewer.