Skip to content

Commit

Permalink
Fix url parsing and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LyzardKing committed Apr 21, 2022
1 parent 81194cc commit 4c7ee2a
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 254 deletions.
3 changes: 3 additions & 0 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Make sure you try the following before submitting the issue, thank you!

This repo is for the ubuntu-make (umake) project, not the Ubuntu distro.
For assistance related to Ubuntu you should post on the forum: https://discourse.ubuntu.com/

- Check that umake is the latest version (https://github.com/ubuntu/ubuntu-make/releases)
- If you're not running the latest development version of Ubuntu, or a flavor based on it, add the ppa as described in the README.

Expand Down
42 changes: 0 additions & 42 deletions tests/large/test_electronics.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,45 +118,3 @@ def test_default_eclipse_ide_install(self):
self.expect_and_no_warn(r"{} is already installed.*\[.*\] ".format(self.name))
self.child.sendline()
self.wait_and_close()


class FritzingTests(LargeFrameworkTests):
"""The Eagle Autodesk tests."""

TIMEOUT_INSTALL_PROGRESS = 120
TIMEOUT_START = 60
TIMEOUT_STOP = 60

def setUp(self):
super().setUp()
self.installed_path = os.path.join(self.install_base_path, "electronics", "fritzing")
self.desktop_filename = "fritzing.desktop"
self.command_args = '{} electronics fritzing'.format(UMAKE)
self.name = "Fritzing"

def test_default_eclipse_ide_install(self):
"""Install fritzing from scratch test case"""
self.child = spawn_process(self.command(self.command_args))
self.expect_and_no_warn("Choose installation path: {}".format(self.installed_path))
self.child.sendline("")
self.expect_and_no_warn("Installation done", timeout=self.TIMEOUT_INSTALL_PROGRESS)
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.assert_exec_exists()
self.assert_icon_exists()
self.assert_exec_link_exists()

# launch it, send SIGTERM and check that it exits fine
proc = subprocess.Popen(self.command_as_list(self.exec_path), stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)

self.check_and_kill_process([self.installed_path, "lib/Fritzing"], wait_before=self.TIMEOUT_START)
proc.wait(self.TIMEOUT_STOP)

# ensure that it's detected as installed:
self.child = spawn_process(self.command(self.command_args))
self.expect_and_no_warn(r"{} is already installed.*\[.*\] ".format(self.name))
self.child.sendline()
self.wait_and_close()
43 changes: 0 additions & 43 deletions tests/large/test_games.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,49 +26,6 @@
from ..tools import UMAKE, spawn_process


class StencylTests(LargeFrameworkTests):
"""This will test the Stencyl installation"""

TIMEOUT_INSTALL_PROGRESS = 120
TIMEOUT_START = 20
TIMEOUT_STOP = 20

def setUp(self):
super().setUp()
self.installed_path = os.path.join(self.install_base_path, "games", "stencyl")
self.desktop_filename = "stencyl.desktop"

def test_default_stencyl_install(self):
"""Install stencyl from scratch test case"""
self.child = spawn_process(self.command('{} games stencyl'.format(UMAKE)))
self.expect_and_no_warn(r"Choose installation path: {}".format(self.installed_path))
self.child.sendline("")
self.expect_and_no_warn(r"Installation done", timeout=self.TIMEOUT_INSTALL_PROGRESS)
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.assert_exec_exists()
self.assert_icon_exists()
self.assert_exec_link_exists()

# launch it, send SIGTERM and check that it exits fine
use_cwd = self.installed_path
if self.in_container:
use_cwd = None
proc = subprocess.Popen(self.command_as_list(self.exec_path), stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL, cwd=use_cwd)
self.check_and_kill_process([self.exec_path], wait_before=self.TIMEOUT_START)
proc.communicate()
proc.wait(self.TIMEOUT_STOP)

# ensure that it's detected as installed:
self.child = spawn_process(self.command('{} games stencyl'.format(UMAKE)))
self.expect_and_no_warn(r"Stencyl is already installed.*\[.*\] ")
self.child.sendline()
self.wait_and_close()


class BlenderTests(LargeFrameworkTests):
"""This will test the Blender installation"""

Expand Down
10 changes: 0 additions & 10 deletions tests/large/test_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ def test_eagle_install(self):
self.child = spawn_process(self.command(f'{UMAKE} electronics eagle --dry-run'))
self.expect_and_no_warn("Found download URL:.*")

def test_fritzing_install(self):
"""Install base installer from scratch test case"""
self.child = spawn_process(self.command(f'{UMAKE} electronics fritzing --dry-run'))
self.expect_and_no_warn("Found download URL:.*")

def test_blender_install(self):
"""Install base installer from scratch test case"""
self.child = spawn_process(self.command(f'{UMAKE} games blender --dry-run'))
Expand All @@ -103,11 +98,6 @@ def test_godot_install(self):
self.child = spawn_process(self.command(f'{UMAKE} games godot --dry-run'))
self.expect_and_no_warn("Found download URL:.*")

def test_stencyl_install(self):
"""Install base installer from scratch test case"""
self.child = spawn_process(self.command(f'{UMAKE} games stencyl --dry-run'))
self.expect_and_no_warn("Found download URL:.*")

def test_superpowers_install(self):
"""Install base installer from scratch test case"""
self.child = spawn_process(self.command(f'{UMAKE} games superpowers --dry-run'))
Expand Down
34 changes: 0 additions & 34 deletions tests/medium/test_electronics.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,37 +79,3 @@ def test_install_with_changed_download_page(self):
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.is_in_path(self.exec_link))


class FritzingInContainer(ContainerTests, test_electronics.FritzingTests):
"""This will test the Fritzing integration inside a container"""

TIMEOUT_START = 20
TIMEOUT_STOP = 10

def setUp(self):
self.hosts = {443: ["api.github.com", "github.com"]}
self.apt_repo_override_path = os.path.join(self.APT_FAKE_REPO_PATH, 'fritzing')
super().setUp()
# override with container path
self.installed_path = os.path.join(self.install_base_path, "electronics", "fritzing")

def test_install_with_changed_download_page(self):
"""Installing Fritzing should fail if download page has significantly changed"""
download_page_file_path = os.path.join(get_data_dir(), "server-content", "api.github.com",
"repos", "Fritzing", "Fritzing-app", "releases", "latest")
umake_command = self.command('{} electronics Fritzing'.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.is_in_path(self.exec_link))

def test_install_beta_with_changed_download_page(self):
"""Installing Fritzing Beta should fail if the latest is not a edge"""
download_page_file_path = os.path.join(get_data_dir(), "server-content", "api.github.com",
"repos", "Fritzing", "Fritzing-app", "releases", "index.html")
with swap_file_and_restore(download_page_file_path) as content:
with open(download_page_file_path, "w") as newfile:
newfile.write(content.replace("-edge", ""))
self.child = umake_command = self.command('{} ide fritzing --edge'.format(UMAKE))
self.assertFalse(self.launcher_exists_and_is_pinned(self.desktop_filename))
self.assertFalse(self.is_in_path(self.exec_link))
14 changes: 0 additions & 14 deletions tests/medium/test_games.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,6 @@
from ..tools import get_data_dir, UMAKE


class StencylInContainer(ContainerTests, test_games.StencylTests):
"""This will test the Stencyl editor inside a container"""

TIMEOUT_START = 20
TIMEOUT_STOP = 10

def setUp(self):
self.hosts = {80: ["www.stencyl.com"]}
self.apt_repo_override_path = os.path.join(self.APT_FAKE_REPO_PATH, 'stencyl')
super().setUp()
# override with container path
self.installed_path = os.path.join(self.install_base_path, "games", "stencyl")


class BlenderInContainer(ContainerTests, test_games.BlenderTests):
"""This will test the Blender editor inside a container"""

Expand Down
54 changes: 3 additions & 51 deletions umake/frameworks/electronics.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,54 +169,6 @@ def post_install(self):
class Fritzing(umake.frameworks.baseinstaller.BaseInstaller):

def __init__(self, **kwargs):
super().__init__(name="Fritzing",
description=_("Electronic Design Automation software with a low entry barrier"),
only_on_archs=['amd64'],
only_ubuntu=True,
packages_requirements=["libssl1.1 | libssl1.0", "libqt5serialport5",
"libqt5sql5", "libqt5xml5"],
download_page="https://api.github.com/repos/Fritzing/Fritzing-app/releases/latest",
desktop_filename="fritzing.desktop",
required_files_path=["Fritzing"],
dir_to_decompress_in_tarball="fritzing-*",
json=True, **kwargs)

@property
def ubuntu_version(self):
if get_current_distro_version().split('.')[0] < "18":
return('xenial')
else:
return('bionic')

def parse_download_link(self, line, in_download):
url = None
for asset in line["assets"]:
if "{}.linux.AMD64.tar.bz2".format(self.ubuntu_version) in asset["browser_download_url"] and \
".md5" not in asset["browser_download_url"]:
in_download = True
url = asset["browser_download_url"]
return (url, in_download)

def post_install(self):
"""Create the Fritzing launcher"""
create_launcher(self.desktop_filename, get_application_desktop_file(name=_("Fritzing"),
icon_path=os.path.join(self.install_path, "icons", "fritzing_icon.png"),
try_exec=self.exec_path,
exec=self.exec_link_name,
comment=self.description,
categories="Development;"))

def install_framework_parser(self, parser):
this_framework_parser = super().install_framework_parser(parser)
this_framework_parser.add_argument('--edge', action="store_true",
help=_("Install Continuous Build version"))
return this_framework_parser

def run_for(self, args):
if args.edge:
self.name += " Edge"
self.description += " edge"
self.desktop_filename = self.desktop_filename.replace(".desktop", "-edge.desktop")
self.download_page = "https://api.github.com/repos/Fritzing/Fritzing-app/releases"
self.install_path += "-edge"
super().run_for(args)
super().__init__(name="Fritzing", description="For removal only (tarfile not supported upstream anymore)",
download_page=None, only_on_archs=['amd64'], only_for_removal=True, **kwargs)

28 changes: 2 additions & 26 deletions umake/frameworks/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,32 +44,8 @@ def __init__(self):
class Stencyl(umake.frameworks.baseinstaller.BaseInstaller):

def __init__(self, **kwargs):
super().__init__(name="Stencyl", description=_("Stencyl game developer IDE"),
only_on_archs=['amd64'],
download_page="http://www.stencyl.com/download/",
desktop_filename="stencyl.desktop",
required_files_path=["Stencyl"],
packages_requirements=["openjdk-8-jre | openjdk-11-jre"],
**kwargs)

PERM_DOWNLOAD_LINKS = {
"amd64": "http://www.stencyl.com/download/get/lin64",
}

def parse_download_link(self, line, in_download):
"""We have persistent links for Stencyl, return it right away"""
url = self.PERM_DOWNLOAD_LINKS["amd64"]
return ((url, None), in_download)

def post_install(self):
"""Create the Stencyl launcher"""
create_launcher(self.desktop_filename, get_application_desktop_file(name=_("Stencyl"),
icon_path=os.path.join(self.install_path, "data", "other", "icon-30x30.png"),
try_exec=self.exec_path,
exec=self.exec_link_name,
comment=self.description,
categories="Development;IDE;",
extra="Path={}\nStartupWMClass=stencyl-sw-Launcher".format(self.install_path)))
super().__init__(name="Stencyl", description=_("For removal only (SSL errors on download page)"),
download_page=None, only_on_archs=['amd64'], only_for_removal=True, **kwargs)


class Blender(umake.frameworks.baseinstaller.BaseInstaller):
Expand Down
9 changes: 3 additions & 6 deletions umake/frameworks/ide.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ def __init__(self, **kwargs):
super().__init__(name="RStudio", description=_("RStudio code editor"),
only_on_archs=['amd64'],
download_page="https://www.rstudio.com/products/rstudio/download/",
packages_requirements=["libjpeg62", "libedit2", "libssl1.0.0 | libssl1.0.3 | libssl1.1", "libclang-dev", "libpq5", "r-base"],
# packages_requirements=["libjpeg62", "libedit2", "libssl1.0.0 | libssl1.0.3 | libssl1.1", "libclang-dev", "libpq5", "r-base"],
desktop_filename="rstudio.desktop",
required_files_path=["bin/rstudio"],
dir_to_decompress_in_tarball="rstudio-*",
Expand All @@ -855,10 +855,7 @@ def parse_download_link(self, line, in_download):
"""Parse RStudio download links"""
url = None
checksum = None
if int(get_current_distro_version().split('.')[0]) < 18 or \
int(get_current_distro_version(distro_name="debian").split('.')[0]) < 9:
ubuntu_version = 'xenial'
elif int(get_current_distro_version(distro_name="debian").split('.')[0]) == 9:
if int(get_current_distro_version(distro_name="debian").split('.')[0]) == 9:
ubuntu_version = "debian9"
else:
ubuntu_version = 'bionic'
Expand All @@ -867,7 +864,7 @@ def parse_download_link(self, line, in_download):
with suppress(AttributeError):
url = p.group(1)
in_download = True
if in_download and 'title="SHA-256"' in line:
if in_download and 'data-ls-toggle="popover"' in line:
p = re.search('data-content="(.*)">', line)
with suppress(AttributeError):
checksum = p.group(1)
Expand Down
Loading

0 comments on commit 4c7ee2a

Please sign in to comment.