# Author: Lorenzo Berni <duplo@develer.com>
#
+import os
+
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import uic
import qvariant_converter
+import const
+
class BWizardPage(QWizardPage):
"""
Base class for all the wizard pages. It has the utility method used in all
def __init__(self, wizardGui, parent = None):
QWizardPage.__init__(self, parent)
- self.pageContent = uic.loadUi(wizardGui, None)
+ self.pageContent = uic.loadUi(os.path.join(const.DATA_DIR, wizardGui), None)
layout = QVBoxLayout()
layout.addWidget(self.pageContent)
self.setLayout(layout)
from BEditingDialog import BEditingDialog, BVersionDialog, BToolchainDialog
import bertos_utils
+import const
from LoadException import VersionException, ToolchainException
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()
mergeSources(srcdir, sources_dir, old_sources_dir)
# Destination makefile
makefile = directory + "/Makefile"
- makefile = open("mktemplates/Makefile").read()
+ makefile = open(os.path.join(const.DATA_DIR, "mktemplates/Makefile"), 'r').read()
makefile = makefileGenerator(project_info, makefile)
open(directory + "/Makefile", "w").write(makefile)
# Destination project dir
f.close()
if not edit:
# Destination user mk file (only on project creation)
- makefile = open("mktemplates/template.mk", "r").read()
+ makefile = open(os.path.join(const.DATA_DIR, "mktemplates/template.mk"), "r").read()
makefile = mkGenerator(project_info, makefile)
open(prjdir + "/" + os.path.basename(prjdir) + ".mk", "w").write(makefile)
# Destination wizard mk file
- makefile = open("mktemplates/template_wiz.mk", "r").read()
+ makefile = open(os.path.join(const.DATA_DIR, "mktemplates/template_wiz.mk"), "r").read()
makefile = mkGenerator(project_info, makefile)
open(prjdir + "/" + os.path.basename(prjdir) + "_wiz.mk", "w").write(makefile)
# Destination main.c file
if not edit:
- main = open("srctemplates/main.c", "r").read()
+ main = open(os.path.join(const.DATA_DIR, "srctemplates/main.c"), "r").read()
open(prjdir + "/main.c", "w").write(main)
# Files for selected plugins
relevants_files = {}
# Author: Lorenzo Berni <duplo@develer.com>
#
+import os, sys
+
+_tmp = sys.argv[0]
+if os.path.islink(_tmp):
+ _tmp = os.readlink(_tmp)
+DATA_DIR = os.path.dirname(os.path.abspath(_tmp))
+del _tmp
+
CPU_DEF = {
"CPU_NAME": "",
"CPU_DIR": "",
"""
Returns the string rapresenting the codelite project.
"""
- template = open("cltemplates/bertos.project", "r").read()
+ template = open(os.path.join(const.DATA_DIR, "cltemplates/bertos.project"), "r").read()
filelist = "\n".join(clFiles(findSources(project_info.info("PROJECT_PATH")), ""))
debugger_path = project_info.info("TOOLCHAIN")["path"].replace("gcc", "gdb")
init_script = project_info.info("CPU_INFOS")["GDB_INIT_SCRIPT"]
"""
Returns the string rapresentig the codelite workspace.
"""
- template = open("cltemplates/bertos.workspace", "r").read()
+ template = open(os.path.join(const.DATA_DIR, "cltemplates/bertos.workspace"), "r").read()
project_name = os.path.basename(project_info.info("PROJECT_PATH"))
while template.find("$project") != -1:
template = template.replace("$project", project_name)