turdbot/py/init.py

32 lines
1020 B
Python
Raw Normal View History

2022-10-29 13:13:55 -06:00
#imports
2022-10-29 11:39:40 -06:00
import version
2022-10-29 12:32:37 -06:00
import sys
import os
2022-11-03 19:20:55 -06:00
import configparser
import wget
import sysrsync
import shutil
2022-10-29 13:13:55 -06:00
#funky stuff to deal with relative file paths
dir = os.getcwd()
os.chdir(os.path.dirname(os.path.realpath(__file__)))
2022-11-03 19:20:55 -06:00
config = configparser.ConfigParser()
config.read("config.conf")
if config["config"]["autoupdate"] == "true":
versionl = version.local()
versionr = version.remote()
2022-10-29 13:13:55 -06:00
#updater
2022-11-03 19:20:55 -06:00
if versionl < versionr:
print("outdated version detected\n",versionl," < ",versionr)
if config["config"]["autoupdate"] == "true":
print("autoupdate is enabled, attempting to update")
wget.download("https://github.com/ionburger/turdbot/archive/refs/tags/"+versionr+".zip",out = "turdbot.zip")
shutil.unpack_archive("turdbot.zip","turdbot")
sysrsync.run(source="turdbot/turdbot-"+versionr+"/py/*.py",destination="*.py")
os.chdir(dir)
os.execl(sys.executable, sys.executable, *sys.argv)
2022-10-29 11:39:40 -06:00
else:
2022-11-03 19:20:55 -06:00
print("running latest version of turdbot ",versionl)