diff --git a/.gitignore b/.gitignore index 38da6d9..6f65c29 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ __pycache__/ .vscode/ +*.egg-info/ +build/ diff --git a/README.mdown b/README.mdown index 6732ac7..e7a7a94 100644 --- a/README.mdown +++ b/README.mdown @@ -12,6 +12,12 @@ On Windows, press `Windows Key + e` to open a file explorer and enter the follow %HOME%\Documents\Elder Scrolls Online\ ``` +or on Windows 11 + +``` +Documents\Elder Scrolls Online\ +``` + Make a copy of the `live` folder and rename it to something meaningful like `old` or `backup`. # Dependencies @@ -22,11 +28,61 @@ python3-pip # Linux Installation +Install `python3` and `pip3`, the following instructions are for Debian. + +``` +sudo apt install python3-pip +pip3 install . +``` + +Once the project is installed to python's packages you may invoke the addon script with the following command: + +``` +eso-banana-script +``` + +## Linux Scheduled + +TODO linux chron job instructions. + # Windows Installation -# Usage +Install the latest Python 3 using the installer provided by [python.org](https://www.python.org/downloads/windows/). -# Linux Development +Open [Windows Terminal](https://www.microsoft.com/en-US/p/windows-terminal/9n0dx20hk701) or any windows command prompt and navigate to this project. +Use the Python package manager PIP to install `eso-banana`. + +```powershell +cd .\eso-banana\ +pip install . +``` + +Once the project is installed to python's packages you may invoke the addon script with the following command: + +```powershell +eso-banana-script.exe +``` + +## Windows Scheduled + +To schedule a periodic background run of `eso-banana`, open Powershell as a user and enter the following commands. + +```powershell +$Action = New-ScheduledTaskAction -Execute "eso-banana-script.exe" -Argument "--verbose" +$Trigger = New-ScheduledTaskTrigger -Daily -At 11am +$Settings = New-ScheduledTaskSettingsSet -RunOnlyIfNetworkAvailable -StartWhenAvailable -RunOnlyIfIdle +Register-ScheduledTask -TaskName "eso-banana" -Action $Action -Trigger $Trigger -Settings $Settings -Description "Elder Scrolls Online addon manager and a Tamriel Trade Centre price table updater." +``` + +To check to make sure the task is registered correctly, enter `Get-ScheduledTask` and check that the first entry looks similar: + +``` +TaskPath TaskName State +-------- -------- ----- +\ eso-banana Ready +``` + +# Development Use docker to test the python components. For docker installation run the following commands on [Ubuntu 20.04](https://ubuntu.com/download/): diff --git a/banana/scripts.py b/banana/scripts.py index d6206f5..c92997e 100644 --- a/banana/scripts.py +++ b/banana/scripts.py @@ -1,5 +1,6 @@ from argparse import ArgumentParser from pathlib import Path +from platform import system import logging from . import compare @@ -13,18 +14,26 @@ def periodical_script(): description="Visit https://www.esoui.com/ to search for addons and their dependencies URLs. Edit addons.yaml in the ESO live path and add the URL for each addon for installation. " ) parser.add_argument("-v", "--verbose", action="count", help="verbose logging") - parser.add_argument( - "-p", - "--eso_live_path", - default=Path.home().joinpath("ESO/live/"), - help='default: "~/.steam/steam/steamapps/compatdata/306130/pfx/drive_c/users/steamuser/Documents/Elder Scrolls Online/live/"', - ) + parser.add_argument("-p", "--eso_live_path") args = parser.parse_args() + if args.eso_live_path: + args.eso_live_path = Path(args.eso_live_path) + else: + if system() == "Windows": + args.eso_live_path = Path.home().joinpath( + "Documents\Elder Scrolls Online\live" + ) + else: + args.eso_live_path = Path.home().joinpath( + ".steam/steam/steamapps/compatdata/306130/pfx/drive_c/users/steamuser/Documents/Elder Scrolls Online/live/" + ) + if args.verbose: logging.basicConfig( level=logging.DEBUG, format="%(asctime)s %(filename)s:%(lineno)d %(message)s", + filename=args.eso_live_path.joinpath("banana.log"), ) else: logging.basicConfig( @@ -34,10 +43,6 @@ def periodical_script(): logging.info(args) - if isinstance(args.eso_live_path, str): - if args.eso_live_path[:2] == "~/": - args.eso_live_path = Path.home().joinpath(args.eso_live_path[2:]) - config_path = Path(args.eso_live_path).joinpath("addons.yaml") config_path.touch(exist_ok=True) config_current = config.load(config_path) @@ -49,7 +54,7 @@ def periodical_script(): config_current = config.load(config_path) logging.info(f'addons list created at "{config_path}"') - live_path = Path(args.eso_live_path).joinpath("AddOns") + live_path = args.eso_live_path.joinpath("AddOns") if not live_path.is_dir(): logging.error(f"eso_live_path_invalid_dir {live_path}") @@ -70,24 +75,28 @@ def periodical_script(): def ttc(): - parser = ArgumentParser( - description="Visit https://www.esoui.com/ to search for addons and their dependencies URLs. Edit addons.yaml in the ESO live path and add the URL for each addon for installation. " - ) + parser = ArgumentParser(description="Tamriel Trade Centre price table updater.") parser.add_argument("-v", "--verbose", action="count", help="verbose logging") - parser.add_argument( - "-p", - "--eso_live_path", - default=Path.home().joinpath( - ".steam/steam/steamapps/compatdata/306130/pfx/drive_c/users/steamuser/Documents/Elder Scrolls Online/live/" - ), - help='default: "~/.steam/steam/steamapps/compatdata/306130/pfx/drive_c/users/steamuser/Documents/Elder Scrolls Online/live/"', - ) + parser.add_argument("-p", "--eso_live_path") args = parser.parse_args() + if args.eso_live_path: + args.eso_live_path = Path(args.eso_live_path) + else: + if system() == "Windows": + args.eso_live_path = Path.home().joinpath( + "Documents\Elder Scrolls Online\live" + ) + else: + args.eso_live_path = Path.home().joinpath( + ".steam/steam/steamapps/compatdata/306130/pfx/drive_c/users/steamuser/Documents/Elder Scrolls Online/live/" + ) + if args.verbose: logging.basicConfig( level=logging.DEBUG, format="%(asctime)s %(filename)s:%(lineno)d %(message)s", + filename=args.eso_live_path.joinpath("banana.log"), ) else: logging.basicConfig( @@ -97,10 +106,6 @@ def ttc(): logging.info(args) - if isinstance(args.eso_live_path, str): - if args.eso_live_path[:2] == "~/": - args.eso_live_path = Path.home().joinpath(args.eso_live_path[2:]) - live_path = Path(args.eso_live_path).joinpath("AddOns") if not live_path.is_dir():