Esempio n. 1
0
    def main(self):
        """
        The method that does a basic check for command
        validity and set's the process in motion.
        """

        (self.options, self.args) = self.parser.parse_args()

        # we dont need argv[0] in this list...

        self.args = self.args[1:]

        # Verbosity propagates in two ways to the individual commands:
        # first, as self.verbosity, and second, through the log level
        # for the 'rho' logger.
        self.verbosity = self.options.verbosity

        ensure_config_dir_exists()
        ensure_data_dir_exists()

        setup_logging(self.verbosity)

        self._validate_options()

        if len(sys.argv) < 2:

            print(self.parser.error(_("Please enter at least 2 args")))

        # do the work, catch most common errors here:

        self._do_command()
Esempio n. 2
0
 def test_verbose_level(self):
     utilities.setup_logging(2)
     self.assertEqual(utilities.log.getEffectiveLevel(), logging.DEBUG)
     self.assertEqual(logging.getLogger().getEffectiveLevel(),
                      logging.WARNING)
Esempio n. 3
0
 def test_default_level(self):
     utilities.setup_logging(None)
     self.assertEqual(utilities.log.getEffectiveLevel(), logging.WARNING)
     self.assertEqual(logging.getLogger().getEffectiveLevel(),
                      logging.WARNING)