当前位置: 首页>>代码示例>>Python>>正文


Python logger.log_errmsg函数代码示例

本文整理汇总了Python中src.utils.logger.log_errmsg函数的典型用法代码示例。如果您正苦于以下问题:Python log_errmsg函数的具体用法?Python log_errmsg怎么用?Python log_errmsg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了log_errmsg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __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

示例2: create_connection

def create_connection(channel, irc_network, irc_port, irc_channel, irc_bot_nick):
    """
    This will create a new IRC<->channel connection.
    """
    if not type(channel) == Channel:
        new_channel = Channel.objects.filter(db_key=channel)
        if not new_channel:
            logger.log_errmsg(_("Cannot attach IRC<->Evennia: Evennia Channel '%s' not found") % channel)
            return False
        channel = new_channel[0]
    key = build_connection_key(channel, irc_network, irc_port, irc_channel, irc_bot_nick)

    old_conns = ExternalChannelConnection.objects.filter(db_external_key=key)
    if old_conns:
        return False
    config = "%s|%s|%s|%s" % (irc_network, irc_port, irc_channel, irc_bot_nick)
    # how the channel will be able to contact this protocol
    send_code =  "from src.comms.irc import IRC_CHANNELS\n"
    send_code += "matched_ircs = [irc for irc in IRC_CHANNELS if irc.factory.key == '%s']\n" % key
    send_code += "[irc.msg_irc(message, senders=[self]) for irc in matched_ircs]\n"
    conn = ExternalChannelConnection(db_channel=channel, db_external_key=key, db_external_send_code=send_code,
                                     db_external_config=config)
    conn.save()

    # connect
    connect_to_irc(conn)
    return True
开发者ID:OthersGames,项目名称:asylum-jam,代码行数:27,代码来源:irc.py

示例3: __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

示例4: 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

示例5: __setattr__

 def __setattr__(self, propname, value):
     """
     Transparently save data. Use property on Typeclass only if
     that property is already defined, otherwise relegate to the
     dbobj object in all situations. Note that this does not
     necessarily mean storing it to the database.
     """
     #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:
         _GA(self, propname)
         _SA(self, propname, value)
     except AttributeError:
         try:
             dbobj = _GA(self, 'dbobj')
         except AttributeError:
             dbobj = None
         if dbobj:
             _SA(dbobj, propname, value)
         else:
             # only as a last resort do we save on the typeclass object
             _SA(self, propname, value)
开发者ID:AHecky3,项目名称:evennia,代码行数:26,代码来源:typeclass.py

示例6: get_objs_with_db_property_value

    def get_objs_with_db_property_value(self, property_name, property_value, candidates=None, typeclasses=None):
        """
        Returns all objects having a given db field property.
        candidates - list of objects to search
        typeclasses - list of typeclass-path strings to restrict matches with
        """
        if isinstance(property_value, basestring):
            property_value = to_unicode(property_value)
        if isinstance(property_name, basestring):
            if not property_name.startswith("db_"):
                property_name = "db_%s" % property_name
        if hasattr(property_value, "dbobj"):
            property_value = property_value.dbobj
        querykwargs = {property_name: property_value}
        cand_restriction = (
            candidates != None and Q(pk__in=[_GA(obj, "id") for obj in make_iter(candidates) if obj]) or Q()
        )
        type_restriction = typeclasses and Q(db_typeclass_path__in=make_iter(typeclasses)) or Q()
        try:
            return list(self.filter(cand_restriction & type_restriction & Q(**querykwargs)))
        except exceptions.FieldError:
            return []
        except ValueError:
            from src.utils import logger

            logger.log_errmsg(
                "The property '%s' does not support search criteria of the type %s."
                % (property_name, type(property_value))
            )
            return []
开发者ID:no-space,项目名称:evennia,代码行数:30,代码来源:manager.py

示例7: __value_set

 def __value_set(self, value):
     "Setter. Allows for self.value = value"
     if utils.has_parent('django.db.models.base.Model', value):
         # we have to protect against storing db objects.
         logger.log_errmsg("ServerConfig cannot store db objects! (%s)" % value)
         return
     self.db_value = pickle.dumps(value)
     self.save()
开发者ID:reddcoin-project,项目名称:ReddConnect,代码行数:8,代码来源:models.py

示例8: _log_error

 def _log_error(self, message):
     "Try to log errors back to object"
     if self.log_obj and hasattr(self.log_obj, 'msg'):
         self.log_obj.msg(message)
     elif hasattr(self.obj, 'msg'):
         self.obj.msg(message)
     else:
         logger.log_errmsg("%s: %s" % (self.obj, message))
开发者ID:TheWhiteOx,项目名称:evennia,代码行数:8,代码来源:lockhandler.py

示例9: _save_tree

 def _save_tree(self):
     "recursively traverse back up the tree, save when we reach the root"
     if self._parent:
         self._parent._save_tree()
     elif self._db_obj:
         self._db_obj.value = self
     else:
         logger.log_errmsg("_SaverMutable %s has no root Attribute to save to." % self)
开发者ID:TheWhiteOx,项目名称:evennia,代码行数:8,代码来源:dbserialize.py

示例10: import_cmdset

def import_cmdset(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.
    path - This is the full path to the cmdset object on python dot-form
    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.
    """

    python_paths = [path] + ["%s.%s" % (prefix, path)
                                    for prefix in _CMDSET_PATHS]
    errstring = ""
    for python_path in python_paths:
        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
        except KeyError:
            errstring += _("Error in loading cmdset: No cmdset class '%(classname)s' in %(modulepath)s.")
            errstring = errstring % {"classname": classname,
                                     "modulepath": modulepath}
        except Exception:
            errstring += _("Compile/Run error when loading cmdset '%s'. Error was logged.")
            errstring = errstring % (python_path)

    if errstring:
        # returning an empty error cmdset
        if not no_logging:
            logger.log_errmsg(errstring)
            if emit_to_obj and not ServerConfig.objects.conf("server_starting_mode"):
                emit_to_obj.msg(errstring)
        err_cmdset = _ErrorCmdSet()
        err_cmdset.errmessage = errstring
        return err_cmdset
开发者ID:reddcoin-project,项目名称:ReddConnect,代码行数:58,代码来源:cmdsethandler.py

示例11: alarm

 def alarm(codestring):
     "store the code of too-long-running scripts"
     global _LOGGER
     if not _LOGGER:
         from src.utils import logger as _LOGGER
     self.timedout_codestrings.append(codestring)
     err = "Evlang code '%s' exceeded allowed execution time (>%ss)." % (codestring, timeout)
     _LOGGER.log_errmsg("EVLANG time exceeded: caller: %s, scripter: %s, code: %s" % (caller, scripter, codestring))
     if not self.msg(err, scripter, caller):
         raise EvlangError(err)
开发者ID:OthersGames,项目名称:asylum-jam,代码行数:10,代码来源:evlang.py

示例12: func

 def func(err, *args, **kwargs):
     err.trap(Exception)
     err = err.getErrorMessage()
     if use_timeout and err == _PROC_ERR:
         err = "Process took longer than %ss and timed out." % use_timeout
     if f:
         return f(err, *args, **kwargs)
     else:
         err = "Error reported from subprocess: '%s'" % err
         logger.log_errmsg(err)
开发者ID:n0q,项目名称:evennia,代码行数:10,代码来源:python_procpool.py

示例13: _step_err_callback

 def _step_err_callback(self, e):
     "callback for runner errors"
     cname = self.__class__.__name__
     estring = _("Script %(key)s(#%(dbid)i) of type '%(cname)s': at_repeat() error '%(err)s'.") % \
                {"key":self.key, "dbid":self.dbid, "cname":cname, "err":e.getErrorMessage()}
     try:
         self.dbobj.db_obj.msg(estring)
     except Exception:
         pass
     logger.log_errmsg(estring)
开发者ID:BGCX262,项目名称:zsmud-git,代码行数:10,代码来源:scripts.py

示例14: _cache_lockfuncs

def _cache_lockfuncs():
    "Updates the cache."
    global _LOCKFUNCS
    _LOCKFUNCS = {}
    for modulepath in settings.LOCK_FUNC_MODULES:
        modulepath = utils.pypath_to_realpath(modulepath)
        mod = utils.mod_import(modulepath)
        if mod:
            for tup in (tup for tup in inspect.getmembers(mod) if callable(tup[1])):
                _LOCKFUNCS[tup[0]] = tup[1]
        else:
            logger.log_errmsg("Couldn't load %s from PERMISSION_FUNC_MODULES." % modulepath)
开发者ID:TheWhiteOx,项目名称:evennia,代码行数:12,代码来源:lockhandler.py

示例15: add

    def add(self, scriptclass, key=None, autostart=True):
        """
        Add an script to this object.

        scriptclass - either a class object
             inheriting from Script, an instantiated script object
             or a python path to such a class object.
        key - optional identifier for the script (often set in script definition)
        autostart - start the script upon adding it
        """
        script = create.create_script(scriptclass, key=key, obj=self.obj, autostart=autostart)
        if not script:
            logger.log_errmsg("Script %s could not be created and/or started." % scriptclass)
            return False
        return True
开发者ID:BGCX262,项目名称:zsmud-git,代码行数:15,代码来源:scripthandler.py


注:本文中的src.utils.logger.log_errmsg函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。