예제 #1
0
    def exec_code(self, sourcecode):

        start_time = time.time()

        stdout_redirector = Redirector(self.page_msg)
        globals = {}
        locals = {}

        try:
            code = compile(sourcecode, "<stdin>", "exec", 0, 1)
            if "pylucid_access" in self.request.form:
                exec code
            else:
                exec code in globals, locals
        except:
            etype, value, tb = sys.exc_info()
            tb = tb.tb_next
            msg = ''.join(traceback.format_exception(etype, value, tb))
            sys.stdout.write(msg)

        output = stdout_redirector.get()

        duration = time.time() - start_time

        self.response.write(
            "<fieldset><legend>executed in %.3fsec.:</legend>" % duration
        )
        self.response.write("<pre>")
        self.response.write(output)
        self.response.write("</pre></fieldset>")
예제 #2
0
    def exec_code(self, sourcecode):

        start_time = time.time()

        stdout_redirector = Redirector(self.page_msg)
        globals = {}
        locals = {}

        try:
            code = compile(sourcecode, "<stdin>", "exec", 0, 1)
            if "pylucid_access" in self.request.form:
                exec code
            else:
                exec code in globals, locals
        except:
            etype, value, tb = sys.exc_info()
            tb = tb.tb_next
            msg = ''.join(traceback.format_exception(etype, value, tb))
            sys.stdout.write(msg)

        output = stdout_redirector.get()

        duration = time.time() - start_time

        self.response.write(
            "<fieldset><legend>executed in %.3fsec.:</legend>" % duration)
        self.response.write("<pre>")
        self.response.write(output)
        self.response.write("</pre></fieldset>")
예제 #3
0
 def __get_help(self, obj):
     out = Redirector(self.page_msg)
     help(obj)
     return cgi.escape(out.get())
예제 #4
0
 def __get_help(self, obj):
     out = Redirector(self.page_msg)
     help(obj)
     return cgi.escape(out.get())