Esempio n. 1
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, 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)
Esempio n. 2
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)
Esempio n. 3
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)
Esempio n. 4
0
 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)
Esempio n. 5
0
 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)
Esempio n. 6
0
 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)
Esempio n. 7
0
 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)
Esempio n. 8
0
 def test_logging_default_info(self):
     config = mock.MagicMock(logconfig=None)
     logging.init_logging(config)
     self.assertEqual(stdlib_logging.getLogger().level,
                      stdlib_logging.INFO)
Esempio n. 9
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)
Esempio n. 10
0
 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)
Esempio n. 11
0
 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)
Esempio n. 12
0
 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)
Esempio n. 13
0
 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)
Esempio n. 14
0
 def test_logging_default_info(self):
     config = mock.MagicMock(logconfig=None)
     logging.init_logging(config)
     self.assertEqual(stdlib_logging.getLogger().level, stdlib_logging.INFO)