def test_msgs(): msgs = pypmsgs.Messages(None, verbosity=1) msgs.info("test 123") msgs.warn("test 123") msgs.bug("test 123") msgs.work("test 123") msgs.close()
def test_log_write(): outfil = 'tst.log' msgs = pypmsgs.Messages(outfil, verbosity=1) msgs.close() # Insure scipy, numpy, astropy are being version with open(outfil, 'r') as f: lines = f.readlines() pckgs = ['scipy', 'numpy', 'astropy'] flgs = [False]*len(pckgs) for line in lines: for jj,pckg in enumerate(pckgs): if pckg in line: flgs[jj] = True for flg in flgs: assert flg is True
The current main purpose of this is to provide package-level globals that can be imported by submodules. """ # Imports for signal and log handling import sys import signal import warnings # Set version __version__ = '0.10.2dev' # Import and instantiate the logger from pypeit import pypmsgs msgs = pypmsgs.Messages() from pypeit import check_requirements # THIS IMPORT DOES THE CHECKING. KEEP IT # Import the close_qa method so that it can be called when a hard stop # is requested by the user from pypeit.core.qa import close_qa # Send all signals to messages to be dealt with (i.e. someone hits ctrl+c) def signal_handler(signalnum, handler): """ Handle signals sent by the keyboard during code execution """ if signalnum == 2: msgs.info('Ctrl+C was pressed. Ending processes...')