Setup vervollständigt

Setup kommentiert und so angepasst, dass es unter QPython mit Python 2 läuft.
This commit is contained in:
Daniel Spittank 2017-02-05 22:31:37 +01:00
parent 17076d00eb
commit b7cd140af8

View file

@ -1,45 +1,60 @@
# Abhängigkeiten
from platform import python_version_tuple as pvt
import tarfile, io, shutil, os import tarfile, io, shutil, os
try: import urllib.request as ulr
except: import urllib2 as ulr
try: try:
# Python 3
import urllib.request as ulr
except:
# Python 2
import urllib2 as ulr
# Plattform
try:
# Android
import androidhelper import androidhelper
platform = "Android" platform = "Android"
except: except:
try: try:
# iOS
import objc_util import objc_util
platform = "iOS" platform = "iOS"
except: except:
platform = "other" # Andere, bisher nicht implementiert
quit() quit()
# Pfade festlegen
if platform == "Android": if platform == "Android":
archPath = "/sdcard/qpython/scripts3/tmp" tmpPVSP = "3" if pvt()[0] > 2 else ""
biblPath = "/sdcard/qpython/lib/python3.2/site-packages" archPath = "/sdcard/qpython/scripts" + tmpPVSP + "/tmp"
exmpPath = "/sdcard/qpython/scripts3/Beispiele" biblPath = "/sdcard/qpython/lib/python" + pvt()[0] + "." + pvt()[1] + "/site-packages"
exmpPath = "/sdcard/qpython/scripts" + tmpPVSP + "/Beispiele"
elif platform == "iOS": elif platform == "iOS":
archPath = os.path.expanduser("~/Documents/tmp") archPath = os.path.expanduser("~/Documents/tmp")
biblPath = os.path.expanduser("~/Documents/site-packages") biblPath = os.path.expanduser("~/Documents/site-packages")
exmpPath = os.path.expanduser("~/Documents/Examples") exmpPath = os.path.expanduser("~/Documents/Examples")
# Alte Installation löschen
shutil.rmtree(exmpPath + "/velamentum", True) shutil.rmtree(exmpPath + "/velamentum", True)
shutil.rmtree(biblPath + "/velamentum", True) shutil.rmtree(biblPath + "/velamentum", True)
# Verzeichnisse anlegen
if not os.path.exists(archPath): os.makedirs(archPath) if not os.path.exists(archPath): os.makedirs(archPath)
if not os.path.exists(biblPath): os.makedirs(biblPath) if not os.path.exists(biblPath): os.makedirs(biblPath)
if not os.path.exists(exmpPath): os.makedirs(exmpPath) 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())) 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] cmid = arch.getnames()[0]
arch.extractall(path=archPath) arch.extractall(path=archPath)
# Installieren
vsrcPath = archPath + "/" + cmid + "/source/" vsrcPath = archPath + "/" + cmid + "/source/"
shutil.move(vsrcPath + platform, biblPath + '/velamentum') shutil.move(vsrcPath + platform, biblPath + '/velamentum')
shutil.move(vsrcPath + "Examples", exmpPath + '/velamentum') shutil.move(vsrcPath + "Examples", exmpPath + '/velamentum')
# Nicht benötigte Dateien löschen
shutil.rmtree(archPath, True) shutil.rmtree(archPath, True)
print("Die aktuelle Version von Velamentum wurde installiert. Bitte die App neu starten.") print("Die aktuelle Version von Velamentum wurde installiert. Bitte die App neu starten.")