eeee
This commit is contained in:
parent
d7120b5bea
commit
28b6bb5068
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
|
*workspace*
|
||||||
*.conf
|
*.conf
|
||||||
*.shlf
|
*.shlf
|
||||||
*test*
|
*test*
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
1.2.2
|
1.2.4
|
||||||
21
py/init.py
21
py/init.py
@ -4,11 +4,10 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import configparser
|
import configparser
|
||||||
import wget
|
import wget
|
||||||
import sysrsync
|
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
#funky stuff to deal with relative file paths
|
#funky stuff to deal with relative file paths
|
||||||
dir = os.getcwd()
|
randir = os.getcwd()
|
||||||
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
@ -16,16 +15,22 @@ config.read("config.conf")
|
|||||||
if config["config"]["autoupdate"] == "true":
|
if config["config"]["autoupdate"] == "true":
|
||||||
versionl = version.local()
|
versionl = version.local()
|
||||||
versionr = version.remote()
|
versionr = version.remote()
|
||||||
|
print(versionr.join("."))
|
||||||
|
|
||||||
#updater
|
#updater
|
||||||
if versionl < versionr:
|
if ".".join(versionl)<".".join(versionr):
|
||||||
print("outdated version detected\n",versionl," < ",versionr)
|
print("outdated version",versionl,"<",versionr)
|
||||||
if config["config"]["autoupdate"] == "true":
|
if config["config"]["autoupdate"] == "true":
|
||||||
print("autoupdate is enabled, attempting to update")
|
print("autoupdate is enabled, attempting to update")
|
||||||
wget.download("https://github.com/ionburger/turdbot/archive/refs/tags/"+versionr+".zip",out = "turdbot.zip")
|
wget.download("https://github.com/ionburger/turdbot/archive/refs/tags/"+versionr+".zip",out = "turdbottmp.zip")
|
||||||
shutil.unpack_archive("turdbot.zip","turdbot")
|
shutil.unpack_archive("turdbottmp.zip","turdbottmp")
|
||||||
sysrsync.run(source="turdbot/turdbot-"+versionr+"/py/*.py",destination="*.py")
|
for file in os.listdir("turdbottmp/turdbot-"+versionr+"/py/"):
|
||||||
os.chdir(dir)
|
if file.endswith(".py"):
|
||||||
|
shutil.move("turdbottmp/turdbot-"+versionr+"/py/"+file,file)
|
||||||
|
with open("VERSION","w") as file:
|
||||||
|
file.write(versionr)
|
||||||
|
|
||||||
|
os.chdir(randir)
|
||||||
os.execl(sys.executable, sys.executable, *sys.argv)
|
os.execl(sys.executable, sys.executable, *sys.argv)
|
||||||
else:
|
else:
|
||||||
print("running latest version of turdbot",versionl)
|
print("running latest version of turdbot",versionl)
|
||||||
|
|||||||
BIN
py/turdbottmp.zip
Normal file
BIN
py/turdbottmp.zip
Normal file
Binary file not shown.
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 404 KiB After Width: | Height: | Size: 404 KiB |
@ -3,8 +3,8 @@ import subprocess
|
|||||||
def remote():
|
def remote():
|
||||||
try:
|
try:
|
||||||
process = subprocess.Popen(["lastversion", "ionburger/turdbot"],stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
process = subprocess.Popen(["lastversion", "ionburger/turdbot"],stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||||
return (process.communicate()[0])
|
return (process.communicate()[0]).strip("\n")
|
||||||
except:
|
except:
|
||||||
return 0
|
return 0
|
||||||
def local():
|
def local():
|
||||||
return open("VERSION","r").read()
|
return open("VERSION","r").read().strip("\n")
|
||||||
Loading…
Reference in New Issue
Block a user