def set_process_env(self, process): arduino_path = settings.arduino_path() if not arduino_path: self.emit(QtCore.SIGNAL("compile_log"), "error","Arduino root path not found") #TOD self.emit( return False env = QtCore.QStringList() env << QtCore.QString("ARDUINO_DIR=").append(arduino_path.path()) env << QtCore.QString("ARDUINO_BOARD=").append(self.board) env << QtCore.QString("ARDUINO_PORT=").append(self.serial_port) process.setEnvironment(env) self.emit(QtCore.SIGNAL("compile_log"), "env", env.join(" ")) process.setWorkingDirectory(self.project_dir) self.emit(QtCore.SIGNAL("compile_log"), "env", "cwd=" % self.project_dir) return True
def set_process_env(self, process): arduino_path = settings.arduino_path() if not arduino_path: self.emit(QtCore.SIGNAL("compile_log"), "error", "Arduino root path not found") #TOD self.emit( return False env = QtCore.QStringList() env << QtCore.QString("ARDUINO_DIR=").append(arduino_path.path()) env << QtCore.QString("ARDUINO_BOARD=").append(self.board) env << QtCore.QString("ARDUINO_PORT=").append(self.serial_port) process.setEnvironment(env) self.emit(QtCore.SIGNAL("compile_log"), "env", env.join(" ")) process.setWorkingDirectory(self.project_dir) self.emit(QtCore.SIGNAL("compile_log"), "env", "cwd=" % self.project_dir) return True
def ard_make(self, file_to_compile, board, port): self.file_to_compile = file_to_compile self.board = board self.port = port self.emit(QtCore.SIGNAL("compile_log"), "start_compile", "%s" % self.file_to_compile) process = QtCore.QProcess(self) arduino_path = settings.arduino_path() if not arduino_path: self.set_error("Arduino root path not found", "..nothing to do ..") #TOD self.emit( return #print arduino_path.path() ## ENV - Set Envoironment variables env = QtCore.QStringList() env << QtCore.QString("ARDUINO_DIR=").append(arduino_path.path()) env << QtCore.QString("ARDUINO_BOARD=").append(board) env << QtCore.QString("ARDUINO_sPORT=").append(port) process.setEnvironment(env) self.emit(QtCore.SIGNAL("compile_log"), "env", env.join(" ")) #print "----------------------------------------" ## Set "process path" to working dir Project Directory project_dir = QtCore.QFileInfo(self.file_to_compile).absolutePath() process.setWorkingDirectory(project_dir) self.emit(QtCore.SIGNAL("compile_log"), "env", "cwd=" % project_dir) ## construct the command "sh /app_path/etc/arduino_make.sh compile" and execute in project_dir dir command = QtCore.QString("sh ") #args = QtCore.QStringList() script_full_path = settings.app_path().absoluteFilePath("etc/arduino_make.sh compile ") command.append(script_full_path) #print "command=", command self.emit(QtCore.SIGNAL("compile_log"), "command", QtCore.QString(command)) ## Execute process process.start(command) if process.waitForStarted(): process.waitForFinished() result = process.readAllStandardOutput() #print type(result), result error = process.readAllStandardError() #print type(error), error if error: #print "is error", error #self.actionIcon.setIcon(Icon(Ico.CompileError)) #self.statusLabel.setText("Error") #self.textWidget.setPlainText(QtCore.QString(error)) #self.emit(QtCore.SIGNAL("compile_error"), QtCore.QString(error)) self.emit(QtCore.SIGNAL("compile_log"), "error", QtCore.QString(error)) else: #print "is ok", result #self.emit(QtCore.SIGNAL("compile_result"), QtCore.QString(result)) self.emit(QtCore.SIGNAL("compile_log"), "result", QtCore.QString(result)) #self.statusLabel.setText("OK") #self.actionIcon.setIcon(Icon(Ico.CompileOk)) #self.textWidget.setPlainText(QtCore.QString(result)) ### >>>> DEAD #self.progress.hide() return command = QtCore.QString() ## Create command sh arduinp_make.sh command.append("pwd") # sh ").append(self.main.settings.app_path()).append("/etc/arduino_make.sh compile") #args = QtCore.QStringList() #command.append(self.main.settings.app_path()).append("/etc/arduino_make.sh compile ") #command.append(QtCore.QFileInfo(self.current_file_path).dir().path()) print "command=", command process = QtCore.QProcess(self) process.start(command) if process.waitForStarted(): process.waitForFinished(); result = process.readAllStandardOutput() #print type(result), result error = process.readAllStandardError() #print type(error), error if error: self.textWidget.setPlainText(QtCore.QString(error)) else: self.textWidget.setPlainText(QtCore.QString(result))
def compile(self, file_path): self.current_file_path = file_path self.progress.show() arduino_path = settings.arduino_path() if not arduino_path: self.set_error("Arduino root path not found", "..nothing to do ..") return ## Set Envoironment env = QtCore.QStringList() env << QtCore.QString("ARDUINO_DIR=").append(settings.arduino_path().absolutePath()) env << QtCore.QString("ARDUINO_BOARD=").append("atmega328") env << QtCore.QString("ARDUINO_sPORT=").append("s/ssdev/ttyUSB0") self.process.setEnvironment(env) print "----------------------------------------" ## Set working dir sketch_dir = QtCore.QFileInfo(self.current_file_path).absolutePath() self.process.setWorkingDirectory(sketch_dir) command = QtCore.QString("sh ") ## Create command sh arduinp_make.sh #command.append("pwd ") #.append(QtCore.QFileInfo(self.current_file_path).dir().path()) #args = QtCore.QStringList() command.append(settings.app_path().absoluteFilePath("etc/arduino_make.sh").append(" compile")) #command.append(QtCore.QFileInfo(self.current_file_path).dir().path()) print "command=", command self.process.start(command) if self.process.waitForStarted(): self.process.waitForFinished() result = self.process.readAllStandardOutput() #print type(result), result error = self.process.readAllStandardError() #print type(error), error if error: print "is error" self.actionIcon.setIcon(Icon(Ico.CompileError)) self.statusLabel.setText("Error") self.terminalTextWidget.setPlainText(QtCore.QString(error)) else: print "is ok" self.statusLabel.setText("OK") self.actionIcon.setIcon(Icon(Ico.CompileOk)) self.terminalTextWidget.setPlainText(QtCore.QString(result)) self.progress.hide() return command = QtCore.QString() ## Create command sh arduinp_make.sh command.append("pwd") # sh ").append(self.main.settings.app_path()).append("/etc/arduino_make.sh compile") #args = QtCore.QStringList() #command.append(self.main.settings.app_path()).append("/etc/arduino_make.sh compile ") #command.append(QtCore.QFileInfo(self.current_file_path).dir().path()) print "command=", command process = QtCore.QProcess(self) process.start(command) if process.waitForStarted(): process.waitForFinished(); result = process.readAllStandardOutput() #print type(result), result error = process.readAllStandardError() #print type(error), error if error: self.terminalTextWidget.setPlainText(QtCore.QString(error)) else: self.terminalTextWidget.setPlainText(QtCore.QString(result))
def compile(self, file_path): self.current_file_path = file_path self.progress.show() arduino_path = settings.arduino_path() if not arduino_path: self.set_error("Arduino root path not found", "..nothing to do ..") return ## Set Envoironment env = QtCore.QStringList() env << QtCore.QString("ARDUINO_DIR=").append( settings.arduino_path().absolutePath()) env << QtCore.QString("ARDUINO_BOARD=").append("atmega328") env << QtCore.QString("ARDUINO_sPORT=").append("s/ssdev/ttyUSB0") self.process.setEnvironment(env) print "----------------------------------------" ## Set working dir sketch_dir = QtCore.QFileInfo(self.current_file_path).absolutePath() self.process.setWorkingDirectory(sketch_dir) command = QtCore.QString("sh ") ## Create command sh arduinp_make.sh #command.append("pwd ") #.append(QtCore.QFileInfo(self.current_file_path).dir().path()) #args = QtCore.QStringList() command.append(settings.app_path().absoluteFilePath( "etc/arduino_make.sh").append(" compile")) #command.append(QtCore.QFileInfo(self.current_file_path).dir().path()) print "command=", command self.process.start(command) if self.process.waitForStarted(): self.process.waitForFinished() result = self.process.readAllStandardOutput() #print type(result), result error = self.process.readAllStandardError() #print type(error), error if error: print "is error" self.actionIcon.setIcon(Icon(Ico.CompileError)) self.statusLabel.setText("Error") self.terminalTextWidget.setPlainText(QtCore.QString(error)) else: print "is ok" self.statusLabel.setText("OK") self.actionIcon.setIcon(Icon(Ico.CompileOk)) self.terminalTextWidget.setPlainText(QtCore.QString(result)) self.progress.hide() return command = QtCore.QString() ## Create command sh arduinp_make.sh command.append( "pwd" ) # sh ").append(self.main.settings.app_path()).append("/etc/arduino_make.sh compile") #args = QtCore.QStringList() #command.append(self.main.settings.app_path()).append("/etc/arduino_make.sh compile ") #command.append(QtCore.QFileInfo(self.current_file_path).dir().path()) print "command=", command process = QtCore.QProcess(self) process.start(command) if process.waitForStarted(): process.waitForFinished() result = process.readAllStandardOutput() #print type(result), result error = process.readAllStandardError() #print type(error), error if error: self.terminalTextWidget.setPlainText(QtCore.QString(error)) else: self.terminalTextWidget.setPlainText(QtCore.QString(result))