def run(self):
        """
        Process entry point. Construct driver and start messaging loops.
        Periodically check messaging is going and parent exists if
        specified.
        """

        from mi.core.log import LoggerManager
        LoggerManager()

        log.info('Driver process started.')

        def shand(signum, frame):
            log.info(
                'mi/core/instrument/driver_process.py DRIVER GOT SIGINT and is ignoring it...'
            )

        signal.signal(signal.SIGINT, shand)

        if self.construct_driver():
            self.start_messaging()
            while self.messaging_started:
                if self.check_parent():
                    time.sleep(2)
                else:
                    self.stop_messaging()
                    break

        self.shutdown()
        time.sleep(1)
        os._exit(0)
 def __init__(self, event_callback):
     """
     Constructor.
     @param event_callback The driver process callback used to send
     asynchrous driver events to the agent.
     """
     LoggerManager()
     self._send_event = event_callback
     self._test_mode = False
Example #3
0
    def run(self):
        """
        Process entry point. Construct driver and start messaging loops.
        Periodically check messaging is going and parent exists if
        specified.
        """

        from mi.core.log import LoggerManager

        LoggerManager()

        log.info('Driver process started.')

        # noinspection PyUnusedLocal
        def shand(signum, frame):
            now = time.time()
            if now - self.int_time < INTERRUPT_REPEAT_INTERVAL:
                self.stop_messaging()
            else:
                self.int_time = now
                log.info(
                    'mi/core/instrument/driver_process.py DRIVER GOT SIGINT and is ignoring it...'
                )

        signal.signal(signal.SIGINT, shand)

        if self.driver is not None or self.construct_driver():
            self.start_messaging()
            while self.messaging_started:
                if self.check_parent():
                    time.sleep(2)
                else:
                    self.stop_messaging()
                    break

        self.shutdown()
        time.sleep(1)
        os._exit(0)
Example #4
0
import httplib
import xmlrpclib

import re
import yaml
from docopt import docopt
from flask import Flask, request
from mi.core.instrument.publisher import Publisher
from mi.core.log import LoggerManager
from mi.logging import log

app = Flask(__name__)
aa_publisher = None

LoggerManager()
log.setLevel('INFO')


@app.route('/', methods=['POST'])
def process_oms_request():
    """
    This is the method that is called when the OMS POSTs OMS Events to
    this registered listener at the "/" path.
    :return:
    """

    if isinstance(request.json, list):
        # Log the list of Alert & Alarm messages from the OMS Event
        for alert_alarm_dict in request.json:
            aa_publisher.enqueue(alert_alarm_dict)