Changeset 1067 for SHX


Ignore:
Timestamp:
12/30/15 19:42:17 (4 years ago)
Author:
klaus
Message:

skip sfdb test if no database available; switch off SHX error output during tests

Location:
SHX/trunk/SeismicHandler
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • SHX/trunk/SeismicHandler/commands/switch.py

    r1063 r1067  
    1616class switch(BaseCommand): 
    1717    """ 
    18     This command toogles (global) switches as they are defined in runtime.py. 
     18    This command toggles (global) switches as they are defined in runtime.py. 
    1919 
    2020    If a switch is set to "on" the corresponding variable will be set to "True": 
     
    3535    The switches are limited to the amount defined at 
    3636    URI:http://www.seismic-handler.org/portal/wiki/ShSwitch 
    37     >>> sw = switch("doesnotexists", "off") #doctest: +ELLIPSIS 
     37    >>> sw = switch("doesnotexist", "off") #doctest: +ELLIPSIS 
    3838    Traceback (most recent call last): 
    3939    ... 
    40     ShxError: Unknown switch: Doesnotexists 
     40    ShxError: Unknown switch: Doesnotexist 
    4141 
    4242    Global switches can be changed as well: 
  • SHX/trunk/SeismicHandler/modules/log.py

    r650 r1067  
    88 
    99from SeismicHandler.basics import Singleton 
    10 from SeismicHandler.config import Settings 
     10from SeismicHandler.config import Settings, get_runtime 
    1111from SeismicHandler.basics.messages import msgs, log_message 
    1212 
     
    6868            ) 
    6969        else: 
    70             # additional to console 
    71             console = logging.StreamHandler() 
    72             console.setLevel(getattr(logging, level_screen.upper())) 
    73             #console.setLevel(logging.DEBUG) 
     70            # no console output of error messages in test mode 
     71            in_test_mode = sys.argv[0].endswith("runtests.py") 
     72            if not in_test_mode: 
     73                # additional to console 
     74                console = logging.StreamHandler() 
     75                console.setLevel(getattr(logging, level_screen.upper())) 
     76                #console.setLevel(logging.DEBUG) 
    7477 
    75             # set a format which is simpler for console use 
    76             formatter = \ 
    77                 logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 
     78                # set a format which is simpler for console use 
     79                formatter = \ 
     80                    logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 
    7881 
    79             # tell the handler to use this format 
    80             console.setFormatter(formatter) 
     82                # tell the handler to use this format 
     83                console.setFormatter(formatter) 
    8184 
    82             # add the handler to the root logger 
    83             logging.getLogger('').addHandler(console) 
     85                # add the handler to the root logger 
     86                logging.getLogger('').addHandler(console) 
    8487 
    8588        self.logging = logging 
  • SHX/trunk/SeismicHandler/modules/parse.py

    r1065 r1067  
    1818 
    1919import os 
     20import sys 
    2021import re 
    2122import inspect 
     
    348349    def traceBack(self, error, msg = ""): 
    349350        # This allows debugging as python users are used to it. 
    350         print "\n" + "*"*72 
    351         print self.__recent 
    352         print "*"*72 
    353         traceback.print_exc() 
    354         print "*"*72 
     351        in_test_mode = sys.argv[0].endswith("runtests.py") 
     352        if not in_test_mode: 
     353            print "\n" + "*"*72 
     354            print self.__recent 
     355            print "*"*72 
     356            traceback.print_exc() 
     357            print "*"*72 
    355358        msg = ";".join(error.args) 
    356359 
    357360        # Respect global settings: 
    358361        if self.switches.Sherrstop: 
    359             import sys 
    360362            print >> sys.stderr, error, msg 
    361363            quit() 
  • SHX/trunk/SeismicHandler/modules/wx_.py

    r1065 r1067  
    864864                varpos_start = STATION_INFO 
    865865 
    866         chunk = length / PARTS 
    867         chunk_t = (end - start) / PARTS 
    868866        chunk_t, chunk, labeloffset, pixoffset, PARTS \ 
    869867            = self.niceNumbers( start, end, length, PARTS ) 
     
    910908            elif self.traceOrder in [2, 3]: 
    911909                if self.traceOrder == 2: 
    912                     varpos_current = varpos_start + (PARTS - i) * chunk 
     910                    varpos_current = pixoffset \ 
     911                        + varpos_start + (PARTS - i) * chunk 
    913912                elif self.traceOrder == 3: 
    914                     varpos_current = varpos_start + i * chunk 
     913                    varpos_current = pixoffset + varpos_start + i * chunk 
    915914                canvas.DrawRotatedText(txt, fixpos + TIMESCALE_OFFSET_TEXT, 
    916915                                                   varpos_current + tw / 2, 90) 
  • SHX/trunk/SeismicHandler/tests/runtests.py

    r469 r1067  
    4343    suite.addTest(doctest.DocTestSuite(imp)) 
    4444 
    45 unittest.main(defaultTest="suite") 
     45unittest.main(defaultTest="suite", verbosity=2) 
  • SHX/trunk/SeismicHandler/tests/test_miniseed.py

    r484 r1067  
    2525from obspy.core import UTCDateTime 
    2626from SeismicHandler.modules.miniseed import miniseed 
     27from SeismicHandler.config import Settings 
    2728 
    2829class TestCase(unittest.TestCase): 
     
    4142 
    4243    def testDbAccess(self): 
     44        if len(Settings.config.bgrszo.host) == 1 \ 
     45            and Settings.config.bgrszo.host[0].lower() == 'none': 
     46            self.skipTest( "testDb Access (no SFDB host defined)" ) 
     47            return 
    4348        a = miniseed( 
    4449            stations=["GRA1", "WET"], 
Note: See TracChangeset for help on using the changeset viewer.