Python cgitb 模块,text() 实例源码

我们从Python开源项目中,提取了以下19个代码示例,用于说明如何使用cgitb.text()

项目:touch-pay-client    作者:HackPucBemobi    | 项目源码 | 文件源码
def _get_table(self, db, tablename, app):
        tablename = tablename + '_' + app
        table = db.get(tablename)
        if not table:
            table = db.define_table(
                tablename,
                db.Field('ticket_id', length=100),
                db.Field('ticket_data', 'text'),
                db.Field('created_datetime', 'datetime'))
        return table
项目:dati-ckan-docker    作者:italia    | 项目源码 | 文件源码
def text_traceback():
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        res = 'the original traceback:'.join(
            cgitb.text(sys.exc_info()).split('the original traceback:')[1:]
        ).strip()
    return res
项目:dati-ckan-docker    作者:italia    | 项目源码 | 文件源码
def _get_content_as_unicode(self, url):
        '''
        Get remote content as unicode.

        We let requests handle the conversion [1] , which will use the
        content-type header first or chardet if the header is missing
        (requests uses its own embedded chardet version).

        As we will be storing and serving the contents as unicode, we actually
        replace the original XML encoding declaration with an UTF-8 one.


        [1] http://github.com/kennethreitz/requests/blob/63243b1e3b435c7736acf1e51c0f6fa6666d861d/requests/models.py#L811

        '''
        url = url.replace(' ', '%20')
        response = requests.get(url, timeout=10)

        content = response.text

        # Remove original XML declaration
        content = re.sub('<\?xml(.*)\?>', '', content)

        # Get rid of the BOM and other rubbish at the beginning of the file
        content = re.sub('.*?<', '<', content, 1)
        content = content[content.index('<'):]

        return content
项目:dati-ckan-docker    作者:italia    | 项目源码 | 文件源码
def text_traceback():
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        res = 'the original traceback:'.join(
            cgitb.text(sys.exc_info()).split('the original traceback:')[1:]
        ).strip()
    return res
项目:true_review_web2py    作者:lucadealfaro    | 项目源码 | 文件源码
def _get_table(self, db, tablename, app):
        tablename = tablename + '_' + app
        table = db.get(tablename)
        if not table:
            table = db.define_table(
                tablename,
                db.Field('ticket_id', length=100),
                db.Field('ticket_data', 'text'),
                db.Field('created_datetime', 'datetime'))
        return table
项目:Problematica-public    作者:TechMaz    | 项目源码 | 文件源码
def _get_table(self, db, tablename, app):
        tablename = tablename + '_' + app
        table = db.get(tablename)
        if not table:
            table = db.define_table(
                tablename,
                db.Field('ticket_id', length=100),
                db.Field('ticket_data', 'text'),
                db.Field('created_datetime', 'datetime'))
        return table
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_fonts(self):
        text = "Hello Robbie!"
        self.assertEqual(cgitb.small(text), "<small>{}</small>".format(text))
        self.assertEqual(cgitb.strong(text), "<strong>{}</strong>".format(text))
        self.assertEqual(cgitb.grey(text),
                         '<font color="#909090">{}</font>'.format(text))
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_text(self):
        try:
            raise ValueError("Hello World")
        except ValueError as err:
            text = cgitb.text(sys.exc_info())
            self.assertIn("ValueError", text)
            self.assertIn("Hello World", text)
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_syshook_no_logdir_text_format(self):
        # Issue 12890: we were emitting the <p> tag in text mode.
        with temp_dir() as tracedir:
            rc, out, err = assert_python_failure(
                  '-c',
                  ('import cgitb; cgitb.enable(format="text", logdir=%s); '
                   'raise ValueError("Hello World")') % repr(tracedir))
        out = out.decode(sys.getfilesystemencoding())
        self.assertIn("ValueError", out)
        self.assertIn("Hello World", out)
        self.assertNotIn('<p>', out)
        self.assertNotIn('</p>', out)
项目:rekall-agent-server    作者:rekall-innovations    | 项目源码 | 文件源码
def _get_table(self, db, tablename, app):
        tablename = tablename + '_' + app
        table = db.get(tablename)
        if not table:
            table = db.define_table(
                tablename,
                db.Field('ticket_id', length=100),
                db.Field('ticket_data', 'text'),
                db.Field('created_datetime', 'datetime'))
        return table
项目:web3py    作者:web2py    | 项目源码 | 文件源码
def _get_table(self, db, tablename, app):
        tablename = tablename + '_' + app
        table = db.get(tablename)
        if not table:
            table = db.define_table(
                tablename,
                db.Field('ticket_id', length=100),
                db.Field('ticket_data', 'text'),
                db.Field('created_datetime', 'datetime'))
        return table
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_fonts(self):
        text = "Hello Robbie!"
        self.assertEqual(cgitb.small(text), "<small>{}</small>".format(text))
        self.assertEqual(cgitb.strong(text), "<strong>{}</strong>".format(text))
        self.assertEqual(cgitb.grey(text),
                         '<font color="#909090">{}</font>'.format(text))
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_text(self):
        try:
            raise ValueError("Hello World")
        except ValueError as err:
            text = cgitb.text(sys.exc_info())
            self.assertIn("ValueError", text)
            self.assertIn("Hello World", text)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_syshook_no_logdir_text_format(self):
        # Issue 12890: we were emitting the <p> tag in text mode.
        with temp_dir() as tracedir:
            rc, out, err = assert_python_failure(
                  '-c',
                  ('import cgitb; cgitb.enable(format="text", logdir=%s); '
                   'raise ValueError("Hello World")') % repr(tracedir))
        out = out.decode(sys.getfilesystemencoding())
        self.assertIn("ValueError", out)
        self.assertIn("Hello World", out)
        self.assertNotIn('<p>', out)
        self.assertNotIn('</p>', out)
项目:slugiot-client    作者:slugiot    | 项目源码 | 文件源码
def _get_table(self, db, tablename, app):
        tablename = tablename + '_' + app
        table = db.get(tablename)
        if not table:
            table = db.define_table(
                tablename,
                db.Field('ticket_id', length=100),
                db.Field('ticket_data', 'text'),
                db.Field('created_datetime', 'datetime'))
        return table
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_fonts(self):
        text = "Hello Robbie!"
        self.assertEqual(cgitb.small(text), "<small>{}</small>".format(text))
        self.assertEqual(cgitb.strong(text), "<strong>{}</strong>".format(text))
        self.assertEqual(cgitb.grey(text),
                         '<font color="#909090">{}</font>'.format(text))
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_text(self):
        try:
            raise ValueError("Hello World")
        except ValueError as err:
            text = cgitb.text(sys.exc_info())
            self.assertIn("ValueError", text)
            self.assertIn("Hello World", text)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_syshook_no_logdir_text_format(self):
        # Issue 12890: we were emitting the <p> tag in text mode.
        with temp_dir() as tracedir:
            rc, out, err = assert_python_failure(
                  '-c',
                  ('import cgitb; cgitb.enable(format="text", logdir=%s); '
                   'raise ValueError("Hello World")') % repr(tracedir))
        out = out.decode(sys.getfilesystemencoding())
        self.assertIn("ValueError", out)
        self.assertIn("Hello World", out)
        self.assertNotIn('<p>', out)
        self.assertNotIn('</p>', out)
项目:StuffShare    作者:StuffShare    | 项目源码 | 文件源码
def _get_table(self, db, tablename, app):
        tablename = tablename + '_' + app
        table = db.get(tablename)
        if not table:
            table = db.define_table(
                tablename,
                db.Field('ticket_id', length=100),
                db.Field('ticket_data', 'text'),
                db.Field('created_datetime', 'datetime'))
        return table