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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 
Note: See TracChangeset for help on using the changeset viewer.