Esempio n. 1
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
Esempio n. 2
0
 def post_install(self):
     """Add go necessary env variables"""
     add_env_to_user(
         self.name,
         {"PATH": {"value": os.path.join(self.install_path, "bin")}, "GOROOT": {"value": self.install_path}},
     )
     UI.delayed_display(DisplayMessage(_("You need to restart a shell session for your installation to work")))
Esempio n. 3
0
    def remove(self):
        """Remove current framework if installed

        Not that we only remove desktop file, launcher icon and dir content, we do not remove
        packages as they might be in used for other framework"""
        # check if it's installed and so on.
        super().remove()

        UI.display(DisplayMessage("Removing {}".format(self.name)))
        if self.desktop_filename:
            with suppress(FileNotFoundError):
                os.remove(get_launcher_path(self.desktop_filename))
                os.remove(
                    os.path.join(self.default_binary_link_path,
                                 self.exec_link_name))
        if self.icon_filename:
            with suppress(FileNotFoundError):
                os.remove(get_icon_path(self.icon_filename))
        with suppress(FileNotFoundError):
            shutil.rmtree(self.install_path)
            path = os.path.dirname(self.install_path)
            while path is not DEFAULT_INSTALL_TOOLS_PATH:
                if os.listdir(path) == []:
                    logger.debug(
                        "Empty folder, cleaning recursively: {}".format(path))
                    os.rmdir(path)
                    path = os.path.dirname(path)
                else:
                    break
        remove_framework_envs_from_user(self.name)
        self.remove_from_config()

        UI.delayed_display(DisplayMessage("Suppression done"))
        UI.return_main_screen()
Esempio n. 4
0
 def post_install(self):
     """Add rust necessary env variables"""
     add_env_to_user(self.name, {"PATH": {"value": "{}:{}".format(os.path.join(self.install_path, "rustc", "bin"),
                                                                  os.path.join(self.install_path, "cargo", "bin"))},
                                 "LD_LIBRARY_PATH": {"value": os.path.join(self.install_path, "rustc", "lib")}})
     UI.delayed_display(DisplayMessage(_("You need to restart your current shell session for your {} installation "
                                         "to work properly").format(self.name)))
Esempio n. 5
0
    def post_install(self):
        """Add rust necessary env variables"""
        add_env_to_user(
            self.name, {
                "PATH": {
                    "value":
                    "{}:{}:{}".format(
                        os.path.join(self.install_path, "rustc", "bin"),
                        os.path.join(self.install_path, "cargo", "bin"),
                        "$HOME/.cargo/bin")
                }
            })

        # adjust for rust: some symlinks magic to have stdlib craft available
        arch_lib_folder = '{}-unknown-linux-gnu'.format(
            self.arch_trans[get_current_arch()])
        lib_folder = os.path.join(self.install_path,
                                  'rust-std-{}'.format(arch_lib_folder), 'lib',
                                  'rustlib', arch_lib_folder, 'lib')
        arch_dest_lib_folder = os.path.join(self.install_path, 'rustc', 'lib',
                                            'rustlib', arch_lib_folder, 'lib')
        os.mkdir(arch_dest_lib_folder)
        for f in os.listdir(lib_folder):
            os.symlink(os.path.join(lib_folder, f),
                       os.path.join(arch_dest_lib_folder, f))

        UI.delayed_display(
            DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Esempio n. 6
0
    def remove(self):
        """Remove current framework if installed

        Not that we only remove desktop file, launcher icon and dir content, we do not remove
        packages as they might be in used for other framework"""
        # check if it's installed and so on.
        super().remove()

        UI.display(DisplayMessage("Removing {}".format(self.name)))
        if self.desktop_filename:
            with suppress(FileNotFoundError):
                os.remove(get_launcher_path(self.desktop_filename))
                os.remove(
                    os.path.join(self.default_binary_link_path,
                                 self.exec_link_name))
        if self.icon_filename:
            with suppress(FileNotFoundError):
                os.remove(get_icon_path(self.icon_filename))
        with suppress(FileNotFoundError):
            shutil.rmtree(self.install_path)
        remove_framework_envs_from_user(self.name)
        self.remove_from_config()

        UI.delayed_display(DisplayMessage("Suppression done"))
        UI.return_main_screen()
Esempio n. 7
0
    def post_install(self):
        """Add necessary environment variables"""
        add_env_to_user(self.name, {"ANDROID_HOME": {"value": self.install_path, "keep": False}})
        # add "platform-tools" to PATH to ensure "adb" can be run once the platform tools are installed via
        # the SDK manager
        add_env_to_user(
            self.name,
            {
                "PATH": {
                    "value": [os.path.join("$ANDROID_HOME", "tools"), os.path.join("$ANDROID_HOME", "platform-tools")]
                }
            },
        )
        UI.delayed_display(
            DisplayMessage(
                _("You need to restart your current shell session for your {} installation " "to work properly").format(
                    self.name
                )
            )
        )

        # print wiki page message
        UI.delayed_display(
            DisplayMessage(
                "SDK installed in {}. More information on how to use it on {}".format(
                    self.install_path, "https://developer.android.com/sdk/installing/adding-packages.html"
                )
            )
        )
Esempio n. 8
0
    def post_install(self):
        """Add rust necessary env variables"""
        add_env_to_user(
            self.name, {
                "PATH": {
                    "value":
                    "{}:{}".format(
                        os.path.join(self.install_path, "rustc", "bin"),
                        os.path.join(self.install_path, "cargo", "bin"))
                },
                "LD_LIBRARY_PATH": {
                    "value": os.path.join(self.install_path, "rustc", "lib")
                }
            })

        # adjust for rust 1.5 some symlinks magic to have stdlib craft available
        os.chdir(os.path.join(self.install_path, "rustc", "lib"))
        os.rename("rustlib", "rustlib.init")
        os.symlink(
            glob(os.path.join('..', '..', 'rust-std-*', 'lib', 'rustlib'))[0],
            'rustlib')
        os.symlink(os.path.join('..', 'rustlib.init', 'etc'),
                   os.path.join('rustlib', 'etc'))

        UI.delayed_display(
            DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Esempio n. 9
0
    def post_install(self):
        """Add necessary environment variables"""
        # add a few fall-back variables that might be used by some tools
        # do not set ANDROID_SDK_HOME here as that is the path of the preference folder expected by the Android tools
        add_env_to_user(
            self.name, {
                "ANDROID_HOME": {
                    "value": self.install_path,
                    "keep": False
                },
                "ANDROID_SDK": {
                    "value": self.install_path,
                    "keep": False
                },
                "PATH": {
                    "value": [
                        os.path.join(self.install_path, "tools"),
                        os.path.join(self.install_path, "tools", "bin")
                    ]
                }
            })
        UI.delayed_display(
            DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))

        # print wiki page message
        UI.delayed_display(
            DisplayMessage(
                "SDK installed in {}. More information on how to use it on {}".
                format(
                    self.install_path,
                    "https://developer.android.com/sdk/installing/adding-packages.html"
                )))
Esempio n. 10
0
    def get_metadata_and_check_license(self, result):
        """Diverge from the baseinstaller implementation in order to allow language selection"""

        logger.debug("Parse download metadata")
        error_msg = result[self.download_page].error
        if error_msg:
            logger.error("An error occurred while downloading {}: {}".format(
                self.download_page, error_msg))
            UI.return_main_screen(status_code=1)

        arch = platform.machine()
        arg_lang_url = None
        default_label = ''
        tag_machine = ''
        if arch == 'x86_64':
            tag_machine = '64'

        reg_expression = r'href="(\S+os=linux{}&lang=\S+)"'.format(
            tag_machine)
        languages = []
        decoded_page = result[self.download_page].buffer.getvalue().decode()
        for index, p in enumerate(re.finditer(reg_expression, decoded_page)):
            with suppress(AttributeError):
                url = p.group(1)

            m = re.search(r'lang=(.*)', url)
            with suppress(AttributeError):
                lang = m.group(1)

            if self.arg_lang and self.arg_lang.lower() == lang.lower():
                arg_lang_url = url
                break
            else:
                is_default_choice = False
                if lang == "en-US":
                    default_label = "(default: en-US)"
                    is_default_choice = True
                choice = Choice(index,
                                lang,
                                partial(self.language_select_callback, url),
                                is_default=is_default_choice)
                languages.append(choice)

        if self.arg_lang:
            logger.debug("Selecting {} lang".format(self.arg_lang))
            if not arg_lang_url:
                logger.error(
                    "Could not find a download url for language {}".format(
                        self.arg_lang))
                UI.return_main_screen(status_code=1)
            self.language_select_callback(arg_lang_url)
        else:
            if not languages:
                logger.error(
                    "Download page changed its syntax or is not parsable")
                UI.return_main_screen(status_code=1)
            logger.debug("Check list of installable languages.")
            UI.delayed_display(
                TextWithChoices(_("Choose language: {}".format(default_label)),
                                languages, True))
Esempio n. 11
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):
                     # 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
Esempio n. 12
0
    def post_install(self):
        """Add rust necessary env variables"""
        add_env_to_user(
            self.name, {
                "PATH": {
                    "value":
                    "{}:{}".format(
                        os.path.join(self.install_path, "rustc", "bin"),
                        os.path.join(self.install_path, "cargo", "bin"))
                },
                "LD_LIBRARY_PATH": {
                    "value": os.path.join(self.install_path, "rustc", "lib")
                }
            })

        # adjust for rust 1.5 some symlinks magic to have stdlib craft available
        os.chdir(os.path.join(self.install_path, "rustc", "lib"))
        os.rename("rustlib", "rustlib.init")
        os.symlink(
            glob(os.path.join('..', '..', 'rust-std-*', 'lib', 'rustlib'))[0],
            'rustlib')
        os.symlink(os.path.join('..', 'rustlib.init', 'etc'),
                   os.path.join('rustlib', 'etc'))

        UI.delayed_display(
            DisplayMessage(
                _("You need to restart your current shell session for your {} installation "
                  "to work properly").format(self.name)))
Esempio n. 13
0
    def post_install(self):
        """Add necessary environment variables"""
        add_env_to_user(
            self.name,
            {"ANDROID_HOME": {
                "value": self.install_path,
                "keep": False
            }})
        # add "platform-tools" to PATH to ensure "adb" can be run once the platform tools are installed via
        # the SDK manager
        add_env_to_user(
            self.name, {
                "PATH": {
                    "value": [
                        os.path.join("$ANDROID_HOME", "tools"),
                        os.path.join("$ANDROID_HOME", "platform-tools")
                    ]
                }
            })
        UI.delayed_display(
            DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))

        # print wiki page message
        UI.delayed_display(
            DisplayMessage(
                "SDK installed in {}. More information on how to use it on {}".
                format(
                    self.install_path,
                    "https://developer.android.com/sdk/installing/adding-packages.html"
                )))
Esempio n. 14
0
 def post_install(self):
     """Add nodejs necessary env variables and move module folder"""
     subprocess.call([os.path.join(self.install_path, "bin", "npm"), "config", "set", "prefix", "~/.node_modules"])
     add_env_to_user(self.name, {"PATH": {"value": "{}:{}".format(os.path.join(self.install_path, "bin"),
                                                                  os.path.join(os.path.expanduser('~'),
                                                                               ".node_modules", "bin"))}})
     UI.delayed_display(DisplayMessage(_("You need to restart your current shell session for your {} installation "
                                         "to work properly").format(self.name)))
Esempio n. 15
0
 def post_install(self):
     """Add Terraform necessary env variables"""
     add_env_to_user(self.name,
                     {"PATH": {
                         "value": os.path.join(self.install_path)
                     }})
     UI.delayed_display(
         DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Esempio n. 16
0
 def post_install(self):
     """Add the Geckodriver binary dir to PATH"""
     add_env_to_user(self.name,
                     {"PATH": {
                         "value": os.path.join(self.install_path)
                     }})
     UI.delayed_display(
         DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Esempio n. 17
0
 def post_install(self):
     """Add necessary environment variables"""
     add_env_to_user(self.name, {
         "PATH": {
             "value": [os.path.join(self.install_path, "platform-tools")]
         }
     })
     UI.delayed_display(
         DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Esempio n. 18
0
 def post_install(self):
     """Add the necessary Maven environment variables"""
     add_env_to_user(
         self.name,
         {"PATH": {
             "value": os.path.join(self.install_path, "bin")
         }})
     UI.delayed_display(
         DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Esempio n. 19
0
    def post_install(self):
        """Add nodejs necessary env variables and move module folder"""
        if not self.prefix_set():
            with open(os.path.join(os.environ['HOME'], '.npmrc'), 'a+') as file:
                file.write("prefix = ${HOME}/.npm_modules\n")

        add_env_to_user(self.name, {"PATH": {"value": "{}:{}".format(os.path.join(self.install_path, "bin"),
                                                                     os.path.join(os.path.expanduser('~'),
                                                                                  ".npm_modules", "bin"))}})
        UI.delayed_display(DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Esempio n. 20
0
    def post_install(self):
        """Add nodejs necessary env variables and move module folder"""
        if not self.prefix_set():
            with open(os.path.join(os.environ['HOME'], '.npmrc'), 'a+') as file:
                file.write("prefix = ${HOME}/.npm_modules\n")

        add_env_to_user(self.name, {"PATH": {"value": "{}:{}".format(os.path.join(self.install_path, "bin"),
                                                                     os.path.join(os.path.expanduser('~'),
                                                                                  ".npm_modules", "bin"))}})
        UI.delayed_display(DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Esempio n. 21
0
 def post_install(self):
     """Add the necessary OpenJFX environment variables"""
     add_env_to_user(
         self.name, {
             "PATH_TO_FX": {
                 "value": os.path.join(self.install_path, "lib"),
                 "keep": False
             }
         })
     UI.delayed_display(
         DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Esempio n. 22
0
 def post_install(self):
     """Add go necessary env variables"""
     add_env_to_user(
         self.name,
         {"PATH": {
             "value": os.path.join(self.install_path, "bin")
         }})
     UI.delayed_display(
         DisplayMessage(
             _("You need to restart a shell session for your installation to work"
               )))
Esempio n. 23
0
 def post_install(self):
     """Add go necessary env variables"""
     add_env_to_user(
         self.name,
         {"PATH": {
             "value": os.path.join(self.install_path, "bin")
         }})
     UI.delayed_display(
         DisplayMessage(
             _("You need to restart your current shell session for your {} installation "
               "to work properly").format(self.name)))
Esempio n. 24
0
    def test_call_delayed_display(self, mocksys):
        """We call the display method from the UIPlug in delayed_display with 50ms waiting"""
        UI.delayed_display(self.contentType)
        now = time()
        self.start_glib_mainloop()
        self.wait_for_mainloop_shutdown()

        self.assertTrue(self.mockUIPlug._display.called)
        self.assertIsNotNone(self.mainloop_thread)
        self.assertIsNotNone(self.display_thread)
        self.assertEqual(self.mainloop_thread, self.display_thread)
        self.assertTrue(self.time_display_call - now > 0.05)
Esempio n. 25
0
    def test_call_delayed_display(self, mocksys):
        """We call the display method from the UIPlug in delayed_display with 50ms waiting"""
        UI.delayed_display(self.contentType)
        now = time()
        self.start_glib_mainloop()
        self.wait_for_mainloop_shutdown()

        self.assertTrue(self.mockUIPlug._display.called)
        self.assertIsNotNone(self.mainloop_thread)
        self.assertIsNotNone(self.display_thread)
        self.assertEqual(self.mainloop_thread, self.display_thread)
        self.assertTrue(self.time_display_call - now > 0.05)
Esempio n. 26
0
    def decompress_and_install(self, fd):
        UI.display(DisplayMessage("Installing {}".format(self.name)))

        shutil.copyfile(fd.name, self.install_path + '/drjava.jar')

        self.post_install()

        # Mark as installation done in configuration
        self.mark_in_config()

        UI.delayed_display(DisplayMessage("Installation done"))
        UI.return_main_screen()
Esempio n. 27
0
 def post_install(self):
     """Create the Arduino launcher"""
     icon_path = join(self.install_path, 'lib', 'arduino_icon.ico')
     comment = _("The Arduino Software IDE")
     categories = "Development;IDE;"
     create_launcher(self.desktop_filename,
                     get_application_desktop_file(name=_("Arduino"),
                                                  icon_path=icon_path,
                                                  exec='"{}" %f'.format(self.exec_path),
                                                  comment=comment,
                                                  categories=categories))
     if not self.was_in_arduino_group:
         UI.delayed_display(DisplayMessage(_("You need to logout and login again for your installation to work")))
Esempio n. 28
0
    def post_install(self):
        """Add rust necessary env variables"""
        add_env_to_user(self.name, {"PATH": {"value": "{}:{}".format(os.path.join(self.install_path, "rustc", "bin"),
                                                                     os.path.join(self.install_path, "cargo", "bin"))},
                                    "LD_LIBRARY_PATH": {"value": os.path.join(self.install_path, "rustc", "lib")}})

        # adjust for rust 1.5 some symlinks magic to have stdlib craft available
        os.chdir(os.path.join(self.install_path, "rustc", "lib"))
        os.rename("rustlib", "rustlib.init")
        os.symlink(glob(os.path.join('..', '..', 'rust-std-*', 'lib', 'rustlib'))[0], 'rustlib')
        os.symlink(os.path.join('..', 'rustlib.init', 'etc'), os.path.join('rustlib', 'etc'))

        UI.delayed_display(DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Esempio n. 29
0
 def post_install(self):
     """Create the Arduino launcher"""
     icon_path = join(self.install_path, 'lib', 'arduino_icon.ico')
     comment = _("The Arduino Software IDE")
     categories = "Development;IDE;"
     create_launcher(self.desktop_filename,
                     get_application_desktop_file(name=_("Arduino"),
                                                  icon_path=icon_path,
                                                  exec='"{}" %f'.format(self.exec_path),
                                                  comment=comment,
                                                  categories=categories))
     if not self.was_in_arduino_group:
         UI.delayed_display(DisplayMessage(_("You need to logout and login again for your installation to work")))
Esempio n. 30
0
 def post_install(self):
     """Add go necessary env variables"""
     add_env_to_user(
         self.name, {
             "PATH": {
                 "value": os.path.join(self.install_path, "bin")
             },
             "GOROOT": {
                 "value": self.install_path,
                 "keep": False
             }
         })
     UI.delayed_display(
         DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Esempio n. 31
0
    def get_metadata_and_check_license(self, result):
        """Diverge from the baseinstaller implementation in order to allow language selection"""

        logger.debug("Parse download metadata")
        error_msg = result[self.download_page].error
        if error_msg:
            logger.error("An error occurred while downloading {}: {}".format(self.download_page, error_msg))
            UI.return_main_screen(status_code=1)

        arch = platform.machine()
        arg_lang_url = None
        default_label = ''
        tag_machine = ''
        if arch == 'x86_64':
            tag_machine = '64'

        reg_expression = '<td class="download linux{}"><a href="(.*)" title'.format(tag_machine)
        languages = []
        decoded_page = result[self.download_page].buffer.getvalue().decode()
        for index, p in enumerate(re.finditer(reg_expression, decoded_page)):
            with suppress(AttributeError):
                url = p.group(1)

            m = re.search(r'lang=(.*)', url)
            with suppress(AttributeError):
                lang = m.group(1)

            if self.arg_lang and self.arg_lang.lower() == lang.lower():
                arg_lang_url = url
                break
            else:
                is_default_choice = False
                if lang == "en-US":
                    default_label = "(default: en-US)"
                    is_default_choice = True
                choice = Choice(index, lang, partial(self.language_select_callback, url), is_default=is_default_choice)
                languages.append(choice)

        if self.arg_lang:
            logger.debug("Selecting {} lang".format(self.arg_lang))
            if not arg_lang_url:
                logger.error("Could not find a download url for language {}".format(self.arg_lang))
                UI.return_main_screen(status_code=1)
            self.language_select_callback(arg_lang_url)
        else:
            if not languages:
                logger.error("Download page changed its syntax or is not parsable")
                UI.return_main_screen(status_code=1)
            logger.debug("Check list of installable languages.")
            UI.delayed_display(TextWithChoices(_("Choose language: {}".format(default_label)), languages, True))
Esempio n. 32
0
    def post_install(self):
        """Add rust necessary env variables"""
        add_env_to_user(self.name, {"PATH": {"value": "{}:{}".format(os.path.join(self.install_path, "rustc", "bin"),
                                                                     os.path.join(self.install_path, "cargo", "bin"))},
                                    "LD_LIBRARY_PATH": {"value": os.path.join(self.install_path, "rustc", "lib")}})

        # adjust for rust 1.5 some symlinks magic to have stdlib craft available
        os.chdir(os.path.join(self.install_path, "rustc", "lib"))
        os.rename("rustlib", "rustlib.init")
        os.symlink(glob(os.path.join('..', '..', 'rust-std-*', 'lib', 'rustlib'))[0], 'rustlib')
        os.symlink(os.path.join('..', 'rustlib.init', 'etc'), os.path.join('rustlib', 'etc'))

        UI.delayed_display(DisplayMessage(_("You need to restart your current shell session for your {} installation "
                                            "to work properly").format(self.name)))
Esempio n. 33
0
    def post_install(self):
        """Add necessary environment variables"""
        # add a few fall-back variables that might be used by some tools
        # do not set ANDROID_SDK_HOME here as that is the path of the preference folder expected by the Android tools
        add_env_to_user(self.name, {"ANDROID_HOME": {"value": self.install_path, "keep": False},
                                    "ANDROID_SDK": {"value": self.install_path, "keep": False},
                                    "PATH": {"value": [os.path.join(self.install_path, "tools"),
                                                       os.path.join(self.install_path, "tools", "bin")]}})
        UI.delayed_display(DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))

        # print wiki page message
        UI.delayed_display(DisplayMessage("SDK installed in {}. More information on how to use it on {}".format(
                                          self.install_path,
                                          "https://developer.android.com/sdk/installing/adding-packages.html")))
Esempio n. 34
0
    def post_install(self):
        """Add rust necessary env variables"""
        add_env_to_user(self.name, {"PATH": {"value": "{}:{}".format(os.path.join(self.install_path, "rustc", "bin"),
                                                                     os.path.join(self.install_path, "cargo", "bin"))},
                                    "LD_LIBRARY_PATH": {"value": os.path.join(self.install_path, "rustc", "lib")}})

        # adjust for rust: some symlinks magic to have stdlib craft available
        arch_lib_folder = '{}-unknown-linux-gnu'.format(self.arch_trans[get_current_arch()])
        lib_folder = os.path.join(self.install_path, 'rust-std-{}'.format(arch_lib_folder),
                                  'lib', 'rustlib', arch_lib_folder, 'lib')
        for f in os.listdir(lib_folder):
            os.symlink(os.path.join(lib_folder, f),
                       os.path.join(self.install_path, 'rustc', 'lib', 'rustlib', arch_lib_folder, 'lib', f))

        UI.delayed_display(DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Esempio n. 35
0
 def post_install(self):
     """Add the necessary Scala environment variables"""
     add_env_to_user(
         self.name, {
             "PATH": {
                 "value": os.path.join(self.install_path, "bin")
             },
             "SCALA_HOME": {
                 "value": self.install_path
             }
         })
     UI.delayed_display(
         DisplayMessage(
             _("You need to restart the shell session for your installation to work"
               )))
Esempio n. 36
0
    def decompress_and_install_done(self, result):
        self._install_done = True
        error_detected = False
        for fd in result:
            if result[fd].error:
                logger.error(result[fd].error)
                error_detected = True
            fd.close()
        if error_detected:
            UI.return_main_screen()

        self.post_install()

        # Mark as installation done in configuration
        self.mark_in_config()

        UI.delayed_display(DisplayMessage("Installation done"))
        UI.return_main_screen()
Esempio n. 37
0
    def decompress_and_install_done(self, result):
        self._install_done = True
        error_detected = False
        for fd in result:
            if result[fd].error:
                logger.error(result[fd].error)
                error_detected = True
            fd.close()
        if error_detected:
            UI.return_main_screen(status_code=1)

        self.post_install()

        # Mark as installation done in configuration
        self.mark_in_config()

        UI.delayed_display(DisplayMessage("Installation done"))
        UI.return_main_screen()
Esempio n. 38
0
 def post_install(self):
     """Create the Arduino launcher"""
     icon_path = join(self.install_path, 'lib', 'arduino_icon.ico')
     comment = _("The Arduino Software IDE")
     categories = "Development;IDE;"
     create_launcher(self.desktop_filename,
                     get_application_desktop_file(name=_("Arduino"),
                                                  icon_path=icon_path,
                                                  try_exec=self.exec_path,
                                                  exec=self.exec_link_name,
                                                  comment=comment,
                                                  categories=categories))
     # add the user to arduino group
     if not self.was_in_arduino_group:
         with futures.ProcessPoolExecutor(max_workers=1) as executor:
             f = executor.submit(_add_to_group, self._current_user, self.ARDUINO_GROUP)
             if not f.result():
                 UI.return_main_screen(status_code=1)
         UI.delayed_display(DisplayMessage(_("You need to logout and login again for your installation to work")))
Esempio n. 39
0
 def post_install(self):
     """Create the Arduino launcher"""
     icon_path = join(self.install_path, 'lib', 'arduino_icon.ico')
     comment = _("The Arduino Software IDE")
     categories = "Development;IDE;"
     create_launcher(self.desktop_filename,
                     get_application_desktop_file(name=_("Arduino"),
                                                  icon_path=icon_path,
                                                  try_exec=self.exec_path,
                                                  exec=self.exec_link_name,
                                                  comment=comment,
                                                  categories=categories))
     # add the user to arduino group
     if not self.was_in_arduino_group:
         with futures.ProcessPoolExecutor(max_workers=1) as executor:
             f = executor.submit(_add_to_group, self._current_user, self.ARDUINO_GROUP)
             if not f.result():
                 UI.return_main_screen(status_code=1)
         UI.delayed_display(DisplayMessage(_("You need to logout and login again for your installation to work")))
Esempio n. 40
0
 def post_install(self):
     """Add nodejs necessary env variables and move module folder"""
     subprocess.call([
         os.path.join(self.install_path, "bin", "npm"), "config", "set",
         "prefix", "~/.node_modules"
     ])
     add_env_to_user(
         self.name, {
             "PATH": {
                 "value":
                 "{}:{}".format(
                     os.path.join(self.install_path, "bin"),
                     os.path.join(os.path.expanduser('~'), ".node_modules",
                                  "bin"))
             }
         })
     UI.delayed_display(
         DisplayMessage(
             _("You need to restart your current shell session for your {} installation "
               "to work properly").format(self.name)))
Esempio n. 41
0
    def remove(self):
        """Remove current framework if installed

        Not that we only remove desktop file, launcher icon and dir content, we do not remove
        packages as they might be in used for other framework"""
        # check if it's installed and so on.
        super().remove()

        UI.display(DisplayMessage("Removing {}".format(self.name)))
        if self.desktop_filename:
            with suppress(FileNotFoundError):
                os.remove(get_launcher_path(self.desktop_filename))
        if self.icon_filename:
            with suppress(FileNotFoundError):
                os.remove(get_icon_path(self.icon_filename))
        with suppress(FileNotFoundError):
            shutil.rmtree(self.install_path)
        remove_framework_envs_from_user(self.name)
        self.remove_from_config()

        UI.delayed_display(DisplayMessage("Suppression done"))
        UI.return_main_screen()
Esempio n. 42
0
 def run_display(future):
     nonlocal now
     self.function_thread = threading.current_thread().ident
     now = time()
     UI.delayed_display(self.contentType)
Esempio n. 43
0
 def run_display(future):
     nonlocal now
     self.function_thread = threading.current_thread().ident
     now = time()
     UI.delayed_display(self.contentType)
Esempio n. 44
0
 def post_install(self):
     """Add go necessary env variables"""
     add_env_to_user(self.name, {"PATH": {"value": os.path.join(self.install_path, "bin")},
                                 "GOROOT": {"value": self.install_path, "keep": False}})
     UI.delayed_display(DisplayMessage(_("You need to restart your current shell session for your {} installation "
                                         "to work properly").format(self.name)))
Esempio n. 45
0
 def post_install(self):
     """Add the Kotlin binary dir to PATH"""
     add_env_to_user(self.name, {"PATH": {"value": os.path.join(self.install_path, "bin")}})
     UI.delayed_display(DisplayMessage(_("You need to restart your current shell session for your {} installation "
                                         "to work properly").format(self.name)))
Esempio n. 46
0
 def post_install(self):
     """Add the Kotlin binary dir to PATH"""
     add_env_to_user(self.name, {"PATH": {"value": os.path.join(self.install_path, "bin")}})
     UI.delayed_display(DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Esempio n. 47
0
 def post_install(self):
     """Add necessary environment variables"""
     add_env_to_user(self.name, {"PATH": {"value": [os.path.join(self.install_path, "platform-tools")]}})
     UI.delayed_display(DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Esempio n. 48
0
 def post_install(self):
     """Add the necessary Maven environment variables"""
     add_env_to_user(self.name, {"PATH": {"value": os.path.join(self.install_path, "bin")}})
     UI.delayed_display(DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Esempio n. 49
0
 def post_install(self):
     """Add the necessary Scala environment variables"""
     add_env_to_user(self.name, {"PATH": {"value": os.path.join(self.install_path, "bin")},
                                 "SCALA_HOME": {"value": self.install_path}})
     UI.delayed_display(DisplayMessage(_("You need to restart your current shell session for your {} installation "
                                         "to work properly").format(self.name)))
Esempio n. 50
0
 def post_install(self):
     """Add go necessary env variables"""
     add_env_to_user(self.name, {"PATH": {"value": os.path.join(self.install_path, "bin")},
                                 "GOROOT": {"value": self.install_path, "keep": False}})
     UI.delayed_display(DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))