def checkFile(queue, code, filePath, fileEncoding): tmp = os.path.join(constants.getAppTempDirectory(), QFileInfo(filePath).fileName()) if os.path.isdir(tmp): return with open(tmp, "wb") as f: if sys.version_info[0] == 3: code = bytes(code, fileEncoding) else: code = code.encode(fileEncoding) f.write(code) fileType = detect_file_type(tmp) output = os.path.join(constants.getAppTempDirectory(), QFileInfo(tmp).baseName() + fileType[2]) status, messages = compiler.compile(tmp, fileType, outputFilename=output) queue.put(messages)
def compileCurrent(self, filePath, programType): """ Compiles the current file and its dependencies (executed in a background thread """ dependencies = parse_dependencies(filePath) globalStatus = True for path, pgmType in dependencies: status, messags = compiler.compile(path, pgmType) globalStatus &= status for msg in messags: self.compilerMsgReady.emit(msg) if status == 0: msg = pyqode.core.CheckerMessage( "Compilation succeeded", pyqode.core.MSG_STATUS_INFO, -1, icon=":/ide-icons/rc/accept.png", filename=path) msg.filename =path else: msg = pyqode.core.CheckerMessage( "Compilation failed", pyqode.core.MSG_STATUS_ERROR, -1, filename=path) msg.filename = path self.compilerMsgReady.emit(msg) status, messages = compiler.compile(filePath, programType) for msg in messages: self.compilerMsgReady.emit(msg) if status == 0: msg = pyqode.core.CheckerMessage( "Compilation succeeded", pyqode.core.MSG_STATUS_INFO, -1, icon=":/ide-icons/rc/accept.png", filename=filePath) else: msg = pyqode.core.CheckerMessage( "Compilation failed", pyqode.core.MSG_STATUS_ERROR, -1, filename=filePath) msg.filename = filePath self.compilerMsgReady.emit(msg) self.compilationFinished.emit(globalStatus)