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__
|
||||
from os.path import exists, abspath
|
||||
try:
|
||||
import Cocoa # mac
|
||||
except: pass
|
||||
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
@ -15,9 +18,9 @@ if osname == "Linux": QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_X11InitT
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
|
||||
path = sys.argv[0]
|
||||
if osname == "Darwin" and ".app" in path: # bundle
|
||||
path = "/".join(path.split("/")[:-1]) # to Resources folder
|
||||
os.chdir(path)
|
||||
if osname == "Darwin":
|
||||
path = Cocoa.NSBundle.mainBundle()
|
||||
os.chdir(path.resourcePath())
|
||||
|
||||
debugmode = len(sys.argv) > 1 and sys.argv[1] == "debug"
|
||||
if not debugmode:
|
||||
@ -86,8 +89,8 @@ if not debugmode:
|
||||
if code == 0:
|
||||
subprocess.Popen(["./AO2XPupdat"])
|
||||
os._exit(0)
|
||||
elif osname == "Darwin" and ".app" in sys.argv[0]: # bundle
|
||||
os.chdir(path) # return to Resources folder
|
||||
elif osname == "Darwin": # bundle
|
||||
os.chdir(path.resourcePath()) # return to Resources folder
|
||||
|
||||
|
||||
import gameview, mainmenu, options
|
||||
|
13
updater.py
13
updater.py
@ -1,5 +1,8 @@
|
||||
import json, sys, requests, time, os, platform, traceback
|
||||
from io import BytesIO
|
||||
try:
|
||||
import Cocoa # mac
|
||||
except: pass
|
||||
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
@ -145,9 +148,9 @@ class updateThread(QtCore.QThread):
|
||||
return
|
||||
|
||||
path = sys.argv[0]
|
||||
if platform.system() == "Darwin" and ".app" in path: # bundle
|
||||
path = "/".join(path.split("/")[:-4]) # right next to the .app package
|
||||
os.chdir(path)
|
||||
if platform.system() == "Darwin":
|
||||
path = Cocoa.NSBundle.mainBundle().bundlePath()
|
||||
os.chdir(os.path.splitext(path)[0]) # right next to the .app package
|
||||
|
||||
updatezip = "update" + os.path.splitext(filename)[1]
|
||||
if not os.path.exists(updatezip):
|
||||
@ -186,9 +189,9 @@ class updateThread(QtCore.QThread):
|
||||
|
||||
print "downloaded update"
|
||||
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...")
|
||||
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
|
||||
returncode = 0
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user