1
0
Fork 0

move appimage url resolution to util.py

This commit is contained in:
Kim, Jimin 2022-11-12 01:21:08 +09:00
parent 62715b990f
commit 0f55300461
2 changed files with 43 additions and 40 deletions

View file

@ -1,51 +1,19 @@
from src.util import flatpak_install, paru_install, appimage_install, copy_file
from src.util import (
paru_install,
appimage_install,
copy_file,
get_latest_appimage_url_from_github,
)
from src.setup.system import system76_scheduler
from os.path import exists
from os import system
import requests
import re
name = "osu!lazer"
post_install = ["Install osu! skin from https://github.com/developomp/osu-pomp-skin"]
def get_latest_osu_lazer_appimage_url() -> str:
return (
re.search(
"(?P<url>https?://[^\s]+)",
[
t
for t in requests.get(
"https://api.github.com/repos/ppy/osu/releases/latest"
).text.split(",")
if "browser_download" in t and 'AppImage"' in t
][0],
)
.group("url")
.split(".AppImage")[0]
+ ".AppImage"
)
def setup():
"""
A circle-clicking rhythm game.
"""
# install the game
appimage_install(
get_latest_osu_lazer_appimage_url(),
"osu",
)
# give CPU scheduler priority
system76_scheduler.setup()
#
# set up tablet driver
#
def setup_open_tablet_driver():
paru_install("opentabletdriver-git")
# apply settings
@ -73,3 +41,19 @@ def setup():
# Enable and start the user service
system("systemctl --user enable opentabletdriver --now")
def setup():
"""
A circle-clicking rhythm game.
"""
# install the game
appimage_install(
get_latest_appimage_url_from_github("ppy/osu"),
"osu",
)
# give CPU scheduler priority
system76_scheduler.setup()
setup_open_tablet_driver()

View file

@ -6,6 +6,7 @@ from pathlib import Path
import requests
import zipfile
import shutil
import re
from src.log import error, log
import src.constants
@ -78,6 +79,24 @@ def appimage_install(file_url: str, file_name: str) -> None:
shutil.copyfileobj(raw, output)
def get_latest_appimage_url_from_github(repo: str) -> str:
return (
re.search(
"(?P<url>https?://[^\s]+)",
[
t
for t in requests.get(
f"https://api.github.com/repos/{repo}/releases/latest"
).text.split(",")
if "browser_download" in t and 'AppImage"' in t
][0],
)
.group("url")
.split(".AppImage")[0]
+ ".AppImage"
)
def smart_mkdir(path: str) -> None:
"""
Recursively create directories if it doesn't exist already.