61 lines
1.8 KiB
Python
61 lines
1.8 KiB
Python
# Abhängigkeiten
|
|
from platform import python_version_tuple as pvt
|
|
import tarfile, io, shutil, os
|
|
try:
|
|
# Python 3
|
|
import urllib.request as ulr
|
|
except:
|
|
# Python 2
|
|
import urllib2 as ulr
|
|
|
|
# Plattform
|
|
try:
|
|
# Android
|
|
import androidhelper
|
|
plfn = "Android"
|
|
except:
|
|
try:
|
|
# iOS
|
|
import objc_util
|
|
plfn = "iOS"
|
|
except:
|
|
# Andere, bisher nicht implementiert
|
|
print("Velamentum konnte nicht installiert werden.")
|
|
quit()
|
|
|
|
# Pfade festlegen
|
|
if plfn == "Android":
|
|
tmpPVSP = "3" if int(pvt()[0]) > 2 else ""
|
|
archPath = "/sdcard/qpython/scripts" + tmpPVSP + "/tmp"
|
|
biblPath = "/sdcard/qpython/lib/python" + pvt()[0] + "." + pvt()[1] + "/site-packages"
|
|
exmpPath = "/sdcard/qpython/scripts" + tmpPVSP + "/Beispiele"
|
|
elif plfn == "iOS":
|
|
archPath = os.path.expanduser("~/Documents/tmp")
|
|
biblPath = os.path.expanduser("~/Documents/site-packages")
|
|
exmpPath = os.path.expanduser("~/Documents/Examples")
|
|
|
|
# Alte Installation löschen
|
|
shutil.rmtree(exmpPath + "/velamentum", True)
|
|
shutil.rmtree(biblPath + "/velamentum", True)
|
|
|
|
# Verzeichnisse anlegen
|
|
if not os.path.exists(archPath): os.makedirs(archPath)
|
|
if not os.path.exists(biblPath): os.makedirs(biblPath)
|
|
if not os.path.exists(exmpPath): os.makedirs(exmpPath)
|
|
|
|
# Tarball des GIT-Repos laden
|
|
arch = tarfile.open(fileobj=io.BytesIO(ulr.urlopen("https://dev.spittank.org/mobile/velamentum/repository/archive.tar.gz?ref=master").read()))
|
|
|
|
# Extrahieren
|
|
cmid = arch.getnames()[0]
|
|
arch.extractall(path=archPath)
|
|
|
|
# Installieren
|
|
vsrcPath = archPath + "/" + cmid + "/source/"
|
|
shutil.move(vsrcPath + plfn, biblPath + '/velamentum')
|
|
shutil.move(vsrcPath + "Examples", exmpPath + '/velamentum')
|
|
|
|
# Nicht benötigte Dateien löschen
|
|
shutil.rmtree(archPath, True)
|
|
|
|
print("Die aktuelle Version von Velamentum wurde installiert. Bitte die App neu starten.")
|