From 9a996055d3470e46e3a41a1643024624e8708949 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Fri, 6 Oct 2023 13:12:47 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20Java,=20Godot,=20Blender,=20RStudio=20url?= =?UTF-8?q?s=20Remove=20icon=20pinning=20in=20launcher=20(only=20worked=20?= =?UTF-8?q?on=20Unity)=20Add=20Logic=20section=20with=20Proteg=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/large/__init__.py | 6 +-- tests/large/test_android.py | 2 +- tests/large/test_baseinstaller.py | 52 ++++++++++---------- tests/large/test_electronics.py | 4 +- tests/large/test_games.py | 12 ++--- tests/large/test_ide.py | 28 +++++------ tests/large/test_web.py | 4 +- tests/medium/__init__.py | 5 -- tests/medium/test_baseinstaller.py | 8 +-- tests/medium/test_dart.py | 4 +- tests/medium/test_devops.py | 2 +- tests/medium/test_electronics.py | 6 +-- tests/medium/test_games.py | 6 +-- tests/medium/test_ide.py | 22 ++++----- tests/medium/test_web.py | 6 +-- tests/small/test_frameworks_loader.py | 6 +-- tests/small/test_tools.py | 57 +-------------------- umake/__init__.py | 3 +- umake/frameworks/baseinstaller.py | 5 +- umake/frameworks/games.py | 22 ++------- umake/frameworks/ide.py | 7 +-- umake/frameworks/java.py | 4 +- umake/frameworks/logic.py | 71 +++++++++++++++++++++++++++ umake/tools.py | 25 +++------- 24 files changed, 175 insertions(+), 192 deletions(-) create mode 100644 umake/frameworks/logic.py diff --git a/tests/large/__init__.py b/tests/large/__init__.py index 2cb7db11..7883527a 100644 --- a/tests/large/__init__.py +++ b/tests/large/__init__.py @@ -28,7 +28,7 @@ import stat import subprocess from time import sleep -from umake.tools import get_icon_path, get_launcher_path, launcher_exists_and_is_pinned, remove_framework_envs_from_user +from umake.tools import get_icon_path, get_launcher_path, remove_framework_envs_from_user from ..tools import LoggedTestCase, get_path_from_desktop_file, is_in_group, INSTALL_DIR, swap_file_and_restore, \ spawn_process, set_local_umake, BRANCH_TESTS from umake.settings import DEFAULT_BINARY_LINK_PATH @@ -204,10 +204,6 @@ def get_launcher_path(self, desktop_filename): """passthrough getting the launcher path from umake tools""" return get_launcher_path(desktop_filename) - def launcher_exists_and_is_pinned(self, desktop_filename): - """passthrough to in process method""" - return launcher_exists_and_is_pinned(desktop_filename) - def path_exists(self, path): """passthrough to os.path.exists""" return os.path.exists(path) diff --git a/tests/large/test_android.py b/tests/large/test_android.py index 73d740e7..4f533658 100644 --- a/tests/large/test_android.py +++ b/tests/large/test_android.py @@ -48,7 +48,7 @@ def test_default_android_studio_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() diff --git a/tests/large/test_baseinstaller.py b/tests/large/test_baseinstaller.py index d64b4551..31aefd74 100644 --- a/tests/large/test_baseinstaller.py +++ b/tests/large/test_baseinstaller.py @@ -94,7 +94,7 @@ def test_default_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() @@ -121,7 +121,7 @@ def test_no_license_accept(self): self.accept_default_and_wait() self.close_and_check_status() - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) def test_doesnt_accept_wrong_path(self): """We don't accept a wrong path""" @@ -134,7 +134,7 @@ def test_doesnt_accept_wrong_path(self): self.child.sendcontrol('C') self.wait_and_no_warn() - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) def test_reinstall(self): """Reinstall once installed""" @@ -152,7 +152,7 @@ def test_reinstall(self): self.wait_and_close() # we have an installed launcher, added to the launcher - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() # launch it, send SIGTERM and check that it exits fine @@ -180,7 +180,7 @@ def test_reinstall_other_path(self): self.wait_and_close() # we have an installed launcher, added to the launcher - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() # ensure that version first isn't installed anymore @@ -213,7 +213,7 @@ def test_reinstall_other_non_empty_path(self): self.wait_and_close() # we have an installed launcher, added to the launcher - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() # ensure that version first isn't installed anymore @@ -236,7 +236,7 @@ def test_reinstall_previous_install_removed(self): self.wait_and_close() # we have an installed launcher, added to the launcher - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() def test_reinstall_previous_launcher_removed(self): @@ -259,7 +259,7 @@ def test_reinstall_previous_launcher_removed(self): self.wait_and_close() # we have an installed launcher, added to the launcher - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() def test_xdg_data_install_path(self): @@ -276,7 +276,7 @@ def test_xdg_data_install_path(self): self.expect_and_no_warn(r"\[I Accept.*\]") self.accept_default_and_wait() self.close_and_check_status() - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) def test_custom_install_path(self): """We install Base Framework in a custom path""" @@ -289,7 +289,7 @@ def test_custom_install_path(self): self.wait_and_close() # we have an installed launcher, added to the launcher - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() @@ -311,7 +311,7 @@ def test_start_install_on_empty_dir(self): self.accept_default_and_wait() self.close_and_check_status() - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) def test_start_install_on_existing_dir_refuse(self): """We prompt if we try to install on an existing directory which isn't empty. Refusing doesn't install""" @@ -325,7 +325,7 @@ def test_start_install_on_existing_dir_refuse(self): self.accept_default_and_wait() self.close_and_check_status() - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) def test_start_install_on_existing_dir_accept(self): """We prompt if we try to install on an existing directory which isn't empty. Accepting install""" @@ -343,7 +343,7 @@ def test_start_install_on_existing_dir_accept(self): self.wait_and_close() # we have an installed launcher, added to the launcher - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() @@ -386,7 +386,7 @@ def test_is_default_framework_with_user_path(self): self.wait_and_close() # we have an installed launcher, added to the launcher - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() @@ -406,14 +406,14 @@ def test_removal(self): self.child.sendline("a") self.expect_and_no_warn(r"Installation done", timeout=self.TIMEOUT_INSTALL_PROGRESS) self.wait_and_close() - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assertTrue(self.path_exists(self.installed_path)) # now, remove it self.child = spawn_process(self.command('{} base base-framework --remove'.format(UMAKE))) self.wait_and_close() - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.path_exists(self.installed_path)) self.assertFalse(self.path_exists(os.path.dirname(self.installed_path))) self.assertFalse(self.path_exists(self.exec_link)) @@ -426,14 +426,14 @@ def test_removal_non_default_path(self): self.child.sendline("a") self.expect_and_no_warn(r"Installation done", timeout=self.TIMEOUT_INSTALL_PROGRESS) self.wait_and_close() - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assertTrue(self.path_exists(self.installed_path)) # now, remove it self.child = spawn_process(self.command('{} base base-framework --remove'.format(UMAKE))) self.wait_and_close() - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.path_exists(self.installed_path)) def test_removal_global_option(self): @@ -445,14 +445,14 @@ def test_removal_global_option(self): self.child.sendline("a") self.expect_and_no_warn(r"Installation done", timeout=self.TIMEOUT_INSTALL_PROGRESS) self.wait_and_close() - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assertTrue(self.path_exists(self.installed_path)) # now, remove it self.child = spawn_process(self.command('{} --remove base base-framework'.format(UMAKE))) self.wait_and_close() - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.path_exists(self.installed_path)) self.assertFalse(self.path_exists(os.path.dirname(self.installed_path))) @@ -464,7 +464,7 @@ def test_automated_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() def test_try_removing_uninstalled_framework(self): @@ -489,13 +489,13 @@ def test_install_with_wrong_md5sum(self): self.wait_and_close(exit_status=1) # we have nothing installed - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) def test_install_with_no_license_in_download_page(self): """Installing should fail if license is not in download page""" umake_command = self.command("{} base base-framework".format(UMAKE)) self.bad_download_page_test(umake_command, self.download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) def test_install_with_no_download_links(self): """Installing should fail if no valid download links are found""" @@ -509,7 +509,7 @@ def test_install_with_no_download_links(self): self.wait_and_close(exit_status=1) # we have nothing installed - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) def test_install_with_404(self): """Installing should fail with a 404 download asset reported correctly""" @@ -527,7 +527,7 @@ def test_install_with_404(self): self.wait_and_close(exit_status=1) # we have nothing installed - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) def test_download_page_404(self): """Download page changed address or is just 404 should be reported correctly""" @@ -541,4 +541,4 @@ def test_download_page_404(self): self.wait_and_close(exit_status=1) # we have nothing installed - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) diff --git a/tests/large/test_electronics.py b/tests/large/test_electronics.py index 5be9867b..0ecf1eb5 100644 --- a/tests/large/test_electronics.py +++ b/tests/large/test_electronics.py @@ -55,7 +55,7 @@ def test_default_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher and an icon file - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assertTrue(self.is_in_group("dialout")) @@ -99,7 +99,7 @@ def test_default_eclipse_ide_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher and an icon file - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() diff --git a/tests/large/test_games.py b/tests/large/test_games.py index a08da32a..49b1f7fe 100644 --- a/tests/large/test_games.py +++ b/tests/large/test_games.py @@ -47,7 +47,7 @@ def test_default_blender_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() @@ -95,7 +95,7 @@ def test_default_unity3D_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() @@ -140,7 +140,7 @@ def test_default_twine_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() @@ -182,7 +182,7 @@ def test_default_superpowers_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() @@ -224,7 +224,7 @@ def test_default_gdevelop_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() @@ -266,7 +266,7 @@ def test_default_godot_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() diff --git a/tests/large/test_ide.py b/tests/large/test_ide.py index f173fa7d..5d6302cf 100644 --- a/tests/large/test_ide.py +++ b/tests/large/test_ide.py @@ -57,7 +57,7 @@ def test_default_eclipse_ide_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher and an icon file - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() @@ -141,7 +141,7 @@ def test_default_install(self): self.assertTrue(self.name == 'GoLand') elif result == 1: # we have an installed launcher, added to the launcher and an icon file - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() @@ -175,7 +175,7 @@ def test_eap_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher and an icon file - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() @@ -383,7 +383,7 @@ def test_default_install(self): logger.info("Installed, running...") # we have an installed launcher, added to the launcher and an icon file - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() @@ -429,7 +429,7 @@ def test_default_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher and an icon file - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() @@ -466,7 +466,7 @@ def test_insiders_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher and an icon file - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() @@ -510,7 +510,7 @@ def test_default_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher and an icon file - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() @@ -560,7 +560,7 @@ def test_default_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher and an icon file - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() @@ -614,7 +614,7 @@ def test_default_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher and an icon file - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() @@ -663,7 +663,7 @@ def test_default_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher and an icon file - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() @@ -705,7 +705,7 @@ def test_default_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher and an icon file - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() @@ -752,7 +752,7 @@ def test_default_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher and an icon file - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() @@ -800,7 +800,7 @@ def test_default_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher and an icon file - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() @@ -845,7 +845,7 @@ def test_default_install(self): self.wait_and_close() # we have an installed launcher, added to the launcher and an icon file - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assert_exec_exists() self.assert_icon_exists() self.assert_exec_link_exists() diff --git a/tests/large/test_web.py b/tests/large/test_web.py index 1d9fc604..8de87118 100644 --- a/tests/large/test_web.py +++ b/tests/large/test_web.py @@ -48,7 +48,7 @@ def arch_option(self): def verify_install(self, installed_language): # we have an installed launcher, added to the launcher, a dictionary file and an icon file - self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertTrue(self.launcher_exists(self.desktop_filename)) self.assertTrue(self.language_file_exists(installed_language)) self.assert_exec_exists() self.assert_icon_exists() @@ -111,7 +111,7 @@ def test_unavailable_language_select_install(self): self.child.sendline("") self.wait_and_close(expect_warn=True, exit_status=1) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) def language_file_exists(self, language): return self.path_exists(os.path.join(self.installed_path, "dictionaries", "{}.aff".format(language))) diff --git a/tests/medium/__init__.py b/tests/medium/__init__.py index c81e4146..922ddc6f 100644 --- a/tests/medium/__init__.py +++ b/tests/medium/__init__.py @@ -178,11 +178,6 @@ def get_launcher_path(self, desktop_filename): desktop_filename]) return self._exec_command(command)[1] - def launcher_exists_and_is_pinned(self, desktop_filename): - """Check if launcher exists and is pinned inside the container""" - command = self.command_as_list([os.path.join(get_tools_helper_dir(), "check_launcher_exists_and_is_pinned"), - desktop_filename]) - return self._exec_command(command)[0] def path_exists(self, path): """Check if a path exists inside the container""" diff --git a/tests/medium/test_baseinstaller.py b/tests/medium/test_baseinstaller.py index 63dd39fb..249957ac 100644 --- a/tests/medium/test_baseinstaller.py +++ b/tests/medium/test_baseinstaller.py @@ -56,7 +56,7 @@ def test_install_wrong_download_link_update(self): self.wait_and_close(exit_status=1) # we have nothing installed - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) def test_install_wrong_download_link_no_update(self): """Install wrong download link, no update available""" @@ -78,7 +78,7 @@ def test_install_wrong_download_link_no_update(self): self.assertNotIn("To get the latest version", self.child.before) # we have nothing installed - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) def test_install_wrong_download_link_404_update(self): """Install wrong download link, github giving 404""" @@ -95,7 +95,7 @@ def test_install_wrong_download_link_404_update(self): self.assertIn("\r\nERROR: 404 Client Error:", self.child.before) # we have nothing installed - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) def test_install_wrong_download_link_github_missing(self): # TODO: cut all network connection on the container to enable that test @@ -111,4 +111,4 @@ def test_install_wrong_download_link_github_missing(self): self.wait_and_close(exit_status=1) # we have nothing installed - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) diff --git a/tests/medium/test_dart.py b/tests/medium/test_dart.py index 0d4a59eb..c291080b 100644 --- a/tests/medium/test_dart.py +++ b/tests/medium/test_dart.py @@ -41,7 +41,7 @@ def test_install_with_changed_version_page(self): "channels/stable/release/latest/VERSION") umake_command = self.command('{} dart'.format(UMAKE)) self.bad_download_page_test(umake_command, download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) class FlutterInContainer(ContainerTests, test_dart.FlutterTests): @@ -60,4 +60,4 @@ def test_install_with_changed_version_page(self): "releases/releases_linux.json") umake_command = self.command('{} dart flutter-sdk'.format(UMAKE)) self.bad_download_page_test(umake_command, download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) diff --git a/tests/medium/test_devops.py b/tests/medium/test_devops.py index ed19790d..493ab1fc 100644 --- a/tests/medium/test_devops.py +++ b/tests/medium/test_devops.py @@ -43,5 +43,5 @@ def test_install_with_changed_download_page(self): "repos", "hashicorp", "terraform", "releases", "latest") self.command('{} devops terraform'.format(UMAKE)) self.bad_download_page_test(self.command(self.command_args), download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(self.exec_link)) diff --git a/tests/medium/test_electronics.py b/tests/medium/test_electronics.py index a6a4ebf2..df155c04 100644 --- a/tests/medium/test_electronics.py +++ b/tests/medium/test_electronics.py @@ -46,7 +46,7 @@ def test_install_with_changed_download_page(self): "Software") umake_command = self.command('{} electronics arduino'.format(UMAKE)) self.bad_download_page_test(umake_command, download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(self.exec_link)) def test_install_with_changed_checksum_page(self): @@ -55,7 +55,7 @@ def test_install_with_changed_checksum_page(self): "arduino-mock.sha512sum.txt") umake_command = self.command('{} electronics arduino'.format(UMAKE)) self.bad_download_page_test(umake_command, download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(self.exec_link)) @@ -77,5 +77,5 @@ def test_install_with_changed_download_page(self): "downloads", "latest.html") umake_command = self.command('{} electronics eagle'.format(UMAKE)) self.bad_download_page_test(umake_command, download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(self.exec_link)) diff --git a/tests/medium/test_games.py b/tests/medium/test_games.py index 4348e0d7..7922985d 100644 --- a/tests/medium/test_games.py +++ b/tests/medium/test_games.py @@ -85,7 +85,7 @@ def test_install_with_changed_download_page(self): "repos", "superpowers", "superpowers-app", "releases", "latest") umake_command = self.command('{} games superpowers'.format(UMAKE)) self.bad_download_page_test(self.command(self.command_args), download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(self.exec_link)) @@ -108,7 +108,7 @@ def test_install_with_changed_download_page(self): "repos", "4ian", "GD", "releases", "latest") umake_command = self.command('{} games gdevelop'.format(UMAKE)) self.bad_download_page_test(self.command(self.command_args), download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(self.exec_link)) @@ -130,5 +130,5 @@ def test_install_with_changed_download_page(self): "download", "linux", "index.html") umake_command = self.command('{} games godot'.format(UMAKE)) self.bad_download_page_test(self.command(self.command_args), download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(self.exec_link)) diff --git a/tests/medium/test_ide.py b/tests/medium/test_ide.py index b8f7f0cb..bf3e61c8 100644 --- a/tests/medium/test_ide.py +++ b/tests/medium/test_ide.py @@ -55,13 +55,13 @@ def test_install_with_changed_download_page(self): download_page_file_path = os.path.join(get_data_dir(), "server-content", "www.eclipse.org", "downloads", "packages", "index.html") self.bad_download_page_test(self.command(self.command_args), download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(self.exec_link)) def test_install_with_changed_checksum_page(self): """Installing eclipse ide should fail if checksum link is unparsable""" self.bad_download_page_test(self.command(self.command_args), self.bad_download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(self.exec_link)) @@ -143,7 +143,7 @@ def setUp(self): def test_install_with_changed_download_page(self): """Installing IntelliJ Idea should fail if download page has changed""" self.bad_download_page_test(self.command(self.command_args), self.bad_download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(self.exec_link)) @@ -348,7 +348,7 @@ def test_install_with_changed_download_page(self): "incubator", "netbeans", "incubating-netbeans", "index.html") umake_command = self.command('{} ide netbeans'.format(UMAKE)) self.bad_download_page_test(umake_command, download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(self.exec_link)) @@ -385,7 +385,7 @@ def test_install_with_changed_download_page(self): "repos", "LightTable", "LightTable", "releases", "latest") umake_command = self.command('{} ide lighttable'.format(UMAKE)) self.bad_download_page_test(self.command(self.command_args), download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(self.exec_link)) @@ -418,7 +418,7 @@ def test_install_with_changed_download_page(self): "repos", "DBeaver", "DBeaver", "releases", "latest") umake_command = self.command('{} ide dbeaver'.format(UMAKE)) self.bad_download_page_test(self.command(self.command_args), download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(self.exec_link)) @@ -453,7 +453,7 @@ def test_install_with_changed_download_page(self): download_page_file_path = os.path.join(get_data_dir(), "server-content", "spring.io", "tools") umake_command = self.command('{} ide spring-tools-suite'.format(UMAKE)) self.bad_download_page_test(self.command(self.command_args), download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(self.exec_link)) def test_install_with_changed_checksum_page(self): @@ -462,7 +462,7 @@ def test_install_with_changed_checksum_page(self): 'STS4', 'mock.RELEASE', 'dist', 'emock', 'spring-tool-suite-mock.RELEASE-emock-linux.gtk.x86_64.tar.gz.sha1') self.bad_download_page_test(self.command(self.command_args), download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(self.exec_link)) @@ -485,7 +485,7 @@ def test_install_with_changed_download_page(self): "repos", "processing", "processing", "releases", "latest") umake_command = self.command('{} ide processing'.format(UMAKE)) self.bad_download_page_test(self.command(self.command_args), download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(self.exec_link)) @@ -508,7 +508,7 @@ def test_install_with_changed_download_page(self): "repos", "visualfc", "liteide", "releases", "latest") umake_command = self.command('{} ide liteide'.format(UMAKE)) self.bad_download_page_test(self.command(self.command_args), download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(self.exec_link)) @@ -531,5 +531,5 @@ def test_install_with_changed_download_page(self): "repos", "VSCodium", "VSCodium", "releases", "latest") umake_command = self.command('{} ide vscodium'.format(UMAKE)) self.bad_download_page_test(self.command(self.command_args), download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(self.exec_link)) diff --git a/tests/medium/test_web.py b/tests/medium/test_web.py index 1b4e89ab..db1a95d6 100644 --- a/tests/medium/test_web.py +++ b/tests/medium/test_web.py @@ -43,7 +43,7 @@ def test_install_with_changed_download_page(self): "firefox", "developer", "all") umake_command = self.command('{} web firefox-dev'.format(UMAKE)) self.bad_download_page_test(umake_command, download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(os.path.join(self.binary_dir, self.desktop_filename.split('.')[0]))) @@ -85,7 +85,7 @@ def test_install_with_changed_download_page(self): "repos", "mozilla", "geckodriver", "releases", "latest") umake_command = self.command('{} web geckodriver'.format(UMAKE)) self.bad_download_page_test(self.command(self.command_args), download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(self.exec_link)) @@ -107,5 +107,5 @@ def test_install_with_changed_download_page(self): "LATEST_RELEASE") umake_command = self.command('{} web chromedriver'.format(UMAKE)) self.bad_download_page_test(self.command(self.command_args), download_page_file_path) - self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assertFalse(self.launcher_exists(self.desktop_filename)) self.assertFalse(self.is_in_path(self.exec_link)) diff --git a/tests/small/test_frameworks_loader.py b/tests/small/test_frameworks_loader.py index cfb853d2..d8f58203 100644 --- a/tests/small/test_frameworks_loader.py +++ b/tests/small/test_frameworks_loader.py @@ -302,7 +302,7 @@ def test_parse_category_and_framework_run_correct_framework(self): self.CategoryHandler.categories[args.category].run_for(args) self.assertTrue(setup_call.called) - self.assertEqual(setup_call.call_args, call(install_path=None, auto_accept_license=False)) + self.assertEqual(setup_call.call_args, call(install_path=None, auto_accept_license=False, dry_run = True)) def test_parse_no_framework_run_default_for_category(self): """Parsing category will run default framework""" @@ -316,7 +316,7 @@ def test_parse_no_framework_run_default_for_category(self): as setup_call: self.CategoryHandler.categories[args.category].run_for(args) self.assertTrue(setup_call.called) - self.assertEqual(setup_call.call_args, call(install_path=None, auto_accept_license=False)) + self.assertEqual(setup_call.call_args, call(install_path=None, auto_accept_license=False, dry_run = True)) def test_parse_category_and_framework_run_correct_remove_framework(self): """Parsing category and framework with --remove run remove on right category and framework""" @@ -407,7 +407,7 @@ def test_parse_category_and_framework_get_accept_license_arg(self): self.CategoryHandler.categories[args.category].run_for(args) self.assertTrue(setup_call.called) - self.assertEqual(setup_call.call_args, call(install_path=None, auto_accept_license=True)) + self.assertEqual(setup_call.call_args, call(install_path=None, auto_accept_license=True, dry_run=True)) def test_uninstantiable_framework(self): """A uninstantiable framework isn't loaded""" diff --git a/tests/small/test_tools.py b/tests/small/test_tools.py index 90e54164..57ff8ecf 100644 --- a/tests/small/test_tools.py +++ b/tests/small/test_tools.py @@ -33,7 +33,7 @@ from ..tools import change_xdg_path, get_data_dir, LoggedTestCase, INSTALL_DIR from umake import settings, tools from umake.tools import ConfigHandler, Singleton, get_current_arch, get_foreign_archs, get_current_distro_version,\ - create_launcher, launcher_exists_and_is_pinned, launcher_exists, get_icon_path, get_launcher_path, copy_icon,\ + create_launcher, launcher_exists, get_icon_path, get_launcher_path, copy_icon,\ add_exec_link from unittest.mock import patch, Mock from contextlib import suppress @@ -568,61 +568,6 @@ def test_desktop_file_doesnt_exist(self): """Launcher file doesn't exists""" self.assertFalse(launcher_exists("foo.desktop")) - @patch("umake.tools.Gio.Settings") - def test_launcher_exists_and_is_pinned(self, SettingsMock): - """Launcher exists and is pinned if the file exists and is in favorites list""" - SettingsMock.list_schemas.return_value = ["foo", "bar", "com.canonical.Unity.Launcher", "baz"] - SettingsMock.return_value.get_strv.return_value = ["application://bar.desktop", "application://foo.desktop", - "unity://running-apps"] - self.write_desktop_file("foo.desktop") - - self.assertTrue(launcher_exists_and_is_pinned("foo.desktop")) - - @patch("umake.tools.Gio.Settings") - def test_launcher_isnt_pinned(self, SettingsMock): - """Launcher doesn't exists and is pinned if the file exists but not in favorites list""" - SettingsMock.list_schemas.return_value = ["foo", "bar", "com.canonical.Unity.Launcher", "baz"] - SettingsMock.return_value.get_strv.return_value = ["application://bar.desktop", "unity://running-apps"] - self.write_desktop_file("foo.desktop") - - self.assertFalse(launcher_exists_and_is_pinned("foo.desktop")) - - @patch("umake.tools.Gio.Settings") - def test_launcher_exists_but_isnt_pinned_in_none_unity(self, SettingsMock): - """Launcher exists return True if file exists, not pinned but not in Unity""" - os.environ["XDG_CURRENT_DESKTOP"] = "FOOenv" - SettingsMock.list_schemas.return_value = ["foo", "bar", "com.canonical.Unity.Launcher", "baz"] - SettingsMock.return_value.get_strv.return_value = ["application://bar.desktop", "unity://running-apps"] - self.write_desktop_file("foo.desktop") - - self.assertTrue(launcher_exists_and_is_pinned("foo.desktop")) - - @patch("umake.tools.Gio.Settings") - def test_launcher_exists_but_not_schema_in_none_unity(self, SettingsMock): - """Launcher exists return True if file exists, even if Unity schema isn't installed""" - os.environ["XDG_CURRENT_DESKTOP"] = "FOOenv" - SettingsMock.list_schemas.return_value = ["foo", "bar", "baz"] - self.write_desktop_file("foo.desktop") - - self.assertTrue(launcher_exists_and_is_pinned("foo.desktop")) - - @patch("umake.tools.Gio.Settings") - def test_launcher_exists_but_not_schema_in_unity(self, SettingsMock): - """Launcher exists return False if file exists, but no Unity schema installed""" - SettingsMock.list_schemas.return_value = ["foo", "bar", "baz"] - self.write_desktop_file("foo.desktop") - - self.assertFalse(launcher_exists_and_is_pinned("foo.desktop")) - - @patch("umake.tools.Gio.Settings") - def test_launcher_doesnt_exists_but_pinned(self, SettingsMock): - """Launcher doesn't exist if no file, even if pinned""" - SettingsMock.list_schemas.return_value = ["foo", "bar", "com.canonical.Unity.Launcher", "baz"] - SettingsMock.return_value.get_strv.return_value = ["application://bar.desktop", "application://foo.desktop", - "unity://running-apps"] - - self.assertFalse(launcher_exists_and_is_pinned("foo.desktop")) - def test_can_copy_icon(self): """Copy a basic icon""" # we copy any file and treat it as an icon diff --git a/umake/__init__.py b/umake/__init__.py index 560bf746..89aeb112 100644 --- a/umake/__init__.py +++ b/umake/__init__.py @@ -97,7 +97,7 @@ def set_logging_from_args(args, parser): def should_load_all_frameworks(args): """Set partial or complete framework loading condition based on arg""" for arg in args[1:]: - if arg in ["-l", "--list", "--list-installed", "--list-available"]: + if arg in ["-l", "--list", "--list-installed", "--list-available", "--list-json"]: return True return False @@ -139,6 +139,7 @@ def main(): 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")) + list_group.add_argument('--list-json', action="store_true", help=_("List installable frameworks (json)")) parser.add_argument('--version', action="store_true", help=_("Print version and exit")) diff --git a/umake/frameworks/baseinstaller.py b/umake/frameworks/baseinstaller.py index 04e45701..3ee73fdc 100644 --- a/umake/frameworks/baseinstaller.py +++ b/umake/frameworks/baseinstaller.py @@ -37,7 +37,7 @@ from umake.ui import UI from umake.settings import DEFAULT_INSTALL_TOOLS_PATH from umake.tools import MainLoop, strip_tags, launcher_exists, get_icon_path, get_launcher_path, \ - Checksum, remove_framework_envs_from_user, add_exec_link + Checksum, remove_framework_envs_from_user, add_exec_link, validate_url logger = logging.getLogger(__name__) @@ -295,7 +295,8 @@ def check_data_and_start_download(self, url=None, checksum=None, license_txt=Str self.download_requests.append(DownloadItem(url, Checksum(self.checksum_type, checksum))) if self.dry_run: - UI.display(DisplayMessage("Found download URL: " + url)) + if validate_url(url): + UI.display(DisplayMessage("Found download URL: " + url)) if checksum is not None: UI.display(DisplayMessage("Found download checksum: " + checksum)) UI.return_main_screen(status_code=0) diff --git a/umake/frameworks/games.py b/umake/frameworks/games.py index ac2ba196..d3a82640 100644 --- a/umake/frameworks/games.py +++ b/umake/frameworks/games.py @@ -68,7 +68,6 @@ def parse_download_link(self, line, in_download): filename = 'release' + re.search('blender-(.*)-linux', url).group(1).replace('.', '') + '.md5' self.checksum_url = os.path.join(os.path.dirname(url), filename).replace('download', 'release').replace('www', 'download') - url = url.replace('www.blender.org/download', 'download.blender.org/release') return ((url, None), in_download) def post_install(self): @@ -81,20 +80,6 @@ def post_install(self): categories="Development;IDE;Graphics")) -def _chrome_sandbox_setuid(path): - """Chown and setUID to chrome sandbox""" - # switch to root - with as_root(): - try: - os.chown(path, 0, -1) - os.chmod(path, stat.S_ISUID | stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH) - logger.debug("Changed setUID mode {}".format(path)) - return True - except Exception as e: - logger.error("Couldn't change owner and file perm to {}: {}".format(path, e)) - return False - - class Unity3D(umake.frameworks.baseinstaller.BaseInstaller): def __init__(self, **kwargs): @@ -195,7 +180,7 @@ class Godot(umake.frameworks.baseinstaller.BaseInstaller): def __init__(self, **kwargs): super().__init__(name="Godot", description=_("The game engine you waited for"), - only_on_archs=['i386', 'amd64'], + only_on_archs=['amd64'], download_page="https://godotengine.org/download/linux", desktop_filename="godot.desktop", required_files_path=['godot'], @@ -204,8 +189,7 @@ def __init__(self, **kwargs): self.icon_filename = "Godot.svg" arch_trans = { - "amd64": "64", - "i386": "32" + "amd64": "x86_64", } def parse_download_link(self, line, in_download): @@ -213,7 +197,7 @@ def parse_download_link(self, line, in_download): url = None if '{}.zip'.format(self.arch_trans[get_current_arch()]) in line: in_download = True - p = re.search(r'href=\"(.*\.zip)\"', line) + p = re.search(r'(.*\.zip)', line) with suppress(AttributeError): url = p.group(1) bin = re.search(r'(Godot.*)\.zip', url) diff --git a/umake/frameworks/ide.py b/umake/frameworks/ide.py index 1349bd21..9cd59caa 100644 --- a/umake/frameworks/ide.py +++ b/umake/frameworks/ide.py @@ -796,10 +796,11 @@ def parse_download_link(self, line, in_download): """Parse RStudio download links""" url = None checksum = None - if int(get_current_distro_version(distro_name="debian").split('.')[0]) == 9: - ubuntu_version = "debian9" + if int(get_current_distro_version(distro_name="debian").split('.')[0]) == 9 or\ + int(get_current_distro_version().split('.')[0]) == 20: + ubuntu_version = "focal" else: - ubuntu_version = 'bionic' + ubuntu_version = 'jammy' if '-debian.tar.gz' in line: p = re.search(r'href=\"([^<]*{}.*-debian\.tar\.gz)\"'.format(ubuntu_version), line) with suppress(AttributeError): diff --git a/umake/frameworks/java.py b/umake/frameworks/java.py index e6789dba..faf0182d 100644 --- a/umake/frameworks/java.py +++ b/umake/frameworks/java.py @@ -93,10 +93,10 @@ def complete_download_url(self, result): self.download_page = "https://api.adoptopenjdk.net/v3/assets/latest/{}/{}".format(version, self.jvm_impl) # Check download page, or revert to previous version - if requests.get(self.download_page).json() == []: + if requests.get(self.download_page, headers=self.headers).json() == []: self.download_page = "https://api.adoptopenjdk.net/v3/assets/latest/{}/{}".format(version_prev, self.jvm_impl) - DownloadCenter([DownloadItem(self.download_page)], self.get_metadata_and_check_license, download=False) + DownloadCenter([DownloadItem(self.download_page, headers=self.headers)], self.get_metadata_and_check_license, download=False) def parse_download_link(self, line, in_download): """Parse Java download link, expect to find a url""" diff --git a/umake/frameworks/logic.py b/umake/frameworks/logic.py new file mode 100644 index 00000000..87e2fcd1 --- /dev/null +++ b/umake/frameworks/logic.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2014 Canonical +# +# Authors: +# Galileo Sartor +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; version 3. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + +"""Logic module""" + +from gettext import gettext as _ +import logging +import os +import umake.frameworks.baseinstaller +from umake.tools import create_launcher, get_application_desktop_file +from umake.ui import UI + +logger = logging.getLogger(__name__) + + +class LogicCategory(umake.frameworks.BaseCategory): + + def __init__(self): + super().__init__(name="Logic", description=_("Tools for Logic and knowledge modelling"), + logo_path=None) + + +class Protege(umake.frameworks.baseinstaller.BaseInstaller): + + def __init__(self, **kwargs): + super().__init__(name="Protege", + description=_("Protege is an OWL ontology development environment."), + only_on_archs=['i386', 'amd64'], + download_page="https://api.github.com/repos/protegeproject/protege-distribution/releases/latest", + dir_to_decompress_in_tarball="Protege-*", + required_files_path=["protege"], + desktop_filename="protege.desktop", + json=True, **kwargs) + + def parse_download_link(self, line, in_download): + url = None + for asset in line["assets"]: + if asset["browser_download_url"].endswith("linux.tar.gz"): + in_download = True + url = asset["browser_download_url"] + return (url, in_download) + + def post_install(self): + """Create the Protege launcher""" + icon_path = os.path.join(self.install_path, "app/Protege.ico") + comment = self.description + categories = "Development;IDE;" + create_launcher(self.desktop_filename, + get_application_desktop_file(name=self.name, + icon_path=icon_path, + try_exec=self.exec_path, + exec=self.exec_link_name, + comment=comment, + categories=categories)) diff --git a/umake/tools.py b/umake/tools.py index a03e4d79..ce5b0f27 100644 --- a/umake/tools.py +++ b/umake/tools.py @@ -20,12 +20,15 @@ from collections import namedtuple from contextlib import contextmanager, suppress from enum import unique, Enum +from http.client import HTTPConnection from gettext import gettext as _ from gi.repository import GLib, Gio from glob import glob +from urllib.parse import urlsplit import logging import os import re +import requests import shutil import signal import subprocess @@ -297,24 +300,6 @@ def launcher_exists(desktop_filename): return True -def launcher_exists_and_is_pinned(desktop_filename): - """Return true if the desktop filename is pinned in the launcher""" - if not launcher_exists(desktop_filename): - return False - if os.environ.get("XDG_CURRENT_DESKTOP") != "Unity": - logger.debug("Don't check launcher as current environment isn't Unity") - return True - if "com.canonical.Unity.Launcher" not in Gio.Settings.list_schemas(): - logger.debug("In an Unity environment without the Launcher schema file") - return False - gsettings = Gio.Settings(schema_id="com.canonical.Unity.Launcher", path="/com/canonical/unity/launcher/") - launcher_list = gsettings.get_strv("favorites") - res = "application://" + desktop_filename in launcher_list - if not res: - logger.debug("Launcher exists but is not pinned (pinned: {}).".format(launcher_list)) - return res - - def copy_icon(source_icon_filepath, icon_filename): """copy icon from source filepath to xdg destination as icon_filename @@ -477,3 +462,7 @@ def add_env_to_user(framework_tag, env_dict): export = "export " f.write("{}{}={}\n".format(export, env, value)) f.write("\n") + + +def validate_url(url): + return requests.head(url).ok \ No newline at end of file