def main(argv=None): """Discover an existing configuration for a network location.""" config = parse_args(argv) common_logging.init_logging(config) if not (config['format'] == 'json' or check_format(config['format'] or "text")): sys.exit("Output format file (%s) not found or accessible. Try " "specifying raw JSON format using `--format json`" % get_template_path(config['format'])) try: results, errors = discovery.run(config['netloc'], config, interactive=True) print( format_output(config['netloc'], results, template_name=config['format'])) if errors: sys.stderr.write(format_errors(errors, config)) except Exception as exc: # pylint: disable=W0703 if config['debug']: LOG.exception(exc) return str(exc) sys.exit(0)
def main(argv=None): """Discover an existing configuration for a network location.""" config = parse_args(argv) common_logging.init_logging(config) if not (config.format == 'json' or check_format(config.format or "text")): sys.exit("Output format file (%s) not found or accessible. Try " "specifying raw JSON format using `--format json`" % get_template_path(config.format)) try: results = discovery.run(config.netloc, config, interactive=True) print(format_output(config.netloc, results, template_name=config.format)) except Exception as exc: # pylint: disable=W0703 if config.debug: LOG.exception(exc) return str(exc) sys.exit(0)
def test_logging_quiet_flag(self): config = {} with mock.patch.dict(config, {'logconfig': None, 'quiet': True}): logging.init_logging(config) self.assertEqual(stdlib_logging.getLogger().level, stdlib_logging.WARN)
def test_logging_verbose_flag(self): config = {} with mock.patch.dict(config, {'logconfig': None, 'verbose': True}): logging.init_logging(config) self.assertEqual(stdlib_logging.getLogger().level, stdlib_logging.DEBUG)
def test_logging_default_info(self): config = {} with mock.patch.dict(config, {'logconfig': None}): logging.init_logging(config) self.assertEqual(stdlib_logging.getLogger().level, stdlib_logging.INFO)
def test_logging_quiet_flag(self): config = mock.MagicMock(logconfig=None, quiet=True) logging.init_logging(config) self.assertEqual(stdlib_logging.getLogger().level, stdlib_logging.WARN)
def test_logging_verbose_flag(self): config = mock.MagicMock(logconfig=None, verbose=True) logging.init_logging(config) self.assertEqual(stdlib_logging.getLogger().level, stdlib_logging.DEBUG)
def test_logging_default_info(self): config = mock.MagicMock(logconfig=None) logging.init_logging(config) self.assertEqual(stdlib_logging.getLogger().level, stdlib_logging.INFO)