Exemplo n.º 1
0
def main():
    """Main entry point of the program"""

    parser = argparse.ArgumentParser(
        description=_(
            "Deploy and setup developers environment easily on ubuntu"),
        epilog=_(
            "Note that you can also configure different debug logs behaviors using "
            "LOG_CFG pointing to a log yaml profile."),
        add_help=False)
    parser.add_argument('--help', action=_HelpAction,
                        help=_('Show this help'))  # add custom help
    parser.add_argument("-v",
                        "--verbose",
                        action="count",
                        default=0,
                        help=_("Increase output verbosity (2 levels)"))

    parser.add_argument('-r',
                        '--remove',
                        action="store_true",
                        help=_("Remove specified framework if installed"))

    # set logging ignoring unknown options
    set_logging_from_args(sys.argv, parser)

    mainloop = MainLoop()

    # load frameworks and initialize parser
    load_frameworks()
    cli.main(parser)

    mainloop.run()
Exemplo n.º 2
0
 def _display(self, contentType):
     # print depending on the content type
     while True:
         try:
             if isinstance(contentType, InputText):
                 contentType.run_callback(result=rlinput(
                     contentType.content, contentType.default_input))
             elif isinstance(contentType, LicenseAgreement):
                 print(contentType.content)
                 contentType.choose(answer=input(contentType.input))
             elif isinstance(contentType, TextWithChoices):
                 contentType.choose(answer=input(contentType.prompt))
             elif isinstance(contentType, DisplayMessage):
                 print(contentType.text)
             elif isinstance(contentType, UnknownProgress):
                 if not contentType.bar:
                     contentType.bar = ProgressBar(widgets=[BouncingBar()])
                 with suppress(StopIteration, AttributeError):
                     # pulse and add a timeout callback
                     contentType.bar(contentType._iterator()).next()
                     UI.delayed_display(contentType)
                 # don't recall the callback
                 return False
             else:
                 logger.error(
                     "Unexcepted content type to display to CLI UI: {}".
                     format(contentType))
                 MainLoop().quit(status_code=1)
             break
         except InputError as e:
             logger.error(str(e))
             continue
Exemplo n.º 3
0
def main():
    """Main entry point of the program"""

    if "udtc" in sys.argv[0]:
        print(
            _("WARNING: 'udtc' command is the previous name of Ubuntu Make. Please use the 'umake' command from now "
              "on providing the exact same features. The 'udtc' command will be removed soon."
              ))

    parser = argparse.ArgumentParser(
        description=_(
            "Deploy and setup developers environment easily on ubuntu"),
        epilog=_(
            "Note that you can also configure different debug logging behavior using "
            "LOG_CFG that points to a log yaml profile."),
        add_help=False)
    parser.add_argument('--help', action=_HelpAction,
                        help=_('Show this help'))  # add custom help
    parser.add_argument("-v",
                        "--verbose",
                        action="count",
                        default=0,
                        help=_("Increase output verbosity (2 levels)"))

    parser.add_argument('-r',
                        '--remove',
                        action="store_true",
                        help=_("Remove specified framework if installed"))

    list_group = parser.add_argument_group(
        "List frameworks").add_mutually_exclusive_group()
    list_group.add_argument('-l',
                            '--list',
                            action="store_true",
                            help=_("List all frameworks"))
    list_group.add_argument('--list-installed',
                            action="store_true",
                            help=_("List installed frameworks"))
    list_group.add_argument('--list-available',
                            action="store_true",
                            help=_("List installable frameworks"))

    parser.add_argument('--version',
                        action="store_true",
                        help=_("Print version and exit"))

    # set logging ignoring unknown options
    set_logging_from_args(sys.argv, parser)

    mainloop = MainLoop()

    # load frameworks
    load_frameworks(force_loading=should_load_all_frameworks(sys.argv))

    # initialize parser
    cli.main(parser)

    mainloop.run()
Exemplo n.º 4
0
 def setUp(self):
     super().setUp()
     self.mockUIPlug = Mock()
     self.mockUIPlug._display.side_effect = self.display_UIPlug
     self.contentType = Mock()
     self.ui = UI(self.mockUIPlug)
     self.mainloop_object = MainLoop()
     self.mainloop_thread = None
     self.function_thread = None
     self.display_thread = None
     self.time_display_call = 0
Exemplo n.º 5
0
    def setup(self):
        """Method call to setup the Framework"""
        if not self.is_installable:
            logger.error(_("You can't install that framework on this machine"))
            UI.return_main_screen(status_code=1)

        if self.need_root_access and os.geteuid() != 0:
            logger.debug("Requesting root access")
            cmd = ["sudo", "-E", "env", "PATH={}".format(os.getenv("PATH"))]
            cmd.extend(sys.argv)
            MainLoop().quit(subprocess.call(cmd))

        # be a normal, kind user as we don't want normal files to be written as root
        switch_to_current_user()
Exemplo n.º 6
0
    def setup(self):
        """Method call to setup the Framework"""
        if not self.is_installable:
            logger.error(_("You can't install that framework on this machine"))
            UI.return_main_screen(status_code=2)

        if self.need_root_access and os.geteuid() != 0:
            logger.debug("Requesting root access")
            cmd = ["sudo", "-E", "env"]
            for var in ["PATH", "LD_LIBRARY_PATH", "PYTHONUSERBASE", "PYTHONHOME"]:
                if os.getenv(var):
                    cmd.append("{}={}".format(var, os.getenv(var)))
            if os.getenv("SNAP"):
                logger.debug("Found snap environment. Running correct python version")
                cmd.extend(["{}/usr/bin/python3".format(os.getenv("SNAP"))])
            cmd.extend(sys.argv)
            MainLoop().quit(subprocess.call(cmd))

        # be a normal, kind user as we don't want normal files to be written as root
        switch_to_current_user()
Exemplo n.º 7
0
 def _return_main_screen(self, status_code=0):
     # quit the shell
     MainLoop().quit(status_code=status_code)