Esempio n. 1
0
def main():
    logging.init_logging(sys.argv)
    logger = logging.getLogger(__file__)
    communicator = Ice.initialize(sys.argv)

    try:
        ingest_manager = IngestManager(communicator)
        ingest_manager.run()
    except Exception as ex:
        logger.error(str(ex))
        print >> sys.stderr, ex
        sys.exit(1)
    finally:
        communicator.destroy()
Esempio n. 2
0
def main():
    communicator = Ice.initialize(sys.argv)
    logging.init_logging(sys.argv)
    logger = logging.getLogger(__file__)
    pub1 = Publisher('a', 0.1)
    pub2 = Publisher('b', 0.11)
    pub3 = Publisher('foo', 0.12, 'MHz')
    try:
        fcm = MonProvider(communicator)
        pub1.start()
        pub2.start()
        pub3.start()
        fcm.run()
    except Exception as ex:
        logger.error(str(ex))
        raise
    finally:
        pub1.stop.set()
        pub2.stop.set()
        communicator.destroy()
Esempio n. 3
0

ParameterSet values are always strings as they are mainly stored in files.
This modules offers the :func:`decode` function to help parsing these into python
types and the :func:`extract` to extract a key/value pair form a string.

:class:`ParameterSet` is a little bit more restrictive compared to the
original ParameterSet class:

    * only leaf nodes can have values
    * nested list vectors (lists) can only contain numerical values
    * lists can't contain expressions
    * keys should be valid as variable names, e.g. the following wouldn't work
      '10uJy' or 'abc-xyz'

This module provides logging through :attr:`askap.parset.logger`.

"""
# if used outside askapsoft
try:
    from askap import logging
except ImportError:
    import logging

# module attributes
logger = logging.getLogger(__name__)

from askap.parset.parset import (ParameterSet, decode, encode, extract,
                                 to_dict, merge, parset_to_dict,
                                 dict_to_parset, slice_parset, sub_parset)
Esempio n. 4
0
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA.
#
__all__ = ["get_monitor", "MonitorData"]

import sys
import os
from threading import Lock, Event, Thread
import Ice

from askap import logging
from askap.time import bat_now

from .typedvaluepublisher import TimeTaggedTypedValuePublisher

logger = logging.getLogger(__name__)

_MONITOR_SINGLETON = None


def get_monitor(topic=None, icecomm=None):
    global _MONITOR_SINGLETON
    if topic is None:
        if _MONITOR_SINGLETON is None:
            raise RuntimeError("Monitor not yet configured")
        return _MONITOR_SINGLETON
    if _MONITOR_SINGLETON is not None:
        if _MONITOR_SINGLETON.topic != topic:
            raise KeyError("Monitoring already set up under topic '{}'"
                           .format(_MONITOR_SINGLETON.topic))
        return _MONITOR_SINGLETON
Esempio n. 5
0
from askap.logging import Handler, log_debug, getLogger, DEBUG


class ListHandler(Handler):
    def __init__(self):
        Handler.__init__(self)
        self.event = None

    def emit(self, record):
        self.event = [record.name, record.getMessage()]

# This passes in as reference as it is a list. Use this to access it 
# globally
#event = None
hand = ListHandler()
logger = getLogger(__name__)
logger.setLevel(DEBUG)
logger.addHandler(hand)

# pylint: disable-msg=W0613
@log_debug
def debug_me(arg, kwarg=2):
    pass
    
def test_log_debug():
    debugmestr = 'debug_me:  (1, 2) '
    debugmename = "test_logging"
    # call function to generate log message
    debug_me(1, 2)
    # check the last generated log event
    assert_equals(debugmename, hand.event[0])
Esempio n. 6
0
# or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA.
#
__all__ = ["logger"]

from askap.logging import getLogger

logger = getLogger(__name__)


class ServiceError(Exception):
    def __init__(self, value):
        self.value = value

    def __str__(self):
        return repr(self.value)


def get_service(name, proxy, communicator):
    servicebase = communicator.stringToProxy(name)
    if not servicebase:
        raise ServiceError("%s proxy not found" % name)
    return proxy.checkedCast(servicebase)