Пример #1
0
 def test_say_hello_ok(self):
     self.assertEqual("Hello World", misc.say_hello_world())
Пример #2
0
def main():
    """ Main """

    # set up command line argument parsing
    parser = argparse.ArgumentParser(description="Something")
    parser.add_argument("-V", "--version",
                        help="print version", action="version",
                        version=__version__)
    parser.add_argument("-v", "--verbose",
                        help="console output high verbosity",
                        action="store_true")
    parser.add_argument("-q", "--quiet",
                        help="console output errors only",
                        action="store_true")
    parser.add_argument("--nolog",
                        help="no log file (overrides --logdir and --loglevel)",
                        action="store_true")
    parser.add_argument("--logdir", type=str, default="log",
                        help="log dir (default: log)")
    parser.add_argument("--loglevel", type=str, default="DEBUG",
                        help="logfile verbosity (default: DEBUG)",
                        choices=['TRACE', 'DEBUG',
                                 'INFO', 'WARNING', 'ERROR', 'CRITICAL'])
    # parse args
    args = parser.parse_args()

    # -q (quiet) has precedence over -v (verbose)
    if args.quiet:
        args_verbosity = "ERROR"
    else:
        # if -q is not set check for -v (verbose). If not set default to "INFO"
        if args.verbose:
            args_verbosity = "DEBUG"
        else:
            args_verbosity = "INFO"

    if args.nolog:
        logger = misc.set_up_logger(logger_name=LOGGER_NAME,
                                    console_log=True,
                                    console_log_level=args_verbosity,
                                    file_log=False)
    else:
        logger = misc.set_up_logger(logger_name=LOGGER_NAME,
                                    console_log=True,
                                    console_log_level=args_verbosity,
                                    file_log=True,
                                    file_log_level=args.loglevel,
                                    file_log_dir=args.logdir)

    print "loglevel: " + args.loglevel
    logger.trace("trace message")
    logger.debug("debug message")
    logger.info("info message")
    logger.warning("warn message")
    logger.error("error message")
    logger.critical("critical message")

    logger.info(__name__)

    """
    print config.PASSWORD
    print misc.say_hello_world()
    """
    # Start Coding Here!

    misc.say_hello_world()