Changeset 2315 for trunk/python


Ignore:
Timestamp:
09/29/11 17:08:47 (13 years ago)
Author:
Malte Marquarding
Message:

Ticket #247: Make new summary work in standard asap by handling logger i/o

Location:
trunk/python
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/logging.py

    r1939 r2315  
    1919    create its own casa log sink.
    2020
    21     .. note:: Do instantiate a new one - use the :obj:`asaplog` instead.
     21    .. note:: Do not instantiate a new one - use the :obj:`asaplog` instead.
    2222
    2323    """
     
    5858        self._log = ""
    5959
     60    def clear(self):
     61        if isinstance(self.logger, LogSink):
     62            logs = self.logger.pop()
     63           
    6064    def push(self, msg, newline=True):
    6165        """Push logs into the buffer. post needs to be called to send them.
  • trunk/python/scantable.py

    r2290 r2315  
    22
    33import os
     4import tempfile
    45import numpy
    56try:
     
    181182    #def __init__(self, filename, average=None, unit=None, getpt=None,
    182183    #             antenna=None, parallactify=None):
    183     def __init__(self, filename, average=None, unit=None, parallactify=None, **args):
     184    def __init__(self, filename, average=None, unit=None, parallactify=None,
     185                 **args):
    184186        """\
    185187        Create a scantable from a saved one or make a reference
     
    302304                            * 'ASCII' (saves as ascii text file)
    303305                            * 'MS2' (saves as an casacore MeasurementSet V2)
    304                             * 'FITS' (save as image FITS - not readable by class)
     306                            * 'FITS' (save as image FITS - not readable by
     307                                      class)
    305308                            * 'CLASS' (save as FITS readable by CLASS)
    306309
     
    370373        from asap import unique
    371374        if not _is_valid(scanid):
    372             raise RuntimeError( 'Please specify a scanno to drop from the scantable' )
     375            raise RuntimeError( 'Please specify a scanno to drop from the'
     376                                ' scantable' )
    373377        scanid = _to_list(scanid)
    374378        allscans = unique([ self.getscan(i) for i in range(self.nrow())])
     
    433437
    434438    def __str__(self):
    435         return Scantable._summary(self)
    436 
     439        tempFile = tempfile.NamedTemporaryFile()
     440        Scantable._summary(self, tempFile.name)
     441        tempFile.seek(0)
     442        asaplog.clear()
     443        return tempFile.file.read()
     444
     445    @asaplog_post_dec
    437446    def summary(self, filename=None):
    438447        """\
Note: See TracChangeset for help on using the changeset viewer.