Esempio n. 1
0
 def main(self, argv=None):
     # TODO: setup sane logging system that works just as well for Joe user
     # that runs checkbox from the CD as well as for checkbox developers and
     # custom debugging needs.  It would be perfect^Hdesirable not to create
     # another broken, never-rotated, uncapped logging crap that kills my
     # SSD by writing junk to ~/.cache/
     basicConfig(level="WARNING")
     config = PlainBoxConfig.get()
     parser = self._construct_parser(config)
     ns = parser.parse_args(argv)
     # Set the desired log level
     getLogger("").setLevel(ns.log_level)
     # Argh the horrror!
     #
     # Since CPython revision cab204a79e09 (landed for python3.3)
     # http://hg.python.org/cpython/diff/cab204a79e09/Lib/argparse.py
     # the argparse module behaves differently than it did in python3.2
     #
     # In practical terms subparsers are now optional in 3.3 so all of the
     # commands are no longer required parameters.
     #
     # To compensate, on python3.3 and beyond, when the user just runs
     # plainbox without specifying the command, we manually, explicitly do
     # what python3.2 did: call parser.error(_('too few arguments'))
     if (sys.version_info[:2] >= (3, 3)
             and getattr(ns, "command", None) is None):
         parser.error(argparse_gettext("too few arguments"))
     else:
         return ns.command.invoked(ns)