use Cocoa for mac folder paths
This commit is contained in:
parent
8d09979a5a
commit
954d3b8acd
13
AO2XP.py
13
AO2XP.py
@ -1,5 +1,8 @@
|
|||||||
import subprocess, sys, thread, time, os, platform, __builtin__
|
import subprocess, sys, thread, time, os, platform, __builtin__
|
||||||
from os.path import exists, abspath
|
from os.path import exists, abspath
|
||||||
|
try:
|
||||||
|
import Cocoa # mac
|
||||||
|
except: pass
|
||||||
|
|
||||||
from PyQt4 import QtGui, QtCore
|
from PyQt4 import QtGui, QtCore
|
||||||
|
|
||||||
@ -15,9 +18,9 @@ if osname == "Linux": QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_X11InitT
|
|||||||
app = QtGui.QApplication(sys.argv)
|
app = QtGui.QApplication(sys.argv)
|
||||||
|
|
||||||
path = sys.argv[0]
|
path = sys.argv[0]
|
||||||
if osname == "Darwin" and ".app" in path: # bundle
|
if osname == "Darwin":
|
||||||
path = "/".join(path.split("/")[:-1]) # to Resources folder
|
path = Cocoa.NSBundle.mainBundle()
|
||||||
os.chdir(path)
|
os.chdir(path.resourcePath())
|
||||||
|
|
||||||
debugmode = len(sys.argv) > 1 and sys.argv[1] == "debug"
|
debugmode = len(sys.argv) > 1 and sys.argv[1] == "debug"
|
||||||
if not debugmode:
|
if not debugmode:
|
||||||
@ -86,8 +89,8 @@ if not debugmode:
|
|||||||
if code == 0:
|
if code == 0:
|
||||||
subprocess.Popen(["./AO2XPupdat"])
|
subprocess.Popen(["./AO2XPupdat"])
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
elif osname == "Darwin" and ".app" in sys.argv[0]: # bundle
|
elif osname == "Darwin": # bundle
|
||||||
os.chdir(path) # return to Resources folder
|
os.chdir(path.resourcePath()) # return to Resources folder
|
||||||
|
|
||||||
|
|
||||||
import gameview, mainmenu, options
|
import gameview, mainmenu, options
|
||||||
|
13
updater.py
13
updater.py
@ -1,5 +1,8 @@
|
|||||||
import json, sys, requests, time, os, platform, traceback
|
import json, sys, requests, time, os, platform, traceback
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
try:
|
||||||
|
import Cocoa # mac
|
||||||
|
except: pass
|
||||||
|
|
||||||
from PyQt4 import QtGui, QtCore
|
from PyQt4 import QtGui, QtCore
|
||||||
|
|
||||||
@ -145,9 +148,9 @@ class updateThread(QtCore.QThread):
|
|||||||
return
|
return
|
||||||
|
|
||||||
path = sys.argv[0]
|
path = sys.argv[0]
|
||||||
if platform.system() == "Darwin" and ".app" in path: # bundle
|
if platform.system() == "Darwin":
|
||||||
path = "/".join(path.split("/")[:-4]) # right next to the .app package
|
path = Cocoa.NSBundle.mainBundle().bundlePath()
|
||||||
os.chdir(path)
|
os.chdir(os.path.splitext(path)[0]) # right next to the .app package
|
||||||
|
|
||||||
updatezip = "update" + os.path.splitext(filename)[1]
|
updatezip = "update" + os.path.splitext(filename)[1]
|
||||||
if not os.path.exists(updatezip):
|
if not os.path.exists(updatezip):
|
||||||
@ -186,9 +189,9 @@ class updateThread(QtCore.QThread):
|
|||||||
|
|
||||||
print "downloaded update"
|
print "downloaded update"
|
||||||
downloadfile.close()
|
downloadfile.close()
|
||||||
if platform.system() == "Darwin" and ".app" in sys.argv[0]: # bundle
|
if platform.system() == "Darwin":
|
||||||
self.labelText.emit("Making a backup of AO base folder...")
|
self.labelText.emit("Making a backup of AO base folder...")
|
||||||
path = "/".join(sys.argv[0].split("/")[:-1]) # to Resources folder
|
path = Cocoa.NSBundle.mainBundle().resourcePath()
|
||||||
os.system("cp -r "+path+"/base ./appbase") # move the base folder out of the app folder to avoid deletion
|
os.system("cp -r "+path+"/base ./appbase") # move the base folder out of the app folder to avoid deletion
|
||||||
returncode = 0
|
returncode = 0
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user