本文整理汇总了Python中src.utils.logger.log_trace函数的典型用法代码示例。如果您正苦于以下问题:Python log_trace函数的具体用法?Python log_trace怎么用?Python log_trace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log_trace函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: dataReceived
def dataReceived(self, data):
"""
This method will split the incoming data depending on if it
starts with IAC (a telnet command) or not. All other data will
be handled in line mode. Some clients also sends an erroneous
line break after IAC, which we must watch out for.
"""
#print "dataRcv (%s):" % data,
#try:
# for b in data:
# print ord(b),
# print ""
#except Exception, e:
# print str(e) + ":", str(data)
if data and data[0] == IAC or self.iaw_mode:
try:
#print "IAC mode"
super(TelnetProtocol, self).dataReceived(data)
if len(data) == 1:
self.iaw_mode = True
else:
self.iaw_mode = False
return
except Exception:
logger.log_trace()
# if we get to this point the command must end with a linebreak.
# We make sure to add it, to fix some clients messing this up.
data = data.rstrip("\r\n") + "\n"
#print "line data in:", repr(data)
StatefulTelnetProtocol.dataReceived(self, data)
开发者ID:abbacode,项目名称:avaloria,代码行数:31,代码来源:telnet.py
示例2: data_out
def data_out(self, string='', data=None):
"""
Data Evennia -> Player access hook.
data argument may be used depending on
the client-server implementation.
"""
if data:
# treat data?
pass
# string handling is similar to telnet
try:
string = utils.to_str(string, encoding=self.encoding)
nomarkup = False
raw = False
if type(data) == dict:
# check if we want escape codes to go through unparsed.
raw = data.get("raw", False)
# check if we want to remove all markup
nomarkup = data.get("nomarkup", False)
if raw:
self.client.lineSend(self.suid, string)
else:
self.client.lineSend(self.suid, parse_html(string, strip_ansi=nomarkup))
return
except Exception, e:
logger.log_trace()
开发者ID:BGCX262,项目名称:zsmud-git,代码行数:30,代码来源:webclient.py
示例3: dataReceived
def dataReceived(self, string):
"""
Method called when data is coming in over
the websocket connection.
Type of data is identified by a 3-character
prefix.
OOB - This is an Out-of-band instruction. If so,
the remaining string should be a json-packed
string on the form {oobfuncname: [args, ], ...}
any other prefix (or lack of prefix) is considered
plain text data, to be treated like a game
input command.
"""
if string[:3] == "OOB":
string = string[3:]
try:
oobdata = json.loads(string)
for (key, args) in oobdata.items():
#print "oob data in:", (key, args)
self.data_in(text=None, oob=(key, make_iter(args)))
except Exception:
log_trace("Websocket malformed OOB request: %s" % string)
else:
# plain text input
self.data_in(text=string)
开发者ID:henghu-bai,项目名称:evennia,代码行数:26,代码来源:websocket_client.py
示例4: dataReceived
def dataReceived(self, data):
"""
This method will split the incoming data depending on if it
starts with IAC (a telnet command) or not. All other data will
be handled in line mode. Some clients also sends an erroneous
line break after IAC, which we must watch out for.
OOB protocols (MSDP etc) already intercept subnegotiations
on their own, never entering this method. They will relay
their parsed data directly to self.data_in.
"""
if data and data[0] == IAC or self.iaw_mode:
try:
#print "IAC mode"
super(TelnetProtocol, self).dataReceived(data)
if len(data) == 1:
self.iaw_mode = True
else:
self.iaw_mode = False
return
except Exception, err1:
conv = ""
try:
for b in data:
conv += " " + repr(ord(b))
except Exception, err2:
conv = str(err2) + ":", str(data)
out = "Telnet Error (%s): %s (%s)" % (err1, data, conv)
logger.log_trace(out)
return
开发者ID:RetroRodent,项目名称:evennia,代码行数:32,代码来源:telnet.py
示例5: __delattr__
def __delattr__(self, propname):
"""
Transparently deletes data from the typeclass or dbobj by first searching on the typeclass,
secondly on the dbobj.db.
Will not allow deletion of properties stored directly on dbobj.
"""
if propname in PROTECTED:
string = "%s: '%s' is a protected attribute name."
string += " (protected: [%s])" % (", ".join(PROTECTED))
log_errmsg(string % (self.name, propname))
return
try:
_DA(self, propname)
except AttributeError:
# not on typeclass, try to delete on db/ndb
try:
dbobj = _GA(self, 'dbobj')
except AttributeError:
log_trace("This is probably due to an unsafe reload.")
return # ignore delete
try:
dbobj.del_attribute_raise(propname)
except AttributeError:
string = "Object: '%s' not found on %s(#%s), nor on its typeclass %s."
raise AttributeError(string % (propname, dbobj,
dbobj.dbid,
dbobj.typeclass_path,))
开发者ID:abbacode,项目名称:avaloria,代码行数:28,代码来源:typeclass.py
示例6: __setattr__
def __setattr__(self, propname, value):
"""
Transparently save data to the dbobj object in
all situations. Note that this does not
necessarily mean storing it to the database
unless data is stored into a propname
corresponding to a field on ObjectDB model.
"""
#print "set %s -> %s" % (propname, value)
if propname in PROTECTED:
string = "%s: '%s' is a protected attribute name."
string += " (protected: [%s])" % (", ".join(PROTECTED))
log_errmsg(string % (self.name, propname))
return
try:
dbobj = _GA(self, 'dbobj')
except AttributeError:
dbobj = None
log_trace("This is probably due to an unsafe reload.")
if dbobj:
try:
# only set value on propname if propname already exists
# on dbobj. __getattribute__ will raise attribute error otherwise.
_GA(dbobj, propname)
_SA(dbobj, propname, value)
except AttributeError:
#XXX deprecated
dbobj.set_attribute(propname, value)
else:
_SA(self, propname, value)
开发者ID:abbacode,项目名称:avaloria,代码行数:31,代码来源:typeclass.py
示例7: __getattribute__
def __getattribute__(self, propname):
"""
Change the normal property access to
transparently include the properties on
self.dbobj. Note that dbobj properties have
priority, so if you define a same-named
property on the class, it will NOT be
accessible through getattr.
"""
if propname == 'dbobj':
return _GA(self, 'dbobj')
if propname.startswith('__') and propname.endswith('__'):
# python specials are parsed as-is (otherwise things like
# isinstance() fail to identify the typeclass)
return _GA(self, propname)
#print "get %s (dbobj:%s)" % (propname, type(dbobj))
try:
return _GA(self, propname)
except AttributeError:
try:
dbobj = _GA(self, 'dbobj')
except AttributeError:
log_trace("Typeclass CRITICAL ERROR! dbobj not found for Typeclass %s!" % self)
raise
try:
return _GA(dbobj, propname)
except AttributeError:
try:
#XXX deprecated
return _GA(dbobj,"get_attribute_raise")(propname)
except AttributeError:
string = "Object: '%s' not found on %s(#%s), nor on its typeclass %s."
raise AttributeError(string % (propname, dbobj, _GA(dbobj, "dbid"), _GA(dbobj, "typeclass_path")))
开发者ID:abbacode,项目名称:avaloria,代码行数:35,代码来源:typeclass.py
示例8: _get_local_obj_cmdsets
def _get_local_obj_cmdsets(obj, obj_cmdset):
"Object-level cmdsets"
# Gather cmdsets from location, objects in location or carried
local_obj_cmdsets = [None]
try:
location = obj.location
except Exception:
location = None
if location and not obj_cmdset.no_objs:
# Gather all cmdsets stored on objects in the room and
# also in the caller's inventory and the location itself
local_objlist = yield (location.contents_get(exclude=obj.dbobj) +
obj.contents +
[location])
for lobj in local_objlist:
try:
# call hook in case we need to do dynamic changing to cmdset
_GA(lobj, "at_cmdset_get")()
except Exception:
logger.log_trace()
# the call-type lock is checked here, it makes sure a player
# is not seeing e.g. the commands on a fellow player (which is why
# the no_superuser_bypass must be True)
local_obj_cmdsets = \
yield [lobj.cmdset.current for lobj in local_objlist
if (lobj.cmdset.current and
lobj.locks.check(caller, 'call', no_superuser_bypass=True))]
for cset in local_obj_cmdsets:
#This is necessary for object sets, or we won't be able to
# separate the command sets from each other in a busy room.
cset.old_duplicates = cset.duplicates
cset.duplicates = True
returnValue(local_obj_cmdsets)
开发者ID:AHecky3,项目名称:evennia,代码行数:33,代码来源:cmdhandler.py
示例9: _create_character
def _create_character(session, new_player, typeclass, start_location, home, permissions):
"""
Helper function, creates a character based on a player's name.
This is meant for Guest and MULTISESSION_MODE < 2 situations.
"""
try:
if not start_location:
start_location = home # fallback
new_character = create.create_object(typeclass, key=new_player.key,
location=start_location, home=home,
permissions=permissions)
# set playable character list
new_player.db._playable_characters.append(new_character)
# allow only the character itself and the player to puppet this character (and Immortals).
new_character.locks.add("puppet:id(%i) or pid(%i) or perm(Immortals) or pperm(Immortals)" %
(new_character.id, new_player.id))
# If no description is set, set a default description
if not new_character.db.desc:
new_character.db.desc = "This is a Player."
# We need to set this to have @ic auto-connect to this character
new_player.db._last_puppet = new_character
except Exception, e:
session.msg("There was an error creating the Character:\n%s\n If this problem persists, contact an admin." % e)
logger.log_trace()
return False
开发者ID:AHecky3,项目名称:evennia,代码行数:27,代码来源:unloggedin.py
示例10: create_help_entry
def create_help_entry(key, entrytext, category="General", locks=None):
"""
Create a static help entry in the help database. Note that Command
help entries are dynamic and directly taken from the __doc__ entries
of the command. The database-stored help entries are intended for more
general help on the game, more extensive info, in-game setting information
and so on.
"""
global _HelpEntry
if not _HelpEntry:
from src.help.models import HelpEntry as _HelpEntry
try:
new_help = _HelpEntry()
new_help.key = key
new_help.entrytext = entrytext
new_help.help_category = category
if locks:
new_help.locks.add(locks)
new_help.save()
return new_help
except IntegrityError:
string = "Could not add help entry: key '%s' already exists." % key
logger.log_errmsg(string)
return None
except Exception:
logger.log_trace()
return None
开发者ID:Mackyjin,项目名称:evennia,代码行数:28,代码来源:create.py
示例11: _parse_lockstring
def _parse_lockstring(self, storage_lockstring):
"""
Helper function. This is normally only called when the
lockstring is cached and does preliminary checking. locks are
stored as a string 'atype:[NOT] lock()[[ AND|OR [NOT] lock()[...]];atype...
"""
locks = {}
if not storage_lockstring:
return locks
duplicates = 0
elist = [] # errors
wlist = [] # warnings
for raw_lockstring in storage_lockstring.split(';'):
lock_funcs = []
try:
access_type, rhs = (part.strip() for part in raw_lockstring.split(':', 1))
except ValueError:
logger.log_trace()
return locks
# parse the lock functions and separators
funclist = _RE_FUNCS.findall(rhs)
evalstring = rhs
for pattern in ('AND', 'OR', 'NOT'):
evalstring = re.sub(r"\b%s\b" % pattern, pattern.lower(), evalstring)
nfuncs = len(funclist)
for funcstring in funclist:
funcname, rest = (part.strip().strip(')') for part in funcstring.split('(', 1))
func = _LOCKFUNCS.get(funcname, None)
if not callable(func):
elist.append(_("Lock: function '%s' is not available.") % funcstring)
continue
args = list(arg.strip() for arg in rest.split(',') if arg and not '=' in arg)
kwargs = dict([arg.split('=', 1) for arg in rest.split(',') if arg and '=' in arg])
lock_funcs.append((func, args, kwargs))
evalstring = evalstring.replace(funcstring, '%s')
if len(lock_funcs) < nfuncs:
continue
try:
# purge the eval string of any superfluous items, then test it
evalstring = " ".join(_RE_OK.findall(evalstring))
eval(evalstring % tuple(True for func in funclist), {}, {})
except Exception:
elist.append(_("Lock: definition '%s' has syntax errors.") % raw_lockstring)
continue
if access_type in locks:
duplicates += 1
wlist.append(_("Lock: access type '%(access_type)s' changed from '%(source)s' to '%(goal)s' " % \
{"access_type":access_type, "source":locks[access_type][2], "goal":raw_lockstring}))
locks[access_type] = (evalstring, tuple(lock_funcs), raw_lockstring)
if wlist and self.log_obj:
# a warning text was set, it's not an error, so only report if log_obj is available.
self._log_error("\n".join(wlist))
if elist:
# an error text was set, raise exception.
raise LockException("\n".join(elist))
# return the gathered locks in an easily executable form
return locks
开发者ID:BGCX262,项目名称:zsmud-git,代码行数:59,代码来源:lockhandler.py
示例12: _stop_task
def _stop_task(self):
"stop task runner"
try:
#print "stopping twisted task:", id(self.ndb.twisted_task), self.obj
if self.ndb.twisted_task and self.ndb.twisted_task.running:
self.ndb.twisted_task.stop()
except Exception:
logger.log_trace()
开发者ID:Aumnren,项目名称:evennia,代码行数:8,代码来源:scripts.py
示例13: _step_task
def _step_task(self):
"step task"
try:
d = maybeDeferred(self._step_succ_callback)
d.addErrback(self._step_err_callback)
return d
except Exception:
logger.log_trace()
开发者ID:Aumnren,项目名称:evennia,代码行数:8,代码来源:scripts.py
示例14: _callback
def _callback(self, oobhandler, sessions):
"See original for more info"
for key, (_, args, kwargs) in self.subscriptions.items():
session = sessions.session_from_sessid(kwargs.get("sessid"))
try:
oobhandler.execute_cmd(session, kwargs.get("func_key"), *args, **kwargs)
except Exception:
logger.log_trace()
开发者ID:Mackyjin,项目名称:evennia,代码行数:8,代码来源:oobhandler.py
示例15: msdp_cmd_reset
def msdp_cmd_reset(self, arg):
"""
The reset command resets a variable to its initial state.
"""
try:
MSDP_REPORTABLE[arg](reset=True)
except Exception:
logger.log_trace()
开发者ID:BGCX262,项目名称:zsmud-git,代码行数:8,代码来源:msdp.py
示例16: save
def save():
"Force save of time. This is called by server when shutting down/reloading."
from src.scripts.models import ScriptDB
try:
script = ScriptDB.objects.get(db_key=GAMETIME_SCRIPT_NAME)
script.at_repeat()
except Exception:
from src.utils import logger
logger.log_trace()
开发者ID:AHecky3,项目名称:evennia,代码行数:9,代码来源:gametime.py
示例17: import_cmdset
def import_cmdset(python_path, cmdsetobj, emit_to_obj=None, no_logging=False):
"""
This helper function is used by the cmdsethandler to load a cmdset
instance from a python module, given a python_path. It's usually accessed
through the cmdsethandler's add() and add_default() methods.
python_path - This is the full path to the cmdset object.
cmdsetobj - the database object/typeclass on which this cmdset is to be
assigned (this can be also channels and exits, as well as players
but there will always be such an object)
emit_to_obj - if given, error is emitted to this object (in addition
to logging)
no_logging - don't log/send error messages. This can be useful
if import_cmdset is just used to check if this is a
valid python path or not.
function returns None if an error was encountered or path not found.
"""
try:
try:
#print "importing %s: _CACHED_CMDSETS=%s" % (python_path, _CACHED_CMDSETS)
wanted_cache_key = python_path
cmdsetclass = _CACHED_CMDSETS.get(wanted_cache_key, None)
errstring = ""
if not cmdsetclass:
#print "cmdset '%s' not in cache. Reloading %s on %s." % (wanted_cache_key, python_path, cmdsetobj)
# Not in cache. Reload from disk.
modulepath, classname = python_path.rsplit('.', 1)
module = __import__(modulepath, fromlist=[True])
cmdsetclass = module.__dict__[classname]
_CACHED_CMDSETS[wanted_cache_key] = cmdsetclass
#instantiate the cmdset (and catch its errors)
if callable(cmdsetclass):
cmdsetclass = cmdsetclass(cmdsetobj)
return cmdsetclass
except ImportError:
errstring = _("Error loading cmdset: Couldn't import module '%s'.")
errstring = errstring % modulepath
raise
except KeyError:
errstring = _("Error in loading cmdset: No cmdset class '%(classname)s' in %(modulepath)s.")
errstring = errstring % {"classname": classname,
"modulepath": modulepath}
raise
except Exception:
errstring = _("Compile/Run error when loading cmdset '%s'. Error was logged.")
errstring = errstring % (python_path)
raise
except Exception:
# returning an empty error cmdset
if not no_logging:
logger.log_trace(errstring)
if emit_to_obj and not ServerConfig.objects.conf("server_starting_mode"):
object.__getattribute__(emit_to_obj, "msg")(errstring)
err_cmdset = _ErrorCmdSet()
err_cmdset.errmessage = errstring
return err_cmdset
开发者ID:Mackyjin,项目名称:evennia,代码行数:57,代码来源:cmdsethandler.py
示例18: update
def update(self, fieldname, new_value):
"""
Called by the field when it updates to a new value
"""
for tracker in self.tracktargets[fieldname].values():
try:
tracker.update(new_value)
except Exception:
logger.log_trace()
开发者ID:Aumnren,项目名称:evennia,代码行数:9,代码来源:oobhandler.py
示例19: at_repeat
def at_repeat(self):
"""
Loops through all subs, calling their given function
"""
for func, args, kwargs in self.subs:
try:
func(*args, **kwargs)
except Exception:
logger.log_trace()
开发者ID:BGCX262,项目名称:zsmud-git,代码行数:9,代码来源:oobhandler.py
示例20: msdp_cmd_report
def msdp_cmd_report(self, *arg):
"""
The report command instructs the server to start reporting a
reportable variable to the client.
"""
try:
MSDP_REPORTABLE[arg](report=True)
except Exception:
logger.log_trace()
开发者ID:BGCX262,项目名称:zsmud-git,代码行数:9,代码来源:msdp.py
注:本文中的src.utils.logger.log_trace函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论