def __init__(self, log, debug, verbose, colors=True): """ Initialize the Message logging class Parameters ---------- log : str or None Name of saved log file (no log will be saved if log=="") debug : dict dict used for debugging. 'LOAD', 'BIAS', 'ARC', 'TRACE' verbose : int (0,1,2) Level of verbosity: 0 = No output 1 = Minimal output (default - suitable for the average user) 2 = All output colors : bool If true, the screen output will have colors, otherwise normal screen output will be displayed """ # Version from pypit import pyputils version, last_updated = pyputils.get_version() # Import for version import scipy import numpy import astropy # Initialize the log if log is not None: self._log = open(log, 'w') else: self._log = log # Initialize other variables self._debug = debug self._last_updated = last_updated self._version = version self._verbose = verbose self.sciexp = None # Save the version of the code including last update information to the log file if self._log: self._log.write("------------------------------------------------------\n\n") self._log.write("PYPIT was last updated {0:s}\n".format(last_updated)) self._log.write("This log was generated with version {0:s} of PYPIT\n\n".format(version)) self._log.write("You are using scipy version={:s}\n".format(scipy.__version__)) self._log.write("You are using numpy version={:s}\n".format(numpy.__version__)) self._log.write("You are using astropy version={:s}\n\n".format(astropy.__version__)) self._log.write("------------------------------------------------------\n\n") # Use colors? self._start, self._end = "", "" self._black_CL, self._yellow_CL, self._blue_CL, self._green_CL, self._red_CL = "", "", "", "", "" self._white_RD, self._white_GR, self._white_BK = "", "", "" self._white_BL, self._black_YL, self._yellow_BK = "", "", "" if colors: self.enablecolors() else: self.disablecolors()
def test_version(): # Dummy self ver,upd = pyputils.get_version() assert isinstance(ver,basestring)