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()
|
helper.install_thread_excepthook()
|
||||||
sys.excepthook = helper.unhandled_exception_logging
|
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(*chalutier)
|
||||||
helper.install_addon(*lam2)
|
helper.install_addon(*lam2)
|
||||||
helper.remove_addon("ProvisionsChalutier")
|
helper.remove_addon("ProvisionsChalutier") #TODO delete with fishy 0.4.6
|
||||||
config.set("addoninstalled", True)
|
config.set("addoninstalled", helper.get_addonversion(chalutier[0]))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
apiversion = 1
|
apiversion = 1
|
||||||
chalutier = ("Chalutier", "https://www.esoui.com/downloads/dl2934/1616505502-Chalutier_1.1.1.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")
|
lam2 = ("LibAddonMenu-2.0", "https://www.esoui.com/downloads/dl7/LibAddonMenu-2.0r32.zip", 32)
|
||||||
|
@ -61,12 +61,13 @@ def _create(gui: 'GUI'):
|
|||||||
|
|
||||||
def installer():
|
def installer():
|
||||||
if filemenu.entrycget(4, 'label') == "Remove Chalutier":
|
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")
|
filemenu.entryconfigure(4, label="Install Chalutier")
|
||||||
else:
|
else:
|
||||||
helper.install_addon(*chalutier)
|
r = helper.install_addon(*chalutier)
|
||||||
helper.install_addon(*lam2)
|
r += helper.install_addon(*lam2)
|
||||||
filemenu.entryconfigure(4, label="Remove Chalutier")
|
if r == 0:
|
||||||
|
filemenu.entryconfigure(4, label="Remove Chalutier")
|
||||||
chaEntry = "Remove Chalutier" if helper.addon_exists(chalutier[0]) else "Install Chalutier"
|
chaEntry = "Remove Chalutier" if helper.addon_exists(chalutier[0]) else "Install Chalutier"
|
||||||
filemenu.add_command(label=chaEntry, command=installer)
|
filemenu.add_command(label=chaEntry, command=installer)
|
||||||
menubar.add_cascade(label="Options", menu=filemenu)
|
menubar.add_cascade(label="Options", menu=filemenu)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from .auto_update import auto_upgrade, upgrade_avail, versions
|
from .auto_update import auto_upgrade, upgrade_avail, versions
|
||||||
from .config import Config
|
from .config import Config
|
||||||
from .helper import open_web, initialize_uid, install_thread_excepthook, unhandled_exception_logging, manifest_file, \
|
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")
|
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))
|
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
|
# noinspection PyBroadException
|
||||||
def install_addon(name, url):
|
def install_addon(name, url, v=None):
|
||||||
try:
|
try:
|
||||||
r = requests.get(url, stream=True)
|
r = requests.get(url, stream=True)
|
||||||
z = ZipFile(BytesIO(r.content))
|
z = ZipFile(BytesIO(r.content))
|
||||||
z.extractall(path=get_addondir())
|
z.extractall(path=get_addondir())
|
||||||
logging.info("Add-On "+name+" installed successfully!\nPlease make sure to enable \"Allow outdated addons\" in ESO")
|
logging.info("Add-On "+name+" installed successfully!\nPlease make sure to enable \"Allow outdated addons\" in ESO")
|
||||||
|
return 0
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logging.error("Could not install Add-On "+name+", try doing it manually")
|
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:
|
try:
|
||||||
shutil.rmtree(os.path.join(get_addondir(), name))
|
shutil.rmtree(os.path.join(get_addondir(), name))
|
||||||
logging.info("Add-On "+name+" removed!")
|
logging.info("Add-On "+name+" removed!")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
|
except PermissionError as ex:
|
||||||
|
logging.error("Fishy has no permission to remove "+name+" Add-On")
|
||||||
|
return 1
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def get_documents():
|
def get_documents():
|
||||||
|
Loading…
Reference in New Issue
Block a user