Attempt to fix the BeRTOS Wizard running directory-related issue.
[bertos.git] / wizard / bertos.py
index 53fa11383f47ad2131c543c31939f7c37c7b0395..e4255177a62557bcab7a05d8b93225df8e0479c8 100755 (executable)
@@ -61,6 +61,7 @@ from BFinalPage import BFinalPage
 from BEditingDialog import BEditingDialog, BVersionDialog, BToolchainDialog
 
 import bertos_utils
+import const
 
 from LoadException import VersionException, ToolchainException
 
@@ -119,21 +120,17 @@ def showStartPage():
     QApplication.instance().dialog.show()
 
 def main():
-    rundir = os.getcwd()
-    datadir = sys.argv[0]
-    if os.path.islink(datadir):
-        datadir = os.readlink(datadir)
-    datadir = os.path.dirname(os.path.abspath(datadir))
-    os.chdir(datadir)
     app = QApplication(sys.argv)
     app.settings = QSettings("Develer", "Bertos Configurator")
     app.project = BProject.BProject()
     # Development utility lines, to be removed for production
-    if not (hasattr(sys, "frozen") and sys.frozen) and newer("bertos.qrc", "bertos.rcc"):
-        os.system("rcc -binary bertos.qrc -o bertos.rcc")
-    QResource.registerResource("bertos.rcc")
+    datadir = const.DATA_DIR
+    qrc, rcc = os.path.join(datadir, 'bertos.qrc'), os.path.join(datadir, 'bertos.rcc')
+    if not (hasattr(sys, "frozen") and sys.frozen) and newer(qrc, rcc):
+        os.system("rcc -binary %s -o %s" %(qrc, rcc))
+    QResource.registerResource(rcc)
     if len(sys.argv) == 3 and sys.argv[1] == "--edit":
-        editProject(os.path.join(rundir, sys.argv[2]))
+        editProject(sys.argv[2])
     else:
         newProject()