Exemplo n.º 1
0
    def test_can_copy_icon_with_glob(self):
        """Copy an icon with glob pattern matching"""
        # we copy any file and treat it as an icon
        copy_icon(os.path.join(self.server_dir, "sim*file"), "foo.png")

        self.assertTrue(os.path.exists(get_icon_path("foo.png")))
        self.assertEqual(open(os.path.join(self.server_dir, "simplefile")).read(),
                         open(get_icon_path("foo.png")).read())
Exemplo n.º 2
0
    def test_can_update_icon(self):
        """Update a basic icon with a new content"""
        copy_icon(os.path.join(self.server_dir, "simplefile"), "foo.png")
        copy_icon(os.path.join(self.server_dir, "biggerfile"), "foo.png")

        self.assertTrue(os.path.exists(get_icon_path("foo.png")))
        self.assertEqual(open(os.path.join(self.server_dir, "biggerfile")).read(),
                         open(get_icon_path("foo.png")).read())
Exemplo n.º 3
0
    def test_can_copy_icon(self):
        """Copy a basic icon"""
        # we copy any file and treat it as an icon
        copy_icon(os.path.join(self.server_dir, "simplefile"), "foo.png")

        self.assertTrue(os.path.exists(get_icon_path("foo.png")))
        self.assertEqual(open(os.path.join(self.server_dir, "simplefile")).read(),
                         open(get_icon_path("foo.png")).read())
Exemplo n.º 4
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()
Exemplo n.º 5
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()
Exemplo n.º 6
0
 def tearDown(self):
     # don't remove on machine paths if running within a container
     if not self.in_container:
         with suppress(FileNotFoundError):
             shutil.rmtree(self.installed_path)
         with suppress(FileNotFoundError):
             os.remove(self.conf_path)
         with suppress(FileNotFoundError):
             os.remove(get_launcher_path(self.desktop_filename))
         with suppress(FileNotFoundError):
             if self.icon_filename:
                 os.remove(get_icon_path(self.icon_filename))
     super().tearDown()
Exemplo n.º 7
0
 def tearDown(self):
     # don't remove on machine paths if running within a container
     if not self.in_container:
         with suppress(FileNotFoundError):
             shutil.rmtree(self.installed_path)
         # TODO: need to be finer grain in the future
         with suppress(FileNotFoundError):
             os.remove(self.conf_path)
         if self.desktop_filename:
             with suppress(FileNotFoundError):
                 os.remove(get_launcher_path(self.desktop_filename))
         with suppress(FileNotFoundError):
             if self.icon_filename:
                 os.remove(get_icon_path(self.icon_filename))
         remove_framework_envs_from_user(self.framework_name_for_profile)
         for dir in self.additional_dirs:
             with suppress(OSError):
                 shutil.rmtree(dir)
     super().tearDown()
Exemplo n.º 8
0
 def tearDown(self):
     # don't remove on machine paths if running within a container
     if not self.in_container:
         with suppress(FileNotFoundError):
             shutil.rmtree(self.installed_path)
         # TODO: need to be finer grain in the future
         with suppress(FileNotFoundError):
             os.remove(self.conf_path)
         if self.desktop_filename:
             with suppress(FileNotFoundError):
                 os.remove(get_launcher_path(self.desktop_filename))
         with suppress(FileNotFoundError):
             if self.icon_filename:
                 os.remove(get_icon_path(self.icon_filename))
         remove_framework_envs_from_user(self.framework_name_for_profile)
         for dir in self.additional_dirs:
             with suppress(OSError):
                 shutil.rmtree(dir)
     super().tearDown()
Exemplo n.º 9
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()
Exemplo n.º 10
0
 def test_get_icon_path(self):
     """Get correct launcher path"""
     self.assertEqual(get_icon_path("foo.png"),
                      os.path.join(self.local_dir, "icons", "foo.png"))
Exemplo n.º 11
0
    def test_create_icon_without_xdg_dir(self):
        """Save a new icon in an unexisting directory"""
        shutil.rmtree(self.local_dir)
        copy_icon(os.path.join(self.server_dir, "simplefile"), "foo.png")

        self.assertTrue(os.path.exists(get_icon_path("foo.png")))
Exemplo n.º 12
0
 def test_get_icon_path(self):
     """Get correct launcher path"""
     self.assertEqual(get_icon_path("foo.png"), os.path.join(self.local_dir, "icons", "foo.png"))
Exemplo n.º 13
0
    def test_create_icon_without_xdg_dir(self):
        """Save a new icon in an unexisting directory"""
        shutil.rmtree(self.local_dir)
        copy_icon(os.path.join(self.server_dir, "simplefile"), "foo.png")

        self.assertTrue(os.path.exists(get_icon_path("foo.png")))