예제 #1
0
    def _init_logging(self):
        """Initialize the logging instance."""
        if self.options.debug:
            loglevel = "DEBUG"
        elif self.options.verbose:
            loglevel = "INFO"
        else:
            loglevel = "WARNING"

        self.loglevel = loglevel

        getAppLogger(__name__, loglevel)
        self.logger = getLogger(fullname(self))
        self.logger.debug("Hi my name is " + __name__)
예제 #2
0
    def _init_logger(self):
        self.loglevel = "WARNING"
        if self.options.debug:
            self.loglevel = "DEBUG"
        elif self.options.verbose:
            self.loglevel = "INFO"

        # Need new object for logging work.
        self.logger = getAppLogger(fullname(self), self.loglevel)

        return True
예제 #3
0
    def _set_logging(self, options):
        """Set log level."""

        loglevel = "WARNING"
        if options.verbose:
            loglevel = "INFO"
        if options.debug:
            loglevel = "DEBUG"

        # New logger object and set loglevel
        self.logger = getAppLogger(__name__, level=loglevel)
        self.logger.info("loglevel=%s" % loglevel)
예제 #4
0
파일: main.py 프로젝트: geoffdavis/anfsrc
def main(argv=None):
    """Run the program."""

    logger = getAppLogger(argv=argv)
    app = Poc2MongoApp(argv)
    logger.setLevel(app.options.loglevel)

    logger = getLogger(basename(argv[0]))
    logger.notify("Loglevel set to %s", app.options.loglevel)
    try:
        app.run()
    except Poc2MongoError as e:
        logger.error(str(e))
        return -1
    except Exception:
        logger.exception("failed with an unknown exception.")
        return -1

    logger.debug("Exiting normally.")
    return 0
예제 #5
0
def main(argv=None):
    """Run the rotation_comparison command."""
    # Configure parameters from command-line.

    usage = "%prog [options] database time/orid"

    parser = OptionParser(usage=usage)

    # Verbose output
    parser.add_option(
        "-v", action="store_true", dest="verbose", default=False, help="verbose output"
    )

    # Parameter file
    parser.add_option(
        "-p",
        action="store",
        dest="pf",
        type="string",
        default="rotation_comparison.pf",
        help="parameter file",
    )

    # Filter
    parser.add_option(
        "-f", action="store", dest="filter", type="string", default=None, help="filter"
    )

    # Time window
    parser.add_option(
        "-t", action="store", dest="tw", type="float", default=None, help="time window"
    )

    # Mode
    parser.add_option(
        "-o", action="store_true", dest="origin", default=False, help="arg2 is orid"
    )

    # Mode
    parser.add_option(
        "-r",
        action="store",
        dest="reference",
        type="string",
        default=None,
        help="reference regex",
    )

    # Stations
    parser.add_option(
        "-c",
        action="store",
        dest="compare",
        type="string",
        default=False,
        help="comparison regex",
    )

    # Plot each data group for a site and wait.
    parser.add_option(
        "-x",
        action="store_true",
        dest="debug_plot",
        default=False,
        help="debug output each station plot",
    )

    # Plot results
    parser.add_option(
        "--noplot",
        action="store_true",
        dest="noplot",
        default=False,
        help="plot azimuth rotation results",
    )

    parser.add_option(
        "--nosave",
        action="store_true",
        dest="nosave",
        default=False,
        help="save results to csv file",
    )

    (options, args) = parser.parse_args(argv[1:])

    # If we don't have 2 arguments then exit.
    if len(args) != 2:
        parser.error("Incorrect number of arguments.")

    # If we don't have station list or reference station than exit

    # Set log level
    loglevel = "WARNING"
    if options.verbose:
        loglevel = "INFO"

    # New logger object and set loglevel
    logger = getAppLogger(__name__, loglevel)
    logger.info("loglevel=%s" % loglevel)

    # parse arguments from command-line
    databasename = args[0]
    logger.info("Database [%s]" % databasename)

    # read parameters from parameter file
    logger.info("Parameter file to use [%s]" % options.pf)

    stock.pfread(options.pf)

    rot_compare = Comparison(options, databasename)
    rot_compare.comp(args[1])
    return 0