Beispiel #1
0
    def do_run(self):
        read_line = create_read_line_function(self.input_file, config.prompt)
        subs_compiler_command = get_compiler_command(self.options, self.exec_filename)

        while True:
            inp = read_line(self.input_num + 1)  # 1-indexed
            if inp is None:
                break

            col_inp, run_compiler = dot_commands.process(inp, self)

            if col_inp:
                if self.input_num < len(self.user_input):
                    self.user_input = self.user_input[: self.input_num]

                if incl_re.match(inp) is None:
                    typ = UserInput.COMMAND
                else:
                    typ = UserInput.INCLUDE

                self.user_input.append(UserInput(inp, typ))
                self.input_num += 1

            if run_compiler:
                self.compile_error = run_compile(subs_compiler_command, self)

                if self.compile_error is not None:
                    info = "Compile error - type .e to see it OR disregard if multi-line statement(s)\n"
                    print(colorize(info, "magenta"))
                    continue

                stdout_data, stderr_data = run_exec(self.exec_filename)

                if len(stdout_data) > self.output_chars_printed:
                    new_output = stdout_data[self.output_chars_printed :]
                    len_new_output = len(new_output)

                    print(new_output.decode("utf8"))

                    self.output_chars_printed += len_new_output
                    self.user_input[-1].output_chars = len_new_output

                if len(stderr_data) > self.error_chars_printed:
                    new_error = stderr_data[self.error_chars_printed :]
                    len_new_error = len(new_error)

                    print(new_error.decode("utf8"))

                    self.error_chars_printed += len_new_error
                    self.user_input[-1].error_chars = len_new_error

            print()  # ensure empty newline between commands
Beispiel #2
0
    def do_run(self):
        read_line = create_read_line_function(self.inputfile, prompt)

        subs_compiler_command = get_compiler_command(self.options,
                                                     self.exefilename)

        inp = 1
        while inp is not None:
            inp = read_line()
            if inp is not None:

                col_inp, run_cmp = (dot_commands.process(inp, self))
                if self.functions_paste and inp.strip() != '.f':
                    self.user_functions.append(inp)
                elif col_inp:
                    if self.input_num < len(self.user_input):
                        self.user_input = self.user_input[:self.input_num]
                    if incl_re.match(inp):
                        typ = UserInput.INCLUDE
                    else:
                        typ = UserInput.COMMAND
                    self.user_input.append(UserInput(inp, typ))
                    self.input_num += 1

                if run_cmp and not self.paste and not self.functions_paste:
                    self.compile_error = run_compile(subs_compiler_command,
                                                     self)

                    if self.compile_error is not None:
                        print "[Compile error - type .e to see it.]"
                    else:
                        stdoutdata, stderrdata = run_exe(self.exefilename)

                        if len(stdoutdata) > self.output_chars_printed:
                            new_output = stdoutdata[self.output_chars_printed:]
                            len_new_output = len(new_output)
                            print new_output,
                            self.output_chars_printed += len_new_output
                            self.user_input[-1].output_chars = len_new_output

                        if len(stderrdata) > self.error_chars_printed:
                            new_error = stderrdata[self.error_chars_printed:]
                            len_new_error = len(new_error)
                            print new_error,
                            self.error_chars_printed += len_new_error
                            self.user_input[-1].error_chars = len_new_error

        print
Beispiel #3
0
	def do_run( self ):
		read_line = create_read_line_function( self.inputfile, prompt )

		subs_compiler_command = get_compiler_command( self.options, self.exefilename )

		inp = 1
		while inp is not None:
			inp = read_line()
			if inp is not None:

				col_inp, run_cmp = (
					dot_commands.process( inp, self ) )
				if self.functions_paste and inp.strip() != '.f':
					self.user_functions.append(inp)
				elif col_inp:
					if self.input_num < len( self.user_input ):
						self.user_input = self.user_input[ : self.input_num ]
					if incl_re.match( inp ):
						typ = UserInput.INCLUDE
					else:
						typ = UserInput.COMMAND
					self.user_input.append( UserInput( inp, typ ) )
					self.input_num += 1

				if run_cmp and not self.paste and not self.functions_paste:
					self.compile_error = run_compile( subs_compiler_command,
						self )

					if self.compile_error is not None:
						print "[Compile error - type .e to see it.]"
					else:
						stdoutdata, stderrdata = run_exe( self.exefilename )

						if len( stdoutdata ) > self.output_chars_printed:
							new_output = stdoutdata[self.output_chars_printed:]
							len_new_output = len( new_output )
							print new_output,
							self.output_chars_printed += len_new_output
							self.user_input[ -1 ].output_chars = len_new_output

						if len( stderrdata ) > self.error_chars_printed:
							new_error = stderrdata[self.error_chars_printed:]
							len_new_error = len( new_error )
							print new_error,
							self.error_chars_printed += len_new_error
							self.user_input[ -1 ].error_chars = len_new_error

		print