• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python Syslog.syslog函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: main

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

    parts = Utils.GetPathPieces()
    lenparts = parts and len(parts)
    if not parts or lenparts < 1:
        title = _("CGI script error")
        doc.SetTitle(title)
        doc.AddItem(Header(2, title))
        doc.addError(_("Invalid options to CGI script."))
        doc.AddItem("<hr>")
        doc.AddItem(MailmanLogo())
        print doc.Format()
        return

    # get the list and user's name
    listname = parts[0].lower()
    # open list
    try:
        mlist = MailList.MailList(listname, lock=0)
    except Errors.MMListError, e:
        # Avoid cross-site scripting attacks
        safelistname = Utils.websafe(listname)
        title = _("CGI script error")
        doc.SetTitle(title)
        doc.AddItem(Header(2, title))
        doc.addError(_("No such list <em>%(safelistname)s</em>"))
        doc.AddItem("<hr>")
        doc.AddItem(MailmanLogo())
        # Send this with a 404 status.
        print "Status: 404 Not Found"
        print doc.Format()
        syslog("error", 'No such list "%s": %s\n', listname, e)
        return
开发者ID:KWMSources,项目名称:mailman_config,代码行数:35,代码来源:options.py


示例17: maybe_forward

def maybe_forward(mlist, msg):
    # Does the list owner want to get non-matching bounce messages?
    # If not, simply discard it.
    if mlist.bounce_unrecognized_goes_to_list_owner:
        adminurl = mlist.GetScriptURL('admin', absolute=1) + '/bounce'
        mlist.ForwardMessage(msg,
                             text=_("""\
The attached message was received as a bounce, but either the bounce format
was not recognized, or no member addresses could be extracted from it.  This
mailing list has been configured to send all unrecognized bounce messages to
the list administrator(s).

For more information see:
%(adminurl)s

"""),
                             subject=_('Uncaught bounce notification'),
                             tomoderators=0)
        syslog('bounce',
               '%s: forwarding unrecognized, message-id: %s',
               mlist.internal_name(),
               msg.get('message-id', 'n/a'))
    else:
        syslog('bounce',
               '%s: discarding unrecognized, message-id: %s',
               mlist.internal_name(),
               msg.get('message-id', 'n/a'))
开发者ID:darix,项目名称:mailman,代码行数:27,代码来源:BounceRunner.py


示例18: add_members

    def add_members (self, save=False):
        """Add any email addressses that are provided in the create form."""

        if self.welcome == '':
            text = ('Welcome to %s. Visit the List Server to ' +
            'manage your subscriptions') % self.ln
        else:
            text = self.welcome

        for key in self.cgidata.keys():
            if re.match('^lc_member_', key):
                fn, em = parseaddr(self.cgival(key).lower().strip())
                userdesc = UserDesc(em, fn, mm_cfg.SSO_STOCK_USER_PWD, False)
                try:
                    self.ml.ApprovedAddMember(userdesc, True, text,
                                              whence='SSO List Creation Time')
                    syslog('sso',
                           'Successfully added %s to list: %s' % (em,
                                                                  self.ln))
                except Errors.MMAlreadyAMember:
                    ## FIXME: Need to find some way of communicating this
                    ## case to the user. As thisi s a new list, this can only
                    ## happen if the same address is given by the admin... hm
                    syslog('sso',
                           '%s already a member of listL %s' % (em, self.ln))

        if save:
            self.ml.Save()
开发者ID:skarra,项目名称:GNU-Mailman-SSO,代码行数:28,代码来源:ctl.py


示例19: verp_probe

def verp_probe(mlist, msg):
    bmailbox, bdomain = Utils.ParseEmail(mlist.GetBouncesEmail())
    # Sadly not every MTA bounces VERP messages correctly, or consistently.
    # Fall back to Delivered-To: (Postfix), Envelope-To: (Exim) and
    # Apparently-To:, and then short-circuit if we still don't have anything
    # to work with.  Note that there can be multiple Delivered-To: headers so
    # we need to search them all (and we don't worry about false positives for
    # forwarded email, because only one should match VERP_REGEXP).
    vals = []
    for header in ('to', 'delivered-to', 'envelope-to', 'apparently-to'):
        vals.extend(msg.get_all(header, []))
    for field in vals:
        to = parseaddr(field)[1]
        if not to:
            continue                          # empty header
        mo = re.search(mm_cfg.VERP_PROBE_REGEXP, to)
        if not mo:
            continue                          # no match of regexp
        try:
            if bmailbox <> mo.group('bounces'):
                continue                      # not a bounce to our list
            # Extract the token and see if there's an entry
            token = mo.group('token')
            data = mlist.pend_confirm(token, expunge=False)
            if data is not None:
                return token
        except IndexError:
            syslog(
                'error',
                "VERP_PROBE_REGEXP doesn't yield the right match groups: %s",
                mm_cfg.VERP_PROBE_REGEXP)
    return None
开发者ID:darix,项目名称:mailman,代码行数:32,代码来源:BounceRunner.py


示例20: encryptSignMessage

 def encryptSignMessage(self,msg,recipients):
     gpg = self.getGPGObject()
     params = ['--encrypt','--sign','--always-trust','--batch','--no-permission-warning']
     for i in recipients:
         params.append('-r')
         params.append(i)
     p = gpg.run(params, create_fhs=['stdin','stdout','stderr','passphrase'])
     t_out = AsyncRead(p.handles['stdout'])
     t_out.start()
     t_err = AsyncRead(p.handles['stderr'])
     t_err.start()
     p.handles['passphrase'].write(self.mlist.gpg_passphrase)
     p.handles['passphrase'].close()
     p.handles['stdin'].write(msg)
     p.handles['stdin'].close()
     t_out.join()
     t_err.join()
     ciphertext = t_out.data
     result = t_err.data
     try:
         p.wait()
     except IOError:
         syslog('gpg',"Error encrypting message: %s",result)
         return None
     return ciphertext
开发者ID:jurov,项目名称:gnu-mailman,代码行数:25,代码来源:GPGUtils.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python i18n._函数代码示例发布时间:2022-05-24
下一篇:
Python Mailman.Utils类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap