def doPopupMakefile(self, event): pathToOpenedFile = split(realpath(self.getPageObject().filePath))[0] if not exists(join(pathToOpenedFile, 'Makefile')): curPath = getcwd() chdir(pathToOpenedFile) GenerateMakefile().generate(self.getPageObject().fileName, self.getPageObject().projectType, self.API.pathToMansos) chdir(curPath) self.addPage(join(pathToOpenedFile, 'Makefile'))
class DoCompile(): def __init__(self, API): self.API = API self.generateMakefile = GenerateMakefile() self.editor = self.API.tabManager.getPageObject self.curPath = '' def doCompile(self): self.curPath = getcwd() chdir(path.split(path.realpath(self.editor().filePath))[0]) self.generateMakefile.generate(self.editor().fileName, self.editor().projectType, self.API.pathToMansos) platform = self.API.getActivePlatform() thread = MyThread(doPopen, ["make", platform], \ self.dummy, True, False, "Compile") self.API.startThread(thread) chdir(self.curPath) def clean(self, data = None): curPath = getcwd() chdir(path.split(path.realpath(self.editor().filePath))[0]) thread = MyThread(doPopen, ["make", "clean"], \ self.dummy, True, False, "Clean") self.API.startThread(thread) if self.curPath == '': chdir(curPath) else: chdir(self.curPath) # Passed to thread start as callback, because without callback # there is no Done msg. def dummy(self, output): pass
def __init__(self, API): self.API = API self.generateMakefile = GenerateMakefile() self.editor = self.API.tabManager.getPageObject
class DoUpload(): def __init__(self, API): self.API = API self.generateMakefile = GenerateMakefile() self.editor = self.API.tabManager.getPageObject def doUpload(self): self.targets = list(self.API.targets) # If no target specified, use default if len(self.targets) == 0: self.targets.append(None) if self.API.targetType == SHELL: return self.shellUpload() else: os.unsetenv("BSLPORT") self.usbUpload() def usbUpload(self, data = None): if self.editor() == None: return self.curPath = os.getcwd() os.chdir(os.path.split(os.path.realpath(self.editor().filePath))[0]) self.generateMakefile.generate(self.editor().fileName, self.editor().projectType, self.API.pathToMansos) platform = self.API.getActivePlatform() while len(self.targets): target = self.targets.pop() self.changeTarget(target) thread = MyThread(doPopen, ["make", platform, "upload"], \ self.usbUpload, True, False, "Upload") self.API.startThread(thread) else: pass #self.clean() def clean(self, data = None): self.API.startPopen(["make", "clean"], "Clean", None, False) os.chdir(self.curPath) def shellUpload(self, targets, platform): assert False, "Currently not supported" startDir = os.getcwd() os.chdir(self.pathToMansos + "/tools/shell") ihex = startDir + "/build/" + platform + "/image.ihex" if not os.path.exists(ihex) or not os.path.isfile(ihex): return [False, "Mistake with ihex file location."] cmd = ['./shell', '-l', ihex] for target in targets: actualCmd = cmd if target == None: target = "default device" else: actualCmd.append("-s") actualCmd.append(target) try: pass #upload = Popen(actualCmd, stdin = PIPE, # stderr = STDOUT, stdout = PIPE) # #out = upload.communicate("program")[0] #if out.find("File uploaded") == -1: # os.chdir(startDir) # return [False, out] except OSError, e: print "execution failed:", e os.chdir(startDir) return [False, e] os.chdir(startDir) return [True, '']
class DoUpload(): def __init__(self, API): self.API = API self.generateMakefile = GenerateMakefile() self.editor = self.API.tabManager.getPageObject def doUpload(self): self.targets = list(self.API.targets) # If no target specified, use default if len(self.targets) == 0: self.targets.append(None) if self.API.targetType == SHELL: return self.shellUpload() else: os.unsetenv("BSLPORT") self.usbUpload() def usbUpload(self, data=None): if self.editor() == None: return self.curPath = os.getcwd() os.chdir(os.path.split(os.path.realpath(self.editor().filePath))[0]) self.generateMakefile.generate(self.editor().fileName, self.editor().projectType, self.API.pathToMansos) platform = self.API.getActivePlatform() while len(self.targets): target = self.targets.pop() self.changeTarget(target) thread = MyThread(doPopen, ["make", platform, "upload"], \ self.usbUpload, True, False, "Upload") self.API.startThread(thread) else: pass #self.clean() def clean(self, data=None): self.API.startPopen(["make", "clean"], "Clean", None, False) os.chdir(self.curPath) def shellUpload(self, targets, platform): assert False, "Currently not supported" startDir = os.getcwd() os.chdir(self.pathToMansos + "/tools/shell") ihex = startDir + "/build/" + platform + "/image.ihex" if not os.path.exists(ihex) or not os.path.isfile(ihex): return [False, "Mistake with ihex file location."] cmd = ['./shell', '-l', ihex] for target in targets: actualCmd = cmd if target == None: target = "default device" else: actualCmd.append("-s") actualCmd.append(target) try: pass #upload = Popen(actualCmd, stdin = PIPE, # stderr = STDOUT, stdout = PIPE) # #out = upload.communicate("program")[0] #if out.find("File uploaded") == -1: # os.chdir(startDir) # return [False, out] except OSError, e: print "execution failed:", e os.chdir(startDir) return [False, e] os.chdir(startDir) return [True, '']