install new addons func

master
JoYo 2021-12-22 18:11:29 -05:00
parent 21bbc6c6b2
commit 435230aa6e
3 changed files with 25 additions and 21 deletions

View File

@ -48,3 +48,26 @@ def live_to_esoui(*, path: Path, esoui_uris: list):
logging.info(
f"{live_name} updated from {live_version} to {esoui_version} at {live_path}"
)
def esoui_to_live(*, esoui_uris: list, live_path: Path):
for addon_name, version, esoui_dowload_uri in esoui_uris:
if addon_name in list(live_path.iterdir()):
logging.info(f"{addon_name} already installed.")
continue
response = requests.get(esoui_dowload_uri)
response.raise_for_status()
temp_dir = TemporaryDirectory()
temp_path = Path(temp_dir.name)
zip_file = ZipFile(BytesIO(response.content))
zip_file.extractall(temp_path)
live_dest = live_path.joinpath(each.name)
for each in temp_path.iterdir():
copytree(each, live_dest)
logging.info(f"{addon_name} installed {version} at {live_dest}")

View File

@ -65,3 +65,5 @@ def periodical_script():
for child in live_path.iterdir():
compare.live_to_esoui(path=child, esoui_uris=esoui_uris)
compare.esoui_to_live(esoui_uris=esoui_uris, live_path=live_path)

View File

@ -1,21 +0,0 @@
[build-system]
requires = ["poetry"]
build-backend = "poetry.masonry.api"
[tool.poetry]
authors = ["py <py@py>"]
description = ""
license = "MIT"
name = "eso-banana"
version = "0.0.1"
[[tool.poetry.packages]]
include = "banana"
[tool.poetry.scripts]
eso-banana-script = "banana:scripts.periodical_script"
[tool.poetry.dependencies]
packaging = ""
PyYAML = ""
requests = ""