2017-02-05 22:31:37 +01:00
|
|
|
# Abhängigkeiten
|
|
|
|
from platform import python_version_tuple as pvt
|
2017-02-05 14:31:11 +01:00
|
|
|
import tarfile, io, shutil, os
|
2017-02-05 22:31:37 +01:00
|
|
|
try:
|
|
|
|
# Python 3
|
|
|
|
import urllib.request as ulr
|
|
|
|
except:
|
|
|
|
# Python 2
|
|
|
|
import urllib2 as ulr
|
2017-02-05 14:31:11 +01:00
|
|
|
|
2017-02-05 22:31:37 +01:00
|
|
|
# Plattform
|
2017-02-05 14:31:11 +01:00
|
|
|
try:
|
2017-02-05 22:31:37 +01:00
|
|
|
# Android
|
2017-02-05 14:31:11 +01:00
|
|
|
import androidhelper
|
|
|
|
platform = "Android"
|
|
|
|
except:
|
|
|
|
try:
|
2017-02-05 22:31:37 +01:00
|
|
|
# iOS
|
2017-02-05 14:31:11 +01:00
|
|
|
import objc_util
|
|
|
|
platform = "iOS"
|
|
|
|
except:
|
2017-02-05 22:31:37 +01:00
|
|
|
# Andere, bisher nicht implementiert
|
2017-02-05 22:53:25 +01:00
|
|
|
print("Velamentum konnte nicht installiert werden.")
|
2017-02-05 14:31:11 +01:00
|
|
|
quit()
|
|
|
|
|
2017-02-05 22:31:37 +01:00
|
|
|
# Pfade festlegen
|
2017-02-05 14:31:11 +01:00
|
|
|
if platform == "Android":
|
2017-02-05 22:31:37 +01:00
|
|
|
tmpPVSP = "3" if 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"
|
2017-02-05 14:31:11 +01:00
|
|
|
elif platform == "iOS":
|
|
|
|
archPath = os.path.expanduser("~/Documents/tmp")
|
|
|
|
biblPath = os.path.expanduser("~/Documents/site-packages")
|
|
|
|
exmpPath = os.path.expanduser("~/Documents/Examples")
|
|
|
|
|
2017-02-05 22:31:37 +01:00
|
|
|
# Alte Installation löschen
|
2017-02-05 14:31:11 +01:00
|
|
|
shutil.rmtree(exmpPath + "/velamentum", True)
|
|
|
|
shutil.rmtree(biblPath + "/velamentum", True)
|
|
|
|
|
2017-02-05 22:31:37 +01:00
|
|
|
# Verzeichnisse anlegen
|
2017-02-05 14:31:11 +01:00
|
|
|
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)
|
|
|
|
|
2017-02-05 22:31:37 +01:00
|
|
|
# Tarball des GIT-Repos laden
|
2017-02-05 14:31:11 +01:00
|
|
|
arch = tarfile.open(fileobj=io.BytesIO(ulr.urlopen("https://dev.spittank.org/mobile/velamentum/repository/archive.tar.gz?ref=master").read()))
|
|
|
|
|
2017-02-05 22:31:37 +01:00
|
|
|
# Extrahieren
|
2017-02-05 14:31:11 +01:00
|
|
|
cmid = arch.getnames()[0]
|
|
|
|
arch.extractall(path=archPath)
|
|
|
|
|
2017-02-05 22:31:37 +01:00
|
|
|
# Installieren
|
2017-02-05 14:31:11 +01:00
|
|
|
vsrcPath = archPath + "/" + cmid + "/source/"
|
|
|
|
shutil.move(vsrcPath + platform, biblPath + '/velamentum')
|
|
|
|
shutil.move(vsrcPath + "Examples", exmpPath + '/velamentum')
|
|
|
|
|
2017-02-05 22:31:37 +01:00
|
|
|
# Nicht benötigte Dateien löschen
|
2017-02-05 14:31:11 +01:00
|
|
|
shutil.rmtree(archPath, True)
|
|
|
|
|
|
|
|
print("Die aktuelle Version von Velamentum wurde installiert. Bitte die App neu starten.")
|