本文整理汇总了Python中twisted.internet.defer.setDebugging函数的典型用法代码示例。如果您正苦于以下问题:Python setDebugging函数的具体用法?Python setDebugging怎么用?Python setDebugging使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setDebugging函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUpClass
def setUpClass(cls):
if not os.environ.get('KAFKA_VERSION'): # pragma: no cover
return
DEBUGGING = True
setDebugging(DEBUGGING)
DelayedCall.debug = DEBUGGING
zk_chroot = random_string(10)
replicas = 2
partitions = 7
# mini zookeeper, 2 kafka brokers
cls.zk = ZookeeperFixture.instance()
kk_args = [cls.zk.host, cls.zk.port, zk_chroot, replicas, partitions]
cls.kafka_brokers = [
KafkaFixture.instance(i, *kk_args) for i in range(replicas)]
hosts = ['%s:%d' % (b.host, b.port) for b in cls.kafka_brokers]
# We want a short timeout on message sending for this test, since
# we are expecting failures when we take down the brokers
cls.client = KafkaClient(hosts, timeout=1000, clientId=__name__)
# Startup the twisted reactor in a thread. We need this before the
# the KafkaClient can work, since KafkaBrokerClient relies on the
# reactor for its TCP connection
cls.reactor, cls.thread = threaded_reactor()
开发者ID:joshainglis,项目名称:afkak,代码行数:27,代码来源:test_failover_integration.py
示例2: install_exception_handlers
def install_exception_handlers(quitFunc=None):
"""this handles exceptions that would normally be caught by Python or Twisted and just silently ignored..."""
def handle_exception(excType, value, tb):
log_ex(value, "Unhandled exception in main loop:", reasonTraceback=tb, excType=excType)
sys.excepthook = handle_exception
#this handles exceptions that would normally be caught by Twisted:
def handle_twisted_err(_stuff=None, _why=None, quitFunc=quitFunc, **kw):
excType = None
tb = None
#get the exception from the system if necessary
if not _stuff or issubclass(type(_stuff), Exception):
(excType, _stuff, tb) = sys.exc_info()
#check if this is a shutdown signal
if quitFunc and _stuff and issubclass(type(_stuff), KeyboardInterrupt):
log_msg("Shutting down from keyboard interrupt...", 0)
quitFunc()
return
#otherwise, log the exception
if excType and tb:
log_ex(_stuff, "Unhandled exception from Twisted:", reasonTraceback=tb, excType=excType)
else:
log_ex(_stuff, "Unhandled failure from Twisted:")
twisted.python.log.err = handle_twisted_err
twisted.python.log.deferr = handle_twisted_err
#for debugging deferreds--maintains the callstack so AlreadyCalled errors are easier to debug
defer.setDebugging(True)
开发者ID:clawplach,项目名称:BitBlinder,代码行数:26,代码来源:Twisted.py
示例3: setUpClass
def setUpClass(cls):
if not os.environ.get('KAFKA_VERSION'): # pragma: no cover
log.warning("WARNING: KAFKA_VERSION not found in environment")
return
DEBUGGING = True
setDebugging(DEBUGGING)
DelayedCall.debug = DEBUGGING
# Single zookeeper, 3 kafka brokers
zk_chroot = random_string(10)
replicas = 3
partitions = 2
cls.zk = ZookeeperFixture.instance()
kk_args = [cls.zk.host, cls.zk.port, zk_chroot, replicas, partitions]
cls.kafka_brokers = [
KafkaFixture.instance(i, *kk_args) for i in range(replicas)]
# server is used by our superclass when creating the client...
cls.server = cls.kafka_brokers[0]
# Startup the twisted reactor in a thread. We need this before the
# the KafkaClient can work, since KafkaBrokerClient relies on the
# reactor for its TCP connection
cls.reactor, cls.thread = threaded_reactor()
开发者ID:joshainglis,项目名称:afkak,代码行数:25,代码来源:test_consumer_integration.py
示例4: _init_local
def _init_local(self):
from p2p import commands
from lib import net_misc
from lib import misc
from system import tmpfile
from system import run_upnpc
from raid import eccmap
from userid import my_id
my_id.init()
if settings.enableWebStream():
from logs import weblog
weblog.init(settings.getWebStreamPort())
if settings.enableWebTraffic():
from logs import webtraffic
webtraffic.init(port=settings.getWebTrafficPort())
misc.init()
commands.init()
tmpfile.init(settings.getTempDir())
net_misc.init()
settings.update_proxy_settings()
run_upnpc.init()
eccmap.init()
if sys.argv.count("--twisted"):
from twisted.python import log as twisted_log
twisted_log.startLogging(MyTwistedOutputLog(), setStdout=0)
# import twisted.python.failure as twisted_failure
# twisted_failure.startDebugMode()
# twisted_log.defaultObserver.stop()
if settings.getDebugLevel() > 10:
defer.setDebugging(True)
开发者ID:vesellov,项目名称:bitdust.devel,代码行数:34,代码来源:initializer.py
示例5: main
def main():
"""
Test harness main()
Usage:
python SshClient.py hostname[:port] comand [command]
Each command must be enclosed in quotes (") to be interpreted
properly as a complete unit.
"""
from itertools import chain
from twisted.python import log
import pprint
import sys, getpass
if debug:
log.startLogging(sys.stdout)
defer.setDebugging(True)
# logging.basicConfig()
client = ClientCommandFactory(username="user", ip="127.0.0.1", port=22, keyPath="/home/user/.ssh/id_rsa")
client.run()
# client._commands.append('hostname')
reactor.run()
pprint.pprint(client.getResults())
开发者ID:sheva-serg,项目名称:executor,代码行数:28,代码来源:sshclient2.py
示例6: setup_logging
def setup_logging(options):
default = pkg_resources.resource_filename(tron.__name__, 'logging.conf')
logfile = options.log_conf or default
level = twist_level = None
if options.verbose > 0:
level = logging.INFO
twist_level = logging.WARNING
if options.verbose > 1:
level = logging.DEBUG
twist_level = logging.INFO
if options.verbose > 2:
twist_level = logging.DEBUG
tron_logger = logging.getLogger('tron')
twisted_logger = logging.getLogger('twisted')
logging.config.fileConfig(logfile)
if level is not None:
tron_logger.setLevel(level)
if twist_level is not None:
twisted_logger.setLevel(twist_level)
# Hookup twisted to standard logging
twisted_log.PythonLoggingObserver().start()
# Show stack traces for errors in twisted deferreds.
if options.debug:
defer.setDebugging(True)
开发者ID:Feriority,项目名称:Tron,代码行数:29,代码来源:trondaemon.py
示例7: main
def main():
arg = docopt("""
Usage: environment.py [options]
-v Verbose
""")
log.setLevel(logging.INFO)
if arg['-v']:
enableTwistedLog()
log.setLevel(logging.DEBUG)
defer.setDebugging(True)
masterGraph = PatchableGraph()
class Application(cyclone.web.Application):
def __init__(self):
handlers = [
(r"/()",
cyclone.web.StaticFileHandler,
{"path": ".", "default_filename": "index.html"}),
(r'/graph',
CycloneGraphHandler, {'masterGraph': masterGraph}),
(r'/graph/events',
CycloneGraphEventsHandler, {'masterGraph': masterGraph}),
(r'/doc', Doc), # to be shared
(r'/stats/(.*)', StatsHandler, {'serverName': 'environment'}),
]
cyclone.web.Application.__init__(self, handlers,
masterGraph=masterGraph)
task.LoopingCall(update, masterGraph).start(1)
reactor.listenTCP(9075, Application())
reactor.run()
开发者ID:drewp,项目名称:homeauto,代码行数:32,代码来源:environment.py
示例8: debug
def debug(self, var):
"""Enable or Disable application model debugging. You should extend
this if you know how to enable application debugging in your custom
'application model'.
returns deferred - already called
"""
#assume blaster which is string based, sent the message
var = str(var) #for safety
a = var.lower()
context = {'code' : 0}
template = '[%(application)s] Debug '
try:
if a == 'true':
self.model.debug = True
defer.setDebugging(True)
template += 'Enabled'
elif a == 'false':
self.model.debug = False
defer.setDebugging(False)
template += 'Disabled'
else:
raise TypeError('input must be a bool, True/False')
except Exception, exc:
template += str(exc)
context['code'] = 1
开发者ID:cbrinley,项目名称:droned,代码行数:26,代码来源:appmgr.py
示例9: connect
def connect(self):
if self.clientdir == None:
raise MissingAttributeError('Missing Directory')
if self.enc_pwd == None:
raise MissingAttributeError('Missing Password')
if os.path.exists(self.clientdir + '/restore~'):
self.process_restore_folder()
if not os.path.exists(self.clientdir):
os.makedirs(self.clientdir)
self.key = hashlib.sha256(self.enc_pwd).digest()
self.existing_file_dict = parse_existing_clientdir(self.enc_pwd, self.clientdir)
self.gdc = get_dir_changes(self.clientdir, self.configfile)
if self.gdc == 'new':
self.new_file_dict = parse_new_dir(self.clientdir, self.enc_pwd, self.key)
else:
self.new_file_dict = parse_dir_changes(self.clientdir, self.gdc, self.enc_pwd, self.key)
self.file_dict = dict(self.existing_file_dict.items() + self.new_file_dict.items())
self.file_dict, self.get_list = process_file_list(self.previous_file_dict, self.existing_file_dict)
self.tmp_files = parse_tmp_dir(self.clientdir)
self.config.set('client', 'path', self.clientdir)
self.config.set('client', 'password', self.enc_pwd)
self.config.set('client', 'ip', self.med_ip)
self.config.set('client', 'port', self.med_port)
save_client_wallet(self.configfile, self.config, self.rsa_key, self.file_dict)
defer.setDebugging(self.debug)
reactor.connectTCP(self.med_ip, self.med_port, MediatorClientFactory(self.clientdir, self.rsa_key, self.tmp_files, 2, self.get_list, self.enc_pwd, self))
reactor.run()
开发者ID:ihasn,项目名称:fincrypt,代码行数:33,代码来源:client_node.py
示例10: opt_debug
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
开发者ID:antong,项目名称:twisted,代码行数:8,代码来源:app.py
示例11: __init__
def __init__(self, config):
""" Set up the server with a INDX. """
self.config = config
from twisted.internet.defer import setDebugging
setDebugging(True)
# enable ssl (or not)
self.ssl = config['server'].get('ssl') or False
# generate the base URLs
self.server_url = self.config['server']['hostname']
if not self.ssl:
self.server_url = "http://" + self.server_url
if self.config['server']['port'] != 80:
self.server_url = self.server_url + ":" + str(self.config['server']['port'])
else:
self.server_url = "https://" + self.server_url
if self.config['server']['port'] != 443:
self.server_url = self.server_url + ":" + str(self.config['server']['port'])
# get values to pass to web server
self.server_address = self.config['server']['address']
if self.server_address == "":
self.server_address = "0.0.0.0"
database.HOST = config['db']['host']
database.PORT = config['db']['port']
def auth_cb(can_auth):
logging.debug("WebServer auth_cb, can_auth: {0}".format(can_auth))
if can_auth:
def checked_db_ok(server_id):
self.server_id = server_id # Gets the Server ID from the database
self.check_users().addCallbacks(lambda checked: self.server_setup(), err_cb)
self.database.check_indx_db().addCallbacks(checked_db_ok, err_cb) # check indx DB exists, otherwise create it - then setup the server
else:
print "Authentication failed, check username and password are correct."
reactor.stop()
def auth_err(failure):
logging.debug("WebServer err_cb, failure: {0}".format(failure))
failure.trap(Exception)
print "Authentication failed, check username and password are correct."
reactor.stop()
def err_cb(failure):
logging.debug("WebServer err_cb, failure: {0}".format(failure))
failure.trap(Exception)
user,password = self.get_indx_user_password()
self.database = database.IndxDatabase(config['indx_db'], user, password)
self.tokens = token.TokenKeeper(self.database)
self.database.auth_indx(database = "postgres").addCallbacks(auth_cb, auth_err)
开发者ID:imclab,项目名称:indx,代码行数:58,代码来源:server.py
示例12: opt_debug
def opt_debug(self):
"""
run the application in the Python Debugger (implies nodaemon),
sending SIGUSR2 will drop into debugger
"""
from twisted.internet import defer
defer.setDebugging(True)
failure.startDebugMode()
self['debug'] = True
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:9,代码来源:app.py
示例13: testNoDebugging
def testNoDebugging(self):
defer.setDebugging(False)
d = defer.Deferred()
d.addCallbacks(self._callback, self._errback)
self._call_1(d)
try:
self._call_2(d)
except defer.AlreadyCalledError, e:
self.failIf(e.args)
开发者ID:Berimor66,项目名称:mythbox,代码行数:9,代码来源:test_defer.py
示例14: __init__
def __init__(self, *args, **kwargs):
super(AbstractServer, self).__init__(*args, **kwargs)
twisted.internet.base.DelayedCall.debug = True
self.watchdog = WatchDog()
self.selected_socks5_ports = set()
# Enable Deferred debugging
from twisted.internet.defer import setDebugging
setDebugging(True)
开发者ID:synctext,项目名称:tribler,代码行数:10,代码来源:test_as_server.py
示例15: _twisted_debug
def _twisted_debug():
"""
When the ``AFKAK_TWISTED_DEBUG`` environment variable is set, enable
debugging of deferreds and delayed calls.
"""
if os.environ.get('AFKAK_TWISTED_DEBUG'):
from twisted.internet import defer
from twisted.internet.base import DelayedCall
defer.setDebugging(True)
DelayedCall.debug = True
开发者ID:ciena,项目名称:afkak,代码行数:11,代码来源:__init__.py
示例16: main
def main(utility):
args = _parse_args(utility)
if args.debug:
log.setLevel(level=logging.DEBUG)
defer.setDebugging(True)
if args.config:
config = _parse_config_file(args.config, utility)
else:
config = _adapt_args_to_config(args, utility)
reactor.callWhenRunning(utility.tx_main, args, config)
reactor.run()
sys.exit(_exit_status)
开发者ID:zenoss,项目名称:txwinrm,代码行数:12,代码来源:app.py
示例17: __init__
def __init__(self, i, conf, port):
self.cpu_blocking = conf[0]
self.net_blocking = conf[1]
self.io_blocking = conf[2]
print "One client running on port %s" % port
self.num = i
self.url = "http://localhost:%s/zip" % port
self.count = 0
self.deferreds = []
setDebugging(True)
self.done_deferred = Deferred()
开发者ID:lfdversluis,项目名称:python-stuff,代码行数:12,代码来源:benchmark_cpu_network_io.py
示例18: __init__
def __init__(self, config):
self.config = config
application = service.Application(
self.config.get('bit', 'name').capitalize(), uid=1001, gid=1001)
self.s = service.IServiceCollection(application)
#self.s.setServiceParent(application)
alsoProvides(application, IApplication)
provideUtility(application, IApplication)
provideUtility(Services(application), IServices)
plugins = Plugins()
provideUtility(plugins, IPlugins)
plugins.loadPlugins()
defer.setDebugging(True)
开发者ID:bithub,项目名称:bit.core,代码行数:13,代码来源:runner.py
示例19: parse_options
def parse_options(self):
"""Parses the command line options"""
parser = self.make_option_parser()
(options, args) = parser.parse_args()
if options.logstderr and not options.foreground:
parser.error('-s is only valid if running in foreground')
if options.netbox and not options.onlyjob:
parser.error('specifying a netbox requires the -J option')
if options.multiprocess:
options.pidlog = True
if options.capture_vars:
setDebugging(True)
return options, args
开发者ID:alexanderfefelov,项目名称:nav,代码行数:14,代码来源:daemon.py
示例20: main
def main():
args = parse_args()
if args.debug:
log.setLevel(level=logging.DEBUG)
defer.setDebugging(True)
if args.interactive:
tx_main = interactive_main
elif args.single_shot:
tx_main = single_shot_main
elif args.batch:
tx_main = batch_main
else:
tx_main = long_running_main
reactor.callWhenRunning(tx_main, args)
reactor.run()
开发者ID:Hackman238,项目名称:txwinrm,代码行数:15,代码来源:winrs.py
注:本文中的twisted.internet.defer.setDebugging函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论