Example #1
0
def main(args):
    """
    Run dbrecsec from the command line
    (params same as dbrecsec function)
    """
    args = args[1:]
    LOG = logging.customLogger(__name__, ["stderr"])
    try:
        fn = dbrecsec(*args)
    except Exception as e:
        LOG.exception(e)
        return 1
    LOG.info("Wrote {0}".format(fn))
    return 0
Example #2
0
 def main(cls):
     """
     Main function to run as a script
     """
     # Change logger to class name, logging to stderr
     cls.logger = logging.customLogger(cls.__name__, ['stderr'])
     # Prefer command line orb, else see if you have one in a pf
     if len(sys.argv) > 1:
         ORB = sys.argv[1]
     else:
         pf = get_pf(cls._pffilename)
         ORB = pf.get('ORB')
     # Instantiate and run forever
     rtapp = cls(orbname=ORB)
     try:
         rtapp.start()
     except Exception as e:
         rtapp.logger.exception(e)
         rtapp.logger.critical("Uncaught exception, exiting...")
         sys.exit(1)
Example #3
0
This is a simple class for writing RTapps in python.

"""
import sys
import time

from antelope.orb import orbopen

import nsl.common.logging as logging
from nsl import __version__ as nsl_version
from nsl.antelope.pf import get_pf
from nsl.antelope.packets import Pkt

# Default null logger for module
LOG = logging.customLogger(__name__)


def _rt_print(packet_tuple):
    """
    Default example of an rt_app function

    Inputs: packet tuple from orbreap
    ** Prints tuple contents **
    Returns: success code
    """
    print(packet_tuple)
    return 0


class Rtapp(object):