예제 #1
0
 def test_logger_init(self):
     assert isinstance(initialize_logger('console', 0),
                       logging.Logger)
     assert isinstance(initialize_logger('syslog', 0),
                       logging.Logger)
     self.assertRaises(ConfigurationException, 
                       initialize_logger, *('foo', 0))
예제 #2
0
        '--debug',
        '--verbose',
        dest='verbosity',
        action='count',
        default=defaults.VERBOSITY,
        help='Increase verbosity level for debugging (multiple allowed)')
    options, args = parser.parse_args()
    return options, args


parser = OptionParser()
options, args = parse_args(parser)

ch = ConfigHolder(config_file_name=options.config_file,
                  verbosity=options.verbosity)
initialize_logger(ch.get(defaults.CONFIG_MAIN_SECTION, 'log_direction'),
                  ch.verbosity)

if options.action in VALID_ACTIONS:
    if len(args) < VALID_ACTIONS[options.action]:
        print_detail("Insufficient argument provided (%d required)" %
                     VALID_ACTIONS[options.action])
        parser.print_help()
        abort("")
else:
    if options.action:
        print_detail("Invalid action requested (%s)\n" % options.action)
    else:
        print_detail("No action specified\n")
    parser.print_help()
    abort("")
예제 #3
0
                      help='Name of the configuration file to use (D: %s)' %\
                                                        defaults.CONFIG_FILE_NAME)
    parser.add_option('--action', dest='action', action='store', default='', 
                      help='Action to execute. Valid actions: %s' % VALID_ACTIONS_STR)
    parser.add_option('-v', '--debug', '--verbose', dest='verbosity',
                      action='count', default=defaults.VERBOSITY, 
                      help='Increase verbosity level for debugging (multiple allowed)')
    options, args = parser.parse_args()
    return options, args

parser = OptionParser()
options, args = parse_args(parser)

ch = ConfigHolder(config_file_name=options.config_file, 
                  verbosity=options.verbosity)
initialize_logger(ch.get(defaults.CONFIG_MAIN_SECTION, 'log_direction'),
                  ch.verbosity)
            
if options.action in VALID_ACTIONS:
    if len(args) < VALID_ACTIONS[options.action]:
        print_detail("Insufficient argument provided (%d required)" % VALID_ACTIONS[options.action])  
        parser.print_help()
        abort("")
else:
    if options.action:
        print_detail("Invalid action requested (%s)\n" % options.action)
    else:
        print_detail("No action specified\n")
    parser.print_help()
    abort("")

backend_proxy = PdiskBackendProxyFactory.createBackendProxy(ch)