Python twisted.python.failure.startDebugMode() Examples

The following are 16 code examples of twisted.python.failure.startDebugMode(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module twisted.python.failure , or try the search function .
Example #1
Source File: test_failure.py    From Safejumper-for-Desktop with GNU General Public License v2.0 6 votes vote down vote up
def setUp(self):
        """
        Override pdb.post_mortem so we can make sure it's called.
        """
        # Make sure any changes we make are reversed:
        post_mortem = pdb.post_mortem
        if _shouldEnableNewStyle:
            origInit = failure.Failure.__init__
        else:
            origInit = failure.Failure.__dict__['__init__']
        def restore():
            pdb.post_mortem = post_mortem
            if _shouldEnableNewStyle:
                failure.Failure.__init__ = origInit
            else:
                failure.Failure.__dict__['__init__'] = origInit
        self.addCleanup(restore)

        self.result = []
        pdb.post_mortem = self.result.append
        failure.startDebugMode() 
Example #2
Source File: __init__.py    From learn_python3_spider with MIT License 6 votes vote down vote up
def process_options(self, args, opts):
        try:
            self.settings.setdict(arglist_to_dict(opts.set),
                                  priority='cmdline')
        except ValueError:
            raise UsageError("Invalid -s value, use -s NAME=VALUE", print_help=False)

        if opts.logfile:
            self.settings.set('LOG_ENABLED', True, priority='cmdline')
            self.settings.set('LOG_FILE', opts.logfile, priority='cmdline')

        if opts.loglevel:
            self.settings.set('LOG_ENABLED', True, priority='cmdline')
            self.settings.set('LOG_LEVEL', opts.loglevel, priority='cmdline')

        if opts.nolog:
            self.settings.set('LOG_ENABLED', False, priority='cmdline')

        if opts.pidfile:
            with open(opts.pidfile, "w") as f:
                f.write(str(os.getpid()) + os.linesep)

        if opts.pdb:
            failure.startDebugMode() 
Example #3
Source File: __init__.py    From learn_python3_spider with MIT License 6 votes vote down vote up
def process_options(self, args, opts):
        try:
            self.settings.setdict(arglist_to_dict(opts.set),
                                  priority='cmdline')
        except ValueError:
            raise UsageError("Invalid -s value, use -s NAME=VALUE", print_help=False)

        if opts.logfile:
            self.settings.set('LOG_ENABLED', True, priority='cmdline')
            self.settings.set('LOG_FILE', opts.logfile, priority='cmdline')

        if opts.loglevel:
            self.settings.set('LOG_ENABLED', True, priority='cmdline')
            self.settings.set('LOG_LEVEL', opts.loglevel, priority='cmdline')

        if opts.nolog:
            self.settings.set('LOG_ENABLED', False, priority='cmdline')

        if opts.pidfile:
            with open(opts.pidfile, "w") as f:
                f.write(str(os.getpid()) + os.linesep)

        if opts.pdb:
            failure.startDebugMode() 
Example #4
Source File: app.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def opt_debug(self):
        """
        Run the application in the Python Debugger (implies nodaemon),
        sending SIGUSR2 will drop into debugger
        """
        defer.setDebugging(True)
        failure.startDebugMode()
        self['debug'] = True 
Example #5
Source File: test_failure.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def test_regularFailure(self):
        """
        If startDebugMode() is called, calling Failure() will first call
        pdb.post_mortem with the traceback.
        """
        try:
            1/0
        except:
            typ, exc, tb = sys.exc_info()
            f = failure.Failure()
        self.assertEqual(self.result, [tb])
        self.assertFalse(f.captureVars) 
Example #6
Source File: test_failure.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def test_captureVars(self):
        """
        If startDebugMode() is called, passing captureVars to Failure() will
        not blow up.
        """
        try:
            1/0
        except:
            typ, exc, tb = sys.exc_info()
            f = failure.Failure(captureVars=True)
        self.assertEqual(self.result, [tb])
        self.assertTrue(f.captureVars) 
Example #7
Source File: trial.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def _initialDebugSetup(config):
    # do this part of debug setup first for easy debugging of import failures
    if config['debug']:
        failure.startDebugMode()
    if config['debug'] or config['debug-stacktraces']:
        defer.setDebugging(True) 
Example #8
Source File: app.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def opt_debug(self):
        """
        Run the application in the Python Debugger (implies nodaemon),
        sending SIGUSR2 will drop into debugger
        """
        defer.setDebugging(True)
        failure.startDebugMode()
        self['debug'] = True 
Example #9
Source File: test_failure.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def setUp(self):
        """
        Override pdb.post_mortem so we can make sure it's called.
        """
        # Make sure any changes we make are reversed:
        post_mortem = pdb.post_mortem
        origInit = failure.Failure.__init__
        def restore():
            pdb.post_mortem = post_mortem
            failure.Failure.__init__ = origInit
        self.addCleanup(restore)

        self.result = []
        pdb.post_mortem = self.result.append
        failure.startDebugMode() 
Example #10
Source File: test_failure.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def test_regularFailure(self):
        """
        If startDebugMode() is called, calling Failure() will first call
        pdb.post_mortem with the traceback.
        """
        try:
            1/0
        except:
            typ, exc, tb = sys.exc_info()
            f = failure.Failure()
        self.assertEqual(self.result, [tb])
        self.assertFalse(f.captureVars) 
Example #11
Source File: test_failure.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def test_captureVars(self):
        """
        If startDebugMode() is called, passing captureVars to Failure() will
        not blow up.
        """
        try:
            1/0
        except:
            typ, exc, tb = sys.exc_info()
            f = failure.Failure(captureVars=True)
        self.assertEqual(self.result, [tb])
        self.assertTrue(f.captureVars) 
Example #12
Source File: app.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def opt_debug(self):
        """
        run the application in the Python Debugger (implies nodaemon),
        sending SIGUSR2 will drop into debugger
        """
        defer.setDebugging(True)
        failure.startDebugMode()
        self['debug'] = True 
Example #13
Source File: trial.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def _initialDebugSetup(config):
    # do this part of debug setup first for easy debugging of import failures
    if config['debug']:
        failure.startDebugMode()
    if config['debug'] or config['debug-stacktraces']:
        defer.setDebugging(True) 
Example #14
Source File: app.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def opt_debug(self):
        """
        run the application in the Python Debugger (implies nodaemon),
        sending SIGUSR2 will drop into debugger
        """
        defer.setDebugging(True)
        failure.startDebugMode()
        self['debug'] = True 
Example #15
Source File: trial.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def _initialDebugSetup(config):
    # do this part of debug setup first for easy debugging of import failures
    if config['debug']:
        failure.startDebugMode()
    if config['debug'] or config['debug-stacktraces']:
        defer.setDebugging(True) 
Example #16
Source File: cli.py    From PyFeeds with GNU Affero General Public License v3.0 5 votes vote down vote up
def cli(ctx, loglevel, config, pdb):
    """
    feeds creates feeds for pages that don't have feeds.
    """
    if pdb:
        failure.startDebugMode()

    # A pip-installed Feeds does not have a scrapy.cfg in its project root.
    os.environ["SCRAPY_SETTINGS_MODULE"] = "feeds.default_settings"

    settings = load_feeds_settings(config)
    settings.set("LOG_LEVEL", loglevel.upper())
    ctx.obj["settings"] = settings