Now the wizard can launch the IDE.
[bertos.git] / wizard / bertos.py
index a8d4665091269c92ac7285def2e4e2eac687aa38..ca6072e42e73c6a766b36e83a9ea639adc5eee38 100755 (executable)
@@ -1,10 +1,10 @@
-#!/usr/bin/env python
+#!/usr/bin/env python
 # encoding: utf-8
 #
 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
 # All rights reserved.
 #
-# $Id:$
+# $Id$
 #
 # Author: Lorenzo Berni <duplo@develer.com>
 #
@@ -38,6 +38,17 @@ def newProject():
     wizard = BWizard.BWizard(page_list)
     wizard.show()
     wizard.exec_()
+    project = QApplication.instance().project
+    to_be_opened = project.info("TO_BE_OPENED")
+    command_lines = project.info("COMMAND_LINES")
+    relevant_files = project.info("RELEVANT_FILES")
+    if to_be_opened:
+        for ide in to_be_opened:
+            command_line = command_lines[ide]
+            relevant_file = relevant_files[ide]
+            import subprocess
+            subprocess.call(command_line + " \"" + relevant_file + "\"")
+    sys.exit()
     
 def editProject():
     page_list = [BOpenPage, BVersionPage, BCpuPage, BToolchainPage, BModulePage, BOutputPage, BCreationPage, BFinalPage]
@@ -52,11 +63,12 @@ def showStartPage():
     QApplication.instance().dialog.show()
 
 def main():
+    os.chdir(os.path.dirname(os.path.abspath(sys.argv[0])))
     app = QApplication(sys.argv)
     app.settings = QSettings("Develer", "Bertos Configurator")
     app.project = BProject.BProject()
-    ## Development utility lines, to be removed for production
-    if newer("bertos.qrc", "bertos.rcc"):
+    # 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")
     if "--create" in sys.argv and "--edit" not in sys.argv:
@@ -64,13 +76,12 @@ def main():
     elif "--edit" in sys.argv and "--create" not in sys.argv:
         editProject()
     elif "--create" in sys.argv and "--edit" in sys.argv:
-        ## TODO: need an explaining message
+        # TODO need an explaining message
         print " ".join(sys.argv)
         print "Invalid usage!"
         pass
     else:
-        showStartPage()
-        sys.exit(app.exec_())
+        newProject()
 
 if __name__ == '__main__':
     main()