mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
Merge pull request #49 from SemjonKerner/delete_provcha_addon_dir
Improve Addon handling
This commit is contained in:
commit
9c6da6e692
@ -59,11 +59,11 @@ def initialize(window_to_hide):
|
||||
helper.install_thread_excepthook()
|
||||
sys.excepthook = helper.unhandled_exception_logging
|
||||
|
||||
if not config.get("addoninstalled", False):
|
||||
if not config.get("addoninstalled", 0) or helper.get_addonversion(chalutier[0]) < chalutier[2]:
|
||||
helper.install_addon(*chalutier)
|
||||
helper.install_addon(*lam2)
|
||||
helper.remove_addon("ProvisionsChalutier")
|
||||
config.set("addoninstalled", True)
|
||||
helper.remove_addon("ProvisionsChalutier") #TODO delete with fishy 0.4.6
|
||||
config.set("addoninstalled", helper.get_addonversion(chalutier[0]))
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -1,3 +1,3 @@
|
||||
apiversion = 1
|
||||
chalutier = ("Chalutier", "https://www.esoui.com/downloads/dl2934/1616505502-Chalutier_1.1.1.zip")
|
||||
lam2 = ("LibAddonMenu-2.0", "https://www.esoui.com/downloads/dl7/LibAddonMenu-2.0r32.zip")
|
||||
chalutier = ("Chalutier", "https://www.esoui.com/downloads/dl2934/1616505502-Chalutier_1.1.1.zip", 111)
|
||||
lam2 = ("LibAddonMenu-2.0", "https://www.esoui.com/downloads/dl7/LibAddonMenu-2.0r32.zip", 32)
|
||||
|
@ -61,11 +61,12 @@ def _create(gui: 'GUI'):
|
||||
|
||||
def installer():
|
||||
if filemenu.entrycget(4, 'label') == "Remove Chalutier":
|
||||
helper.remove_addon(chalutier[0])
|
||||
if helper.remove_addon(chalutier[0]) == 0:
|
||||
filemenu.entryconfigure(4, label="Install Chalutier")
|
||||
else:
|
||||
helper.install_addon(*chalutier)
|
||||
helper.install_addon(*lam2)
|
||||
r = helper.install_addon(*chalutier)
|
||||
r += helper.install_addon(*lam2)
|
||||
if r == 0:
|
||||
filemenu.entryconfigure(4, label="Remove Chalutier")
|
||||
chaEntry = "Remove Chalutier" if helper.addon_exists(chalutier[0]) else "Install Chalutier"
|
||||
filemenu.add_command(label=chaEntry, command=installer)
|
||||
|
@ -1,4 +1,4 @@
|
||||
from .auto_update import auto_upgrade, upgrade_avail, versions
|
||||
from .config import Config
|
||||
from .helper import open_web, initialize_uid, install_thread_excepthook, unhandled_exception_logging, manifest_file, \
|
||||
create_shortcut_first, addon_exists, install_addon, remove_addon, restart, create_shortcut, not_implemented, update
|
||||
create_shortcut_first, addon_exists, get_addonversion, install_addon, remove_addon, restart, create_shortcut, not_implemented, update
|
||||
|
@ -152,27 +152,46 @@ def get_addondir():
|
||||
return os.path.join(documents, "Elder Scrolls Online", "live", "Addons")
|
||||
|
||||
|
||||
def addon_exists(name):
|
||||
def addon_exists(name, url=None, v=None):
|
||||
return os.path.exists(os.path.join(get_addondir(), name))
|
||||
|
||||
|
||||
def get_addonversion(name, url=None, v=None):
|
||||
if addon_exists(name):
|
||||
txt = name + ".txt"
|
||||
try:
|
||||
with open(os.path.join(get_addondir(), name, txt)) as f:
|
||||
for line in f:
|
||||
if "AddOnVersion" in line:
|
||||
return int(line.split(' ')[2])
|
||||
except Exception:
|
||||
pass
|
||||
return 0
|
||||
|
||||
|
||||
# noinspection PyBroadException
|
||||
def install_addon(name, url):
|
||||
def install_addon(name, url, v=None):
|
||||
try:
|
||||
r = requests.get(url, stream=True)
|
||||
z = ZipFile(BytesIO(r.content))
|
||||
z.extractall(path=get_addondir())
|
||||
logging.info("Add-On "+name+" installed successfully!\nPlease make sure to enable \"Allow outdated addons\" in ESO")
|
||||
return 0
|
||||
except Exception as ex:
|
||||
logging.error("Could not install Add-On "+name+", try doing it manually")
|
||||
return 1
|
||||
|
||||
|
||||
def remove_addon(name):
|
||||
def remove_addon(name, url=None, v=None):
|
||||
try:
|
||||
shutil.rmtree(os.path.join(get_addondir(), name))
|
||||
logging.info("Add-On "+name+" removed!")
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
except PermissionError as ex:
|
||||
logging.error("Fishy has no permission to remove "+name+" Add-On")
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
def get_documents():
|
||||
|
Loading…
Reference in New Issue
Block a user