def parseArgs(self, argv):
        import getopt
        short_options = 'vx:'
        long_options = ['xunit=', 'log-level=', 'log-config=', 'verbose']

        xunit = False
        xmlout = None
        log_level = None
        log_config = None
        options, args = getopt.getopt(argv, short_options, long_options)
        for opt, value in options:
            if opt in ('-v', '--verbose'):
                self.verbosity = 2
            elif opt in ('-x', '--xunit'):
                xunit = True
                xmlout = value
            elif opt == '--log-level':
                # Map from string names to Python levels (this does not appear to
                # be built into Python's logging module)
                log_level = ossie.utils.log4py.config._LEVEL_TRANS.get(
                    value.upper(), None)
            elif opt == '--log-config':
                log_config = value

        # If requested, use XML output (but the module is non-standard, so it
        # may not be available).
        if xunit:
            try:
                import xmlrunner
                if xmlout:
                    self.testRunner = xmlrunner.XMLTestRunner(
                        output=xmlout, verbosity=self.verbosity)
                else:
                    self.testRunner = xmlrunner.XMLTestRunner(
                        verbosity=self.verbosity)
            except ImportError:
                print >> sys.stderr, 'WARNING: XML test runner module is not installed'
            except TypeError:
                # Maybe it didn't like the verbosity argument
                self.testRunner = xmlrunner.XMLTestRunner()

        # If a log4j configuration file was given, read it.
        if log_config:
            ossie.utils.log4py.config.fileConfig(log_config)
        else:
            # Set up a simple configuration that logs on the console.
            logging.basicConfig()

        # Apply the log level (can override config file).
        if log_level:
            logging.getLogger().setLevel(log_level)

        # Any additional arguments are test names
        self.testNames = args
Exemple #2
0
import numpy
from new import classobj

from ossie.cf import CF, CF__POA
import ossie.properties
from ossie.utils.bulkio import bulkio_helpers
from ossie.utils.log4py import logging

import bluefile
try:
    import bulkio
    from bulkio.bulkioInterfaces import BULKIO, BULKIO__POA
except:
    pass

logging.basicConfig()
log = logging.getLogger(__name__)

# BLUE files use an epoch of Jan 1, 1950, while REDHAWK uses the Unix epoch
# (Jan 1, 1970); REDHAWK_EPOCH_J1950 is the Unix epoch as a J1950 time
REDHAWK_EPOCH_J1950 = 631152000.0


def unix_to_j1950(ts):
    """
    Converts seconds since the Unix epoch (Jan 1, 1970) to a J1950 time.
    """
    return ts + REDHAWK_EPOCH_J1950


def j1950_to_unix(ts):