def createProcess(self): arguments = self.createArguments() for index, argument in enumerate(arguments): if isinstance(argument, str): has_null = ("\0" in argument) elif isinstance(argument, unicode): has_null = (u"\0" in argument) else: raise ValueError("Process argument %s is not a byte or unicode string: (%s) %r" % ( index, type(argument).__name__, argument)) if has_null: raise ValueError("Process argument %s contains nul byte: %r" % ( index, argument)) arguments[0] = locateProgram(arguments[0], raise_error=True) popen_args = self.createPopenArguments() self.info("Create process: %s" % repr(arguments)) self.info("Working directory: %s" % self.getWorkingDirectory()) self.writeReplayScripts(arguments, popen_args) try: self.current_arguments = arguments self.current_popen_args = popen_args self.time0 = time() self.process = Popen(arguments, **popen_args) except ChildError, err: raise ProcessError(unicode(err))
def compileC(logger, c_filename, output_filename, options=None, debug=True, libraries=None): """ Compile a C script. Raise CompilerError on failure. """ global GCC_PROGRAM if not GCC_PROGRAM: if RUNNING_WINDOWS: program = u"gcc.exe" else: program = u"gcc" GCC_PROGRAM = locateProgram(program, raise_error=True) command = [GCC_PROGRAM, u"-o", output_filename, c_filename] if debug: command.extend((u"-Wall", u"-Wextra", u"-Werror")) command.append(u"-std=c99") if libraries: for library in libraries: command.append(u"-l%s" % library) if options: options = options.split() command.extend(options) try: runCommand(logger, command) except RuntimeError, err: raise CompilerError("Unable to compile %s: %s" % (basename(c_filename), err))
def xhostCommand(xhost_program, user, allow=True): if not xhostCommand.program: xhostCommand.program = locateProgram(xhost_program, raise_error=True) if allow: prefix = '+' else: prefix = '-' return [xhostCommand.program, "%slocal:%s" % (prefix, user)]
def setupProject(self): parrot_root = self.options.parrot_root runcore = self.options.runcore parrot = locateProgram(parrot_root + "/parrot") process = ParrotProcess(self.project, [parrot, runcore, "<fuzzy.pir>"]) pirgen = PirGenerator(self.project, self.options) WatchProcess(process) WatchStdout(process)
def xhostCommand(xhost_program, user, allow=True): if not xhostCommand.program: xhostCommand.program = locateProgram( xhost_program, raise_error=True) if allow: prefix = '+' else: prefix = '-' return [ xhostCommand.program, "%slocal:%s" % (prefix, user)]
def createProcess(self): arguments = self.createArguments() for index, argument in enumerate(arguments): if "\0" in argument: raise ValueError("Argument %s contains nul byte: %r" % (index, argument)) arguments[0] = locateProgram(arguments[0]) popen_args = self.createPopenArguments() self.warning("Create process %r" % ' '.join(arguments)) try: self.time0 = time() self.process = Popen(arguments, **popen_args) except OSError, err: if err.errno == ENOENT: raise ValueError("Program doesn't exist: %s" % arguments[0]) else: raise