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


Python Syslog.syslog函数代码示例

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


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

示例1: __init__

    def __init__(self, mlist, param):
        self._param = param
        self.__mlist = mlist
        self._members = None
        self._member_passwd = {}
        self._member_names = {}
        self._updatetime = 0
        # define the table and standard condition reflecting listname
        self._table = param["mailman_table"]
        self._where = "listname = '%s'" % (self.__mlist.internal_name())

        # define query for session management
        self._cookiename = param["cookiename"]
        self._queryCookieMail = param["queryCookieMail"]
        self._queryCookieId = param["queryCookieId"]
        self._queryIsAdmin = param["queryIsAdmin"]
        self._queryIsSiteAdmin = param["queryIsSiteAdmin"]
        self._queryIsMonitoring = param["queryIsMonitoring"]

        self.__db_connect__()
        if mm_cfg.MYSQL_MEMBER_DB_VERBOSE:
            # Message to indicate successful init.
            message = "DBMemberships " + "$Revision: 1.69 $ initialized with host: %s (%s)" % (
                mm_cfg.connection.get_host_info(),
                mm_cfg.connection.get_server_info(),
            )
            syslog("error", message)
            syslog("mysql", message)

        # add a cache memory
        self._cache = {}
        self._cachedate = 0
开发者ID:Codendi,项目名称:mailman-codendi-ff,代码行数:32,代码来源:ExternalConnector.py

示例2: main

def main():
    doc = Document()
    doc.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE)

    cgidata = cgi.FieldStorage()
    parts = Utils.GetPathPieces()
    if parts:
        # Bad URL specification
        title = _('Bad URL specification')
        doc.SetTitle(title)
        doc.AddItem(
            Header(3, Bold(FontAttr(title, color='#ff0000', size='+2'))))
        syslog('error', 'Bad URL specification: %s', parts)
    elif cgidata.has_key('doit'):
        # We must be processing the list creation request
        process_request(doc, cgidata)
    elif cgidata.has_key('clear'):
        request_creation(doc)
    else:
        # Put up the list creation request form
        request_creation(doc)
    doc.AddItem('<hr>')
    # Always add the footer and print the document
    doc.AddItem(_('Return to the ') +
                Link(Utils.ScriptURL('listinfo'),
                     _('general list overview')).Format())
    doc.AddItem(_('<br>Return to the ') +
                Link(Utils.ScriptURL('admin'),
                     _('administrative list overview')).Format())
    doc.AddItem(MailmanLogo())
    print doc.Format()
开发者ID:EdLeafe,项目名称:mailman_config,代码行数:31,代码来源:create.py

示例3: decorate

def decorate(mlist, template, what, extradict=None):
    # `what' is just a descriptive phrase used in the log message
    #
    # BAW: We've found too many situations where Python can be fooled into
    # interpolating too much revealing data into a format string.  For
    # example, a footer of "% silly %(real_name)s" would give a header
    # containing all list attributes.  While we've previously removed such
    # really bad ones like `password' and `passwords', it's much better to
    # provide a whitelist of known good attributes, then to try to remove a
    # blacklist of known bad ones.
    d = SafeDict({'real_name'     : mlist.real_name,
                  'list_name'     : mlist.internal_name(),
                  # For backwards compatibility
                  '_internal_name': mlist.internal_name(),
                  'host_name'     : mlist.host_name,
                  'web_page_url'  : mlist.web_page_url,
                  'description'   : mlist.description,
                  'info'          : mlist.info,
                  'cgiext'        : mm_cfg.CGIEXT,
                  })
    if extradict is not None:
        d.update(extradict)
    # Using $-strings?
    if getattr(mlist, 'use_dollar_strings', 0):
        template = Utils.to_percent(template)
    # Interpolate into the template
    try:
        text = re.sub(r'(?m)(?<!^--) +(?=\n)', '',
                      re.sub(r'\r\n', r'\n', template % d))
    except (ValueError, TypeError), e:
        syslog('error', 'Exception while calculating %s:\n%s', what, e)
        text = template
开发者ID:EdLeafe,项目名称:mailman_config,代码行数:32,代码来源:Decorate.py

示例4: _dopipeline

 def _dopipeline(self, mlist, msg, msgdata, pipeline):
     while pipeline:
         handler = pipeline.pop(0)
         modname = 'Mailman.Handlers.' + handler
         __import__(modname)
         try:
             pid = os.getpid()
             sys.modules[modname].process(mlist, msg, msgdata)
             # Failsafe -- a child may have leaked through.
             if pid <> os.getpid():
                 syslog('error', 'child process leaked thru: %s', modname)
                 os._exit(1)
         except Errors.DiscardMessage:
             # Throw the message away; we need do nothing else with it.
             syslog('vette', 'Message discarded, msgid: %s',
                    msg.get('message-id', 'n/a'))
             return 0
         except Errors.HoldMessage:
             # Let the approval process take it from here.  The message no
             # longer needs to be queued.
             return 0
         except Errors.RejectMessage, e:
             mlist.BounceMessage(msg, msgdata, e)
             return 0
         except:
开发者ID:EmilyDirsh,项目名称:Paperboy,代码行数:25,代码来源:IncomingRunner.py

示例5: report_submission

def report_submission(msgid, message, inprogress=False):
    """
    :return: URL of the HTML document
    """
    if not mm_cfg.POST_TRACKING_URLBASE or not mm_cfg.POST_TRACKING_PATH:
        return ""
    sha1hex = sha_new(msgid).hexdigest()
    fname = "%s.html" % sha1hex
    tmpname = ".%s.tmp" % sha1hex
    fullfname = os.path.join(mm_cfg.POST_TRACKING_PATH, fname)
    tmpname = os.path.join(mm_cfg.POST_TRACKING_PATH, tmpname)
    doc = """<html><head><title>Mailman tracker</title>%s</head><body>
    <h3>Message ID %s</h3>
    <p>
    %s
    </p>
    </body></html>
    """
    meta = '<meta http-equiv="refresh" content="30"/>' if inprogress else ""

    try:
        with open(tmpname, "w") as reportfile:
            reportfile.write(doc % (meta, websafe(msgid), message))
        os.rename(tmpname, fullfname)
    except OSError, e:
        syslog("error", "report_submission failed: %s", e)
        return ""
开发者ID:jurov,项目名称:gnu-mailman,代码行数:27,代码来源:Utils.py

示例6: db_export

def db_export(mlist):
    try:
        rootdir = mlist.archive_dir()
        conn = db_conn(mlist)
        return _db_export(conn,rootdir)
    except Exception,e:
        syslog('gpg','%s' % e)
开发者ID:jurov,项目名称:gnu-mailman,代码行数:7,代码来源:PatchDB.py

示例7: request_edit

    def request_edit (self):
        self._ml = self.all_mls[self.ln]
        err = self.errcheck(action='edit')
        if err:
            return err

        # We've got all the data we need, so go ahead and try to edit the
        # list See admin.py for why we need to set up the signal handler.

        try:
            signal.signal(signal.SIGTERM, self.sigterm_handler)

            self.ml.Lock()
            self.set_ml_params()
            self.edit_members()
            self.set_ml_owners()
            self.ml.Save()
            syslog('sso', 'Successfully modified list config: %s' % self.ln)
        finally:
            # Now be sure to unlock the list.  It's okay if we get a signal
            # here because essentially, the signal handler will do the same
            # thing.  And unlocking is unconditional, so it's not an error if
            # we unlock while we're already unlocked.
            self.ml.Unlock()

        return None
开发者ID:skarra,项目名称:GNU-Mailman-SSO,代码行数:26,代码来源:ctl.py

示例8: bulkdeliver

def bulkdeliver(mlist, msg, msgdata, envsender, failures, conn):
    # Do some final cleanup of the message header.  Start by blowing away
    # any the Sender: and Errors-To: headers so remote MTAs won't be
    # tempted to delivery bounces there instead of our envelope sender
    #
    # BAW An interpretation of RFCs 2822 and 2076 could argue for not touching
    # the Sender header at all.  Brad Knowles points out that MTAs tend to
    # wipe existing Return-Path headers, and old MTAs may still honor
    # Errors-To while new ones will at worst ignore the header.
    del msg['sender']
    del msg['errors-to']
    msg['Sender'] = envsender
    msg['Errors-To'] = envsender
    # Get the plain, flattened text of the message, sans unixfrom
    msgtext = msg.as_string()
    refused = {}
    recips = msgdata['recips']
    msgid = msg['message-id']
    try:
        # Send the message
        refused = conn.sendmail(envsender, recips, msgtext)
    except smtplib.SMTPRecipientsRefused, e:
        syslog('smtp-failure', 'All recipients refused: %s, msgid: %s',
               e, msgid)
        refused = e.recipients
开发者ID:jwasinger,项目名称:mailman_cas,代码行数:25,代码来源:SMTPDirect.py

示例9: matches_p

def matches_p(sender, nonmembers, listname):
    # First strip out all the regular expressions and listnames
    plainaddrs = [addr for addr in nonmembers if not (addr.startswith('^')
                                                 or addr.startswith('@'))]
    addrdict = Utils.List2Dict(plainaddrs, foldcase=1)
    if addrdict.has_key(sender):
        return 1
    # Now do the regular expression matches
    for are in nonmembers:
        if are.startswith('^'):
            try:
                cre = re.compile(are, re.IGNORECASE)
            except re.error:
                continue
            if cre.search(sender):
                return 1
        elif are.startswith('@'):
            # XXX Needs to be reviewed for [email protected] names.
            try:
                mname = are[1:].lower().strip()
                if mname == listname:
                    # don't reference your own list
                    syslog('error',
                        '*_these_nonmembers in %s references own list',
                        listname)
                else:
                    mother = MailList(mname, lock=0)
                    if mother.isMember(sender):
                        return 1
            except Errors.MMUnknownListError:
                syslog('error',
                  '*_these_nonmembers in %s references non-existent list %s',
                  listname, mname)
    return 0
开发者ID:EdLeafe,项目名称:mailman_config,代码行数:34,代码来源:Moderate.py

示例10: __handlesubscription

   def __handlesubscription(self, record, value, comment):
       stime, addr, fullname, password, digest, lang = record
       if value == mm_cfg.DEFER:
           return DEFER
       elif value == mm_cfg.DISCARD:
           syslog('vette', '%s: discarded subscription request from %s',
                  self.internal_name(), addr)
       elif value == mm_cfg.REJECT:
           self.__refuse(_('Subscription request'), addr,
                         comment or _('[No reason given]'),
                         lang=lang)
           syslog('vette', """%s: rejected subscription request from %s
tReason: %s""", self.internal_name(), addr, comment or '[No reason given]')
       else:
           # subscribe
           assert value == mm_cfg.SUBSCRIBE
           try:
               userdesc = UserDesc(addr, fullname, password, digest, lang)
               self.ApprovedAddMember(userdesc, whence='via admin approval')
           except Errors.MMAlreadyAMember:
               # User has already been subscribed, after sending the request
               pass
           # TBD: disgusting hack: ApprovedAddMember() can end up closing
           # the request database.
           self.__opendb()
       return REMOVE
开发者ID:bdraco,项目名称:mailman,代码行数:26,代码来源:ListAdmin.py

示例11: HoldUnsubscription

 def HoldUnsubscription(self, addr):
     # Assure the database is open for writing
     self.__opendb()
     # Get the next unique id
     id = self.__nextid()
     # All we need to do is save the unsubscribing address
     self.__db[id] = (UNSUBSCRIPTION, addr)
     syslog('vette', '%s: held unsubscription request from %s',
            self.internal_name(), addr)
     # Possibly notify the administrator of the hold
     if self.admin_immed_notify:
         realname = self.real_name
         subject = _(
             'New unsubscription request from %(realname)s by %(addr)s')
         text = Utils.maketext(
             'unsubauth.txt',
             {'username'   : addr,
              ## cpanel patch
              'listname'   : self.real_name,
              'hostname'   : self.host_name,
              'admindb_url': self.GetScriptURL('admindb', absolute=1),
              }, mlist=self)
         # This message should appear to come from the <list>-owner so as
         # to avoid any useless bounce processing.
         owneraddr = self.GetOwnerEmail()
         msg = Message.UserNotification(owneraddr, owneraddr, subject, text,
                                        self.preferred_language)
         msg.send(self, **{'tomoderators': 1})
开发者ID:bdraco,项目名称:mailman,代码行数:28,代码来源:ListAdmin.py

示例12: do_discard

def do_discard(mlist, msg):
    sender = msg.get_sender()
    # Do we forward auto-discards to the list owners?
    if mlist.forward_auto_discards:
        lang = mlist.preferred_language
        varhelp = '%s/?VARHELP=privacy/sender/discard_these_nonmembers' % \
                  mlist.GetScriptURL('admin', absolute=1)
        nmsg = Message.UserNotification(mlist.GetOwnerEmail(),
                                        mlist.GetBouncesEmail(),
                                        _('Auto-discard notification'),
                                        lang=lang)
        nmsg.set_type('multipart/mixed')
        text = MIMEText(Utils.wrap(_(
            'The attached message has been automatically discarded.')),
                        _charset=Utils.GetCharSet(lang))
        nmsg.attach(text)

        decrypted = msg.get('X-Mailman-SLS-decrypted', '').lower()
        if decrypted == 'yes':
            syslog('gpg',
 'forwarding only headers of message from %s to listmaster to notify discard since message was decrypted',
 sender)
            msgtext = msg.as_string()
            (header, body) = msgtext.split("\n\n", 1)
            nmsg.attach(MIMEText(header))
        else:
            nmsg.attach(MIMEMessage(msg))

        nmsg.send(mlist)
    # Discard this sucker
    raise Errors.DiscardMessage
开发者ID:jurov,项目名称:gnu-mailman,代码行数:31,代码来源:Moderate.py

示例13: main

def main():
    doc = Document()
    doc.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE)

    cgidata = cgi.FieldStorage()
    parts = Utils.GetPathPieces()

    if not parts:
        # Bad URL specification
        title = _('Bad URL specification')
        doc.SetTitle(title)
        doc.AddItem(
            Header(3, Bold(FontAttr(title, color='#ff0000', size='+2'))))
        doc.AddItem('<hr>')
        doc.AddItem(MailmanLogo())
        print doc.Format()
        syslog('error', 'Bad URL specification: %s', parts)
        return
        
    listname = parts[0].lower()
    try:
        mlist = MailList.MailList(listname, lock=0)
    except Errors.MMListError, e:
        # Avoid cross-site scripting attacks
        safelistname = Utils.websafe(listname)
        title = _('No such list <em>%(safelistname)s</em>')
        doc.SetTitle(title)
        doc.AddItem(
            Header(3,
                   Bold(FontAttr(title, color='#ff0000', size='+2'))))
        doc.AddItem('<hr>')
        doc.AddItem(MailmanLogo())
        print doc.Format()
        syslog('error', 'No such list "%s": %s\n', listname, e)
        return
开发者ID:jwasinger,项目名称:mailman_cas,代码行数:35,代码来源:rmlist.py

示例14: Secure_MakeRandomPassword

def Secure_MakeRandomPassword(length):
    bytesread = 0
    bytes = []
    fd = None
    try:
        while bytesread < length:
            try:
                # Python 2.4 has this on available systems.
                newbytes = os.urandom(length - bytesread)
            except (AttributeError, NotImplementedError):
                if fd is None:
                    try:
                        fd = os.open('/dev/urandom', os.O_RDONLY)
                    except OSError, e:
                        if e.errno <> errno.ENOENT:
                            raise
                        # We have no available source of cryptographically
                        # secure random characters.  Log an error and fallback
                        # to the user friendly passwords.
                        syslog('error',
                               'urandom not available, passwords not secure')
                        return UserFriendly_MakeRandomPassword(length)
                newbytes = os.read(fd, length - bytesread)
            bytes.append(newbytes)
            bytesread += len(newbytes)
        s = base64.encodestring(EMPTYSTRING.join(bytes))
        # base64 will expand the string by 4/3rds
        return s.replace('\n', '')[:length]
开发者ID:bdraco,项目名称:mailman,代码行数:28,代码来源:Utils.py

示例15: _heartbeat

 def _heartbeat(self):
     """Add a heartbeat to the log for a monitor to watch."""
     now = datetime.now()
     last_heartbeat = self.last_heartbeat
     if last_heartbeat is None or now - last_heartbeat >= self.heartbeat_frequency:
         syslog("xmlrpc", "--MARK--")
         self.last_heartbeat = now
开发者ID:vitaminmoo,项目名称:unnaturalcode,代码行数:7,代码来源:xmlrpcrunner.py


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