本文整理汇总了Python中pyff.logs.log.debug函数的典型用法代码示例。如果您正苦于以下问题:Python debug函数的具体用法?Python debug怎么用?Python debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_metadata
def parse_metadata(self, fn, key=None, base_url=None, fail_on_error=False, filter_invalid=True):
"""Parse a piece of XML and split it up into EntityDescriptor elements. Each such element
is stored in the MDRepository instance.
:param fn: a file-like object containing SAML metadata
:param key: a certificate (file) or a SHA1 fingerprint to use for signature verification
:param base_url: use this base url to resolve relative URLs for XInclude processing
"""
try:
t = etree.parse(fn, base_url=base_url,
parser=etree.XMLParser(resolve_entities=False))
t.xinclude()
if filter_invalid:
for e in t.findall('{%s}EntityDescriptor' % NS['md']):
if not schema().validate(e):
error = _e(schema().error_log, m=base_url)
log.debug("removing '%s': schema validation failed (%s)" % (
e.get('entityID'), error))
e.getparent().remove(e)
self.fire(type=EVENT_DROP_ENTITY, url=base_url,
entityID=e.get('entityID'), error=error)
else:
# Having removed the invalid entities this should now never
# happen...
schema().assertValid(t)
except DocumentInvalid, ex:
traceback.print_exc()
log.debug("schema validation failed on '%s': %s" % (
base_url, _e(ex.error_log, m=base_url)))
raise MetadataException("schema validation failed")
示例2: load_dir
def load_dir(self, directory, ext=".xml", url=None):
"""
:param directory: A directory to walk.
:param ext: Include files with this extension (default .xml)
Traverse a directory tree looking for metadata. Files ending in the specified extension are included. Directories
starting with '.' are excluded.
"""
if url is None:
url = directory
log.debug("walking %s" % directory)
if not directory in self.md:
entities = []
for top, dirs, files in os.walk(directory):
for dn in dirs:
if dn.startswith("."):
dirs.remove(dn)
for nm in files:
log.debug("found file %s" % nm)
if nm.endswith(ext):
fn = os.path.join(top, nm)
try:
t = self.parse_metadata(fn, fail_on_error=True)
# local metadata is assumed to be ok
entities.extend(self.entities(t))
except Exception, ex:
log.error(ex)
self.import_metadata(self.entity_set(entities, url))
示例3: run
def run(self, server):
locked = False
try:
if self.lock.acquire(blocking=0):
locked = True
md = self.server.new_repository()
for o in self.server.observers:
md.subscribe(o)
for p in server.plumbings:
state = {'update': True, 'stats': {}}
p.process(md, state)
stats.update(state.get('stats', {}))
if not md.sane():
log.error("update produced insane active repository - will try again later...")
with server.lock.writelock:
log.debug("update produced new repository with %d entities" % md.index.size())
server.md = md
md.fire(type=EVENT_REPOSITORY_LIVE, size=md.index.size())
stats['Repository Update Time'] = datetime.now()
stats['Repository Size'] = md.index.size()
else:
log.error("another instance is running - will try again later...")
except Exception, ex:
traceback.print_exc(ex)
示例4: producer
def producer(q, resources, cache=self.metadata_cache_enabled):
print resources
for url, verify, id, tries in resources:
log.debug("Starting fetcher for %s" % url)
thread = URLFetch(url, verify, id, enable_cache=cache, tries=tries)
thread.start()
q.put(thread, True)
示例5: test_log_syslog
def test_log_syslog(self):
with patch('syslog.syslog', new=self.dummy_syslog):
try:
logger = logging.getLogger()
old_handlers = []
for hdl in logger.handlers:
logger.removeHandler(hdl)
old_handlers.append(hdl)
test_handler = SysLogLibHandler("USER")
logger.addHandler(test_handler)
logger.setLevel(logging.WARNING)
log.info("info")
log.warn("warn")
log.warning("warning")
log.error("error")
log.critical("critical")
log.debug("debug")
lines = self._syslog.getvalue().split("\n")
assert("info" not in lines)
assert("12:warn" in lines)
assert("12:warning" in lines)
assert("10:critical" in lines)
assert("11:error" in lines)
assert("debug" not in lines)
finally:
logger.removeHandler(test_handler)
for hdl in old_handlers:
logger.addHandler(hdl)
示例6: test_log_plain
def test_log_plain(self):
try:
logfile = StringIO()
logger = logging.getLogger()
old_handlers = []
for hdl in logger.handlers:
logger.removeHandler(hdl)
old_handlers.append(hdl)
test_handler = logging.StreamHandler(logfile)
logger.addHandler(test_handler)
logger.setLevel(logging.WARNING)
log.info("info")
log.warn("warn")
log.warning("warning")
log.error("error")
log.critical("critical")
log.debug("debug")
lines = logfile.getvalue().split("\n")
assert("info" not in lines)
assert("warn" in lines)
assert("warning" in lines)
assert("critical" in lines)
assert("error" in lines)
assert("debug" not in lines)
finally:
logger.removeHandler(test_handler)
for hdl in old_handlers:
logger.addHandler(hdl)
示例7: periodic
def periodic(self, stats):
now = _now()
stats['Last Periodic Maintenance'] = now
log.debug("periodic maintentance...")
self.rc.zremrangebyscore("members", "-inf", now)
self._drop_empty_av("collections", "members", now)
self._drop_empty_av("attributes", "values", now)
示例8: lookup
def lookup(self, key):
log.debug("redis store lookup: %s" % key)
if '+' in key:
hk = hex_digest(key)
if not self.rc.exists("%s#members" % hk):
self.rc.zinterstore("%s#members" % hk, ["%s#members" % k for k in key.split('+')], 'min')
self.rc.expire("%s#members" % hk, 30) # XXX bad juju - only to keep clients from hammering
return self.lookup(hk)
m = re.match("^(.+)=(.+)$", key)
if m:
return self.lookup("{%s}%s" % (m.group(1), m.group(2)))
m = re.match("^{(.+)}(.+)$", key)
if m and ';' in m.group(2):
hk = hex_digest(key)
if not self.rc.exists("%s#members" % hk):
self.rc.zunionstore("%s#members" % hk,
["{%s}%s#members" % (m.group(1), v) for v in m.group(2).split(';')], 'min')
self.rc.expire("%s#members" % hk, 30) # XXX bad juju - only to keep clients from hammering
return self.lookup(hk)
elif self.rc.exists("%s#alias" % key):
return self.lookup(self.rc.get("%s#alias" % key))
elif self.rc.exists("%s#metadata" % key):
return [self._get_metadata(key)]
else:
return self._members(key)
示例9: _process
def _process(self, req):
"""The inner request pipeline processor.
:param req: The request to run through the pipeline
"""
log.debug('Processing \n%s' % self)
for p in self.pipeline:
try:
pipe, opts, name, args = loader.load_pipe(p)
#log.debug("traversing pipe %s,%s,%s using %s" % (pipe,name,args,opts))
if type(args) is str or type(args) is unicode:
args = [args]
if args is not None and type(args) is not dict and type(args) is not list and type(args) is not tuple:
raise PipeException("Unknown argument type %s" % repr(args))
req.args = args
req.name = name
ot = pipe(req, *opts)
if ot is not None:
req.t = ot
#log.debug("new state after %s: %s (done=%s)" % (pipe,req.state,req.done))
if req.done:
break
except PipeException, ex:
log.error(ex)
break
示例10: when
def when(req, condition, *values):
"""
Conditionally execute part of the pipeline.
:param req: The request
:param condition: The condition key
:param values: The condition values
:param opts: More Options (unused)
:return: None
The inner pipeline is executed if the at least one of the condition values is present for the specified key in
the request state.
**Examples**
.. code-block:: yaml
- when foo
- something
- when bar bill
- other
The condition operates on the state: if 'foo' is present in the state (with any value), then the something branch is
followed. If 'bar' is present in the state with the value 'bill' then the other branch is followed.
"""
log.debug("condition key: %s" % repr(condition))
c = req.state.get(condition, None)
log.debug("condition %s" % repr(c))
if c is not None:
if not values or _any(values, c):
return Plumbing(pipeline=req.args, id="%s.when" % req.plumbing.id)._process(req)
return req.t
示例11: _drop_empty_av
def _drop_empty_av(self, attr, tag, ts):
an = "#%s" % attr
for c in self.rc.smembers(an):
tn = "%s#members" % c
self.rc.zremrangebyscore(tn, "-inf", ts)
if not self.rc.zcard(tn) > 0:
log.debug("dropping empty %s %s" % (attr, c))
self.rc.srem(an, c)
示例12: default
def default(self, *args, **kwargs):
log.debug("request default: %s" % ",".join(args))
if len(args) > 0 and args[0] in self.server.aliases:
kwargs['pfx'] = args[0]
if len(args) > 1:
kwargs['path'] = args[1]
return self.server.request(**kwargs)
else:
log.debug("not an alias: %s" % "/".join(args))
kwargs['pfx'] = None
kwargs['path'] = "/" + "/".join(args)
return self.server.request(**kwargs)
示例13: _select_args
def _select_args(req):
args = req.args
log.debug("selecting using args: %s" % args)
if args is None and 'select' in req.state:
args = [req.state.get('select')]
if args is None:
args = req.md.store.collections()
if args is None or not args:
args = req.md.store.lookup('entities')
if args is None or not args:
args = []
return args
示例14: resolve
def resolve(self, system_url, public_id, context):
"""
Resolves URIs using the resource API
"""
log.debug("resolve SYSTEM URL' %s' for '%s'" % (system_url, public_id))
path = system_url.split("/")
fn = path[len(path) - 1]
if pkg_resources.resource_exists(__name__, fn):
return self.resolve_file(pkg_resources.resource_stream(__name__, fn), context)
elif pkg_resources.resource_exists(__name__, "schema/%s" % fn):
return self.resolve_file(pkg_resources.resource_stream(__name__, "schema/%s" % fn), context)
else:
raise ValueError("Unable to locate %s" % fn)
示例15: parse_metadata
def parse_metadata(self,
fn,
key=None,
base_url=None,
fail_on_error=False,
filter_invalid=True,
validate=True,
post=None):
"""Parse a piece of XML and split it up into EntityDescriptor elements. Each such element
is stored in the MDRepository instance.
:param fn: a file-like object containing SAML metadata
:param key: a certificate (file) or a SHA1 fingerprint to use for signature verification
:param base_url: use this base url to resolve relative URLs for XInclude processing
:param fail_on_error: (default: False)
:param filter_invalid: (default True) remove invalid EntityDescriptor elements rather than raise an errror
:param validate: (default: True) set to False to turn off all XML schema validation
:param post: A callable that will be called to modify the parse-tree before any validation
(but after xinclude processing)
"""
try:
t = etree.parse(fn, base_url=base_url, parser=etree.XMLParser(resolve_entities=False))
t.xinclude()
if key is not None:
try:
log.debug("verifying signature using %s" % key)
refs = xmlsec.verified(t, key)
if len(refs) != 1:
raise MetadataException("XML metadata contains %d signatures - exactly 1 is required" % len(refs))
t = refs[0] # prevent wrapping attacks
except Exception, ex:
tb = traceback.format_exc()
print tb
log.error(ex)
return None
if post is not None:
t = post(t)
if validate:
if filter_invalid:
for e in t.findall('{%s}EntityDescriptor' % NS['md']):
if not schema().validate(e):
error = _e(schema().error_log, m=base_url)
log.debug("removing '%s': schema validation failed (%s)" % (e.get('entityID'), error))
e.getparent().remove(e)
self.fire(type=EVENT_DROP_ENTITY, url=base_url, entityID=e.get('entityID'), error=error)
else:
# Having removed the invalid entities this should now never happen...
schema().assertValid(t)