Changeset 200ce9c in sasview


Ignore:
Timestamp:
Jul 20, 2018 3:54:02 AM (5 weeks ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_beta_approx, ESS_GUI_iss971, ESS_GUI_iss976
Children:
6548a01
Parents:
a2b74bb (diff), e4335ae (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'ESS_GUI' of https://github.com/SasView/sasview into ESS_GUI

Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • src/sas/logger_config.py

    rcee5c78 re4335ae  
    77 
    88import pkg_resources 
    9  
    109 
    1110''' 
     
    2928            logging.captureWarnings(True) 
    3029            logger = logging.getLogger(self.name) 
     30 
    3131        return logger 
    3232 
     
    3838        self._update_all_logs_to_debug(logger) 
    3939        logging.captureWarnings(True) 
     40 
    4041        return logger 
    4142 
     
    4950        ''' 
    5051        for handler in logger.handlers or logger.parent.handlers: 
    51             #handler.setLevel(logging.DEBUG) 
    52             handler.setLevel(logging.WARNING) 
     52            handler.setLevel(logging.DEBUG) 
    5353        for name, _ in logging.Logger.manager.loggerDict.items(): 
    54             #logging.getLogger(name).setLevel(logging.DEBUG) 
    55             logging.getLogger(name).setLevel(logging.WARNING) 
     54            logging.getLogger(name).setLevel(logging.DEBUG) 
    5655 
    5756    def _find_config_file(self, filename="logging.ini"): 
  • src/sas/logging.ini

    r7c105e8 re4335ae  
    1212#format=%(asctime)s - %(name)s - %(levelname)s - %(message)s 
    1313#format=%(asctime)s - %(levelname)s : %(name)s:%(pathname)s:%(lineno)4d: %(message)s 
    14 format=%(asctime)s - %(levelname)s : %(name)s:%(lineno)4d: %(message)s 
     14#format=%(asctime)s - %(levelname)s : %(name)s:%(lineno)4d: %(message)s 
     15format=%(asctime)s - %(levelname)s: %(message)s 
    1516datefmt=%H:%M:%S 
    1617 
  • src/sas/qtgui/MainWindow/GuiManager.py

    rf0a8f74 re4335ae  
    1313# General SAS imports 
    1414from sas.qtgui.Utilities.ConnectionProxy import ConnectionProxy 
    15 from sas.qtgui.Utilities.SasviewLogger import XStream 
     15from sas.qtgui.Utilities.SasviewLogger import setup_qt_logging 
    1616 
    1717import sas.qtgui.Utilities.LocalConfig as LocalConfig 
     
    8686 
    8787        # Fork off logging messages to the Log Window 
    88         XStream.stdout().messageWritten.connect(self.listWidget.insertPlainText) 
    89         XStream.stderr().messageWritten.connect(self.listWidget.insertPlainText) 
     88        handler = setup_qt_logging() 
     89        handler.messageWritten.connect(self.appendLog) 
    9090 
    9191        # Log the start of the session 
     
    269269        """ 
    270270        self.statusLabel.setText(text) 
     271 
     272    def appendLog(self, msg): 
     273        """Appends a message to the list widget in the Log Explorer. Use this 
     274        instead of listWidget.insertPlainText() to facilitate auto-scrolling""" 
     275        self.listWidget.append(msg.strip()) 
    271276 
    272277    def createGuiData(self, item, p_file=None): 
  • src/sas/qtgui/MainWindow/MainWindow.py

    ra3221b6 re4335ae  
    1010from sas.qtgui.UI import main_resources_rc 
    1111from .UI.MainWindowUI import Ui_MainWindow 
    12  
    13 # Initialize logging 
    14 import sas.qtgui.Utilities.SasviewLogger 
    1512 
    1613class MainSasViewWindow(QMainWindow, Ui_MainWindow): 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    re20870b re4335ae  
    106106        # Globals 
    107107        self.initializeGlobals() 
    108  
    109         # Set up desired logging level 
    110         logging.disable(LocalConfig.DISABLE_LOGGING) 
    111108 
    112109        # data index for the batch set 
  • src/sas/qtgui/Utilities/LocalConfig.py

    ra0ed202 re4335ae  
    136136USING_TWISTED = True 
    137137 
    138 # Logging levels to disable, if any 
    139 DISABLE_LOGGING = logging.DEBUG 
    140  
    141138# Time out for updating sasview 
    142139UPDATE_TIMEOUT = 2 
    143140 
    144141# Logging levels to disable, if any 
    145 DISABLE_LOGGING = logging.DEBUG 
     142DISABLE_LOGGING = logging.NOTSET 
    146143 
    147144def printEVT(message): 
  • src/sas/qtgui/Utilities/SasviewLogger.py

    r4992ff2 re4335ae  
    66 
    77 
    8 class XStream(QObject): 
    9     _stdout = None 
    10     _stderr = None 
     8class QtHandler(QObject, logging.Handler): 
     9    """ 
     10    Version of logging handler "emitting" the message to custom stdout() 
     11    """ 
    1112    messageWritten = pyqtSignal(str) 
    1213 
    13     def flush(self): 
    14         pass 
    15  
    16     def fileno(self): 
    17         return -1 
    18  
    19     def write(self, msg): 
    20         if(not self.signalsBlocked()): 
    21             self.messageWritten.emit(str(msg)) 
    22  
    23     @staticmethod 
    24     def stdout(): 
    25         if(not XStream._stdout): 
    26             XStream._stdout = XStream() 
    27             sys.stdout = XStream._stdout 
    28         return XStream._stdout 
    29  
    30     @staticmethod 
    31     def stderr(): 
    32         if(not XStream._stderr): 
    33             XStream._stderr = XStream() 
    34             sys.stderr = XStream._stderr 
    35         return XStream._stderr 
    36  
    37 class QtHandler(logging.Handler): 
    38     """ 
    39     Version of logging handler 
    40     "emitting" the message to custom stdout() 
    41     """ 
    4214    def __init__(self): 
     15        QObject.__init__(self) 
    4316        logging.Handler.__init__(self) 
    4417 
     
    4619        record = self.format(record) 
    4720        if record: 
    48             XStream.stdout().write('%s\n'%record) 
     21            self.messageWritten.emit('%s\n'%record) 
    4922 
    5023 
    51 # Define the default logger 
    52 logger = logging.getLogger() 
     24def setup_qt_logging(): 
     25    # Define the default logger 
     26    logger = logging.getLogger() 
    5327 
    54 # Add the file handler 
    55 logging.basicConfig(level=logging.INFO, 
    56                     format='%(asctime)s %(levelname)s %(message)s', 
    57                     filename=os.path.join(os.path.expanduser("~"), 
    58                                           'sasview.log')) 
    59 # Add the qt-signal logger 
    60 handler = QtHandler() 
    61 handler.setFormatter(logging.Formatter("%(levelname)s: %(message)s")) 
    62 logger.addHandler(handler) 
     28    # Add the qt-signal logger 
     29    handler = QtHandler() 
     30    handler.setFormatter(logging.Formatter( 
     31        fmt="%(asctime)s - %(levelname)s: %(message)s", 
     32        datefmt="%H:%M:%S" 
     33    )) 
     34    logger.addHandler(handler) 
     35 
     36    return handler 
  • src/sas/qtgui/Utilities/UnitTesting/SasviewLoggerTest.py

    r53c771e re4335ae  
    1111 
    1212# Local 
    13 from sas.qtgui.Utilities.SasviewLogger import XStream 
    1413from sas.qtgui.Utilities.SasviewLogger import QtHandler 
    1514 
     
    2322        """ 
    2423        self.logger = logging.getLogger(__name__) 
    25         handler = QtHandler() 
    26         handler.setFormatter(logging.Formatter("%(levelname)s: %(message)s")) 
    27         self.logger.addHandler(handler) 
     24        self.handler = QtHandler() 
     25        self.handler.setFormatter(logging.Formatter("%(levelname)s: %(message)s")) 
     26        self.logger.addHandler(self.handler) 
    2827        self.logger.setLevel(logging.DEBUG) 
    2928 
     
    3534        Test redirection of all levels of logging 
    3635        """ 
    37         # Attach the listeners 
    38         XStream.stderr().messageWritten.connect( self.outHandlerGui.insertPlainText ) 
    39         XStream.stdout().messageWritten.connect( self.outHandlerGui.insertPlainText ) 
     36        # Attach the listener 
     37        self.handler.messageWritten.connect(self.outHandlerGui.insertPlainText) 
    4038 
    4139        # Send the signals 
     
    4442        self.logger.warning('warning message') 
    4543        self.logger.error('error message') 
    46         sys.stdout.write('with stdout') 
    47         sys.stderr.write('with stderr') 
    4844 
    4945        out=self.outHandlerGui.toPlainText() 
     
    5450        self.assertIn('WARNING: warning message', out) 
    5551        self.assertIn('ERROR: error message', out) 
    56         self.assertIn('with stdout', out) 
    57         self.assertIn('with stderr', out) 
    5852 
    5953if __name__ == "__main__": 
  • installers/sasview_qt5.spec

    rbb3b1c2 ra2b74bb  
    6666datas.append((os.path.join(PYTHON_LOC,'Library','plugins','platforms'),'platforms')) 
    6767datas.append((os.path.join(PYTHON_LOC,'Lib','site-packages','jedi'),'jedi')) 
    68 datas.append((os.path.join(PYTHON_LOC,'Library','bin', 'libzmq.dll'),'libzmq.pyd')) 
    6968 
    7069# These depend on whether we have MKL or Atlas numpy 
Note: See TracChangeset for help on using the changeset viewer.