Changeset 158a0c7 in sasview


Ignore:
Timestamp:
Jul 13, 2018 4:24:30 AM (6 weeks ago)
Author:
tcbennun
Branches:
ESS_GUI_iss957
Children:
41d6187
Parents:
5dba493 (diff), ecbfddd (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 useful commits from ESS_GUI

  • commit 'ecbfddd': add VS files, stackdumps to gitignore check whether .py files are outdated before generating them from .ui or .qrc files (huge startup speed-up) Update version number to 5.0 - SASVIEW-949 CR: Deleting a single dataitem child will close the corresponding plot (SASVIEW-958) corrections to GUITests doc add documentation to GUITests
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

    r846a063 recbfddd  
    1010# Feel free to add more stuff to this as and when it becomes an issue. 
    1111 
     12# stack dumps due to Git Bash internal crashes 
     13*.stackdump 
     14 
    1215# Editor files 
     16*.pyproj 
    1317.DS_Store 
    1418/.settings 
     
    1721/.pydevproject 
    1822/.idea 
     23/.vs 
    1924 
    2025# Build and run files 
  • src/sas/qtgui/GUITests.py

    r57be490 rd0528c4  
    33from PyQt5 import QtGui 
    44from PyQt5 import QtWidgets 
     5 
     6""" 
     7Unit tests for the QT GUI 
     8========================= 
     9 
     10In order to run the tests, first install SasView and sasmodels to site-packages 
     11by running ``python setup.py install`` in both repositories. 
     12 
     13The tests can be run with ``python GUITests.py``, or to get more verbose 
     14console output (recommended), use ``python GUITests.py -v``. 
     15""" 
    516 
    617# Prepare the general QApplication instance 
  • src/sas/qtgui/MainWindow/DataExplorer.py

    rd9150d8 r6ff103a  
    496496        # Now query the model item for available plots 
    497497        plots = GuiUtils.plotsFromFilename(filename, model) 
    498         item = GuiUtils.itemFromFilename(filename, model) 
    499498 
    500499        new_plots = [] 
    501         for plot in plots: 
     500        for item, plot in plots.items(): 
    502501            plot_id = plot.id 
    503502            if plot_id in list(self.active_plots.keys()): 
  • src/sas/qtgui/Utilities/GuiUtils.py

    re20870b r6ff103a  
    415415    assert isinstance(filename, str) 
    416416 
    417     plot_data = [] 
     417    plot_data = {} 
    418418    # Iterate over model looking for named items 
    419419    for index in range(model_item.rowCount()): 
     
    421421        if str(item.text()) == filename: 
    422422            # TODO: assure item type is correct (either data1/2D or Plotter) 
    423             plot_data.append(item.child(0).data()) 
     423            plot_data[item] = item.child(0).data() 
    424424            # Going 1 level deeper only 
    425425            for index_2 in range(item.rowCount()): 
     
    427427                if item_2 and item_2.isCheckable(): 
    428428                    # TODO: assure item type is correct (either data1/2D or Plotter) 
    429                     plot_data.append(item_2.child(0).data()) 
     429                    plot_data[item_2] = item_2.child(0).data() 
    430430 
    431431    return plot_data 
  • src/sas/qtgui/convertUI.py

    rc03692f r67642f7  
    1313    os.system(execute) 
    1414 
     15def file_in_newer(file_in, file_out): 
     16    """ 
     17    Check whether file_in is newer than file_out, if file_out exists. 
     18 
     19    Returns True if file_in is newer, or if file_out doesn't exist; False 
     20    otherwise. 
     21    """ 
     22    try: 
     23        out_stat = os.stat(file_out) 
     24    except OSError: 
     25        # file_out does not exist 
     26        return True 
     27 
     28    in_stat = os.stat(file_in) 
     29 
     30    # simple comparison of modification time 
     31    return in_stat.st_mtime >= out_stat.st_mtime 
     32 
    1533# look for .ui files 
    1634for root, dirs, files in os.walk("."): 
     
    1937            file_in = os.path.join(root, file) 
    2038            file_out = os.path.splitext(file_in)[0]+'.py' 
    21             pyuic(file_in, file_out) 
     39            if file_in_newer(file_in, file_out): 
     40                print("Generating " + file_out + " ...") 
     41                pyuic(file_in, file_out) 
    2242 
    2343# RC file in UI directory 
     
    2747out_file = 'main_resources_rc.py' 
    2848 
    29 pyrrc(os.path.join(ui_root, rc_file), os.path.join(ui_root, out_file)) 
     49in_file = os.path.join(ui_root, rc_file) 
     50out_file = os.path.join(ui_root, out_file) 
     51 
     52if file_in_newer(in_file, out_file): 
     53    print("Generating " + out_file + " ...") 
     54    pyrrc(in_file, out_file) 
    3055 
    3156# Images 
     
    3459rc_file = 'images.qrc' 
    3560out_file = 'images_rc.py' 
    36 pyrrc(os.path.join(images_root, rc_file), os.path.join(out_root, out_file)) 
     61 
     62in_file = os.path.join(images_root, rc_file) 
     63out_file = os.path.join(ui_root, out_file) 
     64 
     65if file_in_newer(in_file, out_file): 
     66    print("Generating " + out_file + " ...") 
     67    pyrrc(in_file, out_file) 
     68 
  • src/sas/sasview/__init__.py

    r6a88ad9 r18f11a6  
    1 __version__ = "4.1" 
     1__version__ = "5.0" 
    22__build__ = "GIT_COMMIT" 
  • src/sas/logger_config.py

    rcee5c78 r5dba493  
    88import pkg_resources 
    99 
     10import sas.qtgui.Utilities.LocalConfig as LocalConfig 
    1011 
    1112''' 
     
    2930            logging.captureWarnings(True) 
    3031            logger = logging.getLogger(self.name) 
     32 
     33        # use this as a final override if the need arises 
     34        logging.disable(LocalConfig.DISABLE_LOGGING) 
     35 
    3136        return logger 
    3237 
     
    3843        self._update_all_logs_to_debug(logger) 
    3944        logging.captureWarnings(True) 
     45 
     46        # use this as a final override if the need arises 
     47        logging.disable(LocalConfig.DISABLE_LOGGING) 
     48 
    4049        return logger 
    4150 
     
    4958        ''' 
    5059        for handler in logger.handlers or logger.parent.handlers: 
    51             #handler.setLevel(logging.DEBUG) 
    52             handler.setLevel(logging.WARNING) 
     60            handler.setLevel(logging.DEBUG) 
    5361        for name, _ in logging.Logger.manager.loggerDict.items(): 
    54             #logging.getLogger(name).setLevel(logging.DEBUG) 
    55             logging.getLogger(name).setLevel(logging.WARNING) 
     62            logging.getLogger(name).setLevel(logging.DEBUG) 
    5663 
    5764    def _find_config_file(self, filename="logging.ini"): 
  • src/sas/logging.ini

    r7c105e8 r5dba493  
    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/MainWindow.py

    ra3221b6 r5dba493  
    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 r5dba493  
    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 r5dba493  
    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 r5dba493  
    77 
    88class XStream(QObject): 
     9    """ 
     10    Imitates, loosely, an `io.TextIOWrapper` class in order to intercept 
     11    messages going to stdout and stderr. 
     12 
     13    To intercept messages to stdout, use: 
     14 
     15    .. code-block:: python 
     16       XStream.stdout().messageWritten.mySignalHandler() 
     17 
     18    All messages to stdout will now also be emitted to your handler. Use 
     19    `XStream.stderr()` in the same way to intercept stderr messages. 
     20 
     21    An additional function, `XStream.write_log()`, emits a message only to the 
     22    messageWritten signal, and not the stdout or stderr streams. It is intended 
     23    for separation of log handling between console and Qt, as reflected in the 
     24    name. 
     25    """ 
    926    _stdout = None 
    1027    _stderr = None 
    1128    messageWritten = pyqtSignal(str) 
     29 
     30    _real_stream = None 
    1231 
    1332    def flush(self): 
     
    1837 
    1938    def write(self, msg): 
     39        """ 
     40        'msg' is emitted in the messageWritten signal, and is also written to 
     41        the original stream. This means stdout/stderr messages have been 
     42        redirected to a custom location (e.g. in-widget), but also reach 
     43        console output. 
     44 
     45        :param msg: message to write 
     46        :return: None 
     47        """ 
     48        if(not self.signalsBlocked()): 
     49            self.messageWritten.emit(str(msg)) 
     50        self._real_stream.write(msg) 
     51 
     52    def write_log(self, msg): 
     53        """ 
     54        'msg' is only emitted in the messageWritten signal, not in the original 
     55        stdout/stderr stream, for the purposes of logging. Use in, e.g. a 
     56        custom logging handler's emit() function. 
     57 
     58        :param msg: message to write 
     59        :return: None 
     60        """ 
    2061        if(not self.signalsBlocked()): 
    2162            self.messageWritten.emit(str(msg)) 
     
    2364    @staticmethod 
    2465    def stdout(): 
     66        """ 
     67        Creates imitation of sys.stdout. 
     68        :return: An XStream instance that interfaces exactly like sys.stdout, 
     69                 but, has redirection capabilities through the 
     70                 messageWritten(str) signal. 
     71        """ 
    2572        if(not XStream._stdout): 
    2673            XStream._stdout = XStream() 
     74            XStream._stdout._real_stream = sys.stdout 
    2775            sys.stdout = XStream._stdout 
    2876        return XStream._stdout 
     
    3078    @staticmethod 
    3179    def stderr(): 
     80        """ 
     81        Creates imitation of sys.stderr. 
     82        :return: An XStream instance that interfaces exactly like sys.stderr, 
     83                 but, has redirection capabilities through the 
     84                 messageWritten(str) signal. 
     85        """ 
    3286        if(not XStream._stderr): 
    3387            XStream._stderr = XStream() 
     88            XStream._stderr._real_stream = sys.stderr 
    3489            sys.stderr = XStream._stderr 
    3590        return XStream._stderr 
    3691 
     92 
    3793class QtHandler(logging.Handler): 
    3894    """ 
    39     Version of logging handler 
    40     "emitting" the message to custom stdout() 
     95    Version of logging handler "emitting" the message to custom stdout() 
    4196    """ 
    4297    def __init__(self): 
     
    46101        record = self.format(record) 
    47102        if record: 
    48             XStream.stdout().write('%s\n'%record) 
     103            XStream.stdout().write_log('%s\n'%record) 
    49104 
    50105 
     
    52107logger = logging.getLogger() 
    53108 
    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')) 
    59109# Add the qt-signal logger 
    60110handler = QtHandler() 
    61 handler.setFormatter(logging.Formatter("%(levelname)s: %(message)s")) 
     111handler.setFormatter(logging.Formatter( 
     112    fmt="%(asctime)s - %(levelname)s: %(message)s", 
     113    datefmt="%H:%M:%S" 
     114)) 
    62115logger.addHandler(handler) 
Note: See TracChangeset for help on using the changeset viewer.