當前位置: 首頁>>代碼示例>>Python>>正文


Python logging.Logger類代碼示例

本文整理匯總了Python中process.logging.Logger的典型用法代碼示例。如果您正苦於以下問題:Python Logger類的具體用法?Python Logger怎麽用?Python Logger使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Logger類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: execute

    def execute(self, sql, params=None, timeout = 0):
        cursor = self.db_conn.cursor(cursorclass=Dbi.cursors.DictCursor)
        deathClock = None

        if self.debug:
            if params:
                log.debug(str(sql) + " % " + repr(params))
            else:
                log.debug(str(sql))

        if timeout > 0:
            deathClock = threading.Timer(timeout, self.kill_connection)
            deathClock.start()

        try:
            if params:
                cursor.execute(sql, params)
            elif hasattr(sql, 'uninterpolated_sql') and sql.params:
                cursor.execute(sql.uninterpolated_sql(), sql.params)
            else:
                cursor.execute(str(sql))
            #for row in cursor.fetchall():
            #	yield row
            out = cursor.fetchall()
            cursor.close()
            return out
        finally:
            if deathClock is not None:
                deathClock.cancel()
開發者ID:mikebirduk,項目名稱:wikimedia-fundraising-tools,代碼行數:29,代碼來源:db.py

示例2: mail

    def mail(errorcode, data=None, print_exception=False):
        body = ""
        if print_exception:
            exception_info = "".join(traceback.format_exception(*sys.exc_info()))
            body = body + exception_info
        if data:
            if not isinstance(data, basestring):
                data = yaml.safe_dump([data], default_flow_style=False, allow_unicode=True)
            body = body + "\n\nWhile processing:\n{data}".format(data=data)

        log.error("sending failmail: " + body)

        msg = MIMEText(body)

        from_address = config.failmail_sender
        to_address = config.failmail_recipients
        if hasattr(to_address, 'split'):
            to_address = to_address.split(",")

        msg['Subject'] = "Fail Mail: {code} ({process})".format(code=errorcode, process=config.app_name)
        msg['From'] = from_address
        msg['To'] = to_address[0]

        mailer = smtplib.SMTP('localhost')
        mailer.sendmail(from_address, to_address, msg.as_string())
        mailer.quit()
開發者ID:mikebirduk,項目名稱:wikimedia-fundraising-tools,代碼行數:26,代碼來源:mailer.py

示例3: load_config

def load_config(app_name):
    global config

    search_filenames = [
        os.path.expanduser("~/.fundraising/%s.yaml" % app_name),
        os.path.expanduser("~/.%s.yaml" % app_name),
        # FIXME: relative path fail
        os.path.dirname(__file__) + "/../%s/config.yaml" % app_name,
        "/etc/fundraising/%s.yaml" % app_name,
        "/etc/%s.yaml" % app_name,
        # FIXME: relative path fail
        os.path.dirname(__file__) + "/../%s/%s.yaml" % (app_name, app_name,)
    ]
    # TODO: if getops.get(--config/-f): search_filenames.append

    for filename in search_filenames:
        if not os.path.exists(filename):
            continue

        config = DictAsAttrDict(load_yaml(file(filename, 'r')))
        log.info("Loaded config from {path}.".format(path=filename))

        config.app_name = app_name

        return

    raise Exception("No config found, searched " + ", ".join(search_filenames))
開發者ID:mikebirduk,項目名稱:wikimedia-fundraising-tools,代碼行數:27,代碼來源:globals.py

示例4: write_gdoc_results

def write_gdoc_results(doc=None, results=[]):
    log.info("Writing test results to {url}".format(url=doc))
    doc = Spreadsheet(doc=doc)
    for result in results:
        props = {}
        props.update(result['criteria'])
        props.update(result['results'])
        doc.append_row(props)
開發者ID:mikebirduk,項目名稱:wikimedia-fundraising-tools,代碼行數:8,代碼來源:results_gdoc.py

示例5: get

 def get(self, filename, dest_path):
     try:
         self.client.get(filename, dest_path)
     except:
         if os.path.exists(dest_path):
             log.info("Removing corrupted download: {path}".format(path=dest_path))
             os.unlink(dest_path)
         raise
開發者ID:mikebirduk,項目名稱:wikimedia-fundraising-tools,代碼行數:8,代碼來源:client.py

示例6: __init__

    def __init__(self, name):
        self.name = name

        sql = "INSERT INTO donor_autoreview_job SET name = %s"
        dbc = db.get_db(config.drupal_schema)
        dbc.execute(sql, (name, ))
        self.id = dbc.last_insert_id()
        log.info("This job has ID %d" % self.id)
開發者ID:mikebirduk,項目名稱:wikimedia-fundraising-tools,代碼行數:8,代碼來源:review_job.py

示例7: rotate_files

def rotate_files():
    # Clean up after ourselves
    if config.days_to_keep_files:
        now = time.time()
        for f in os.listdir(config.working_path):
            path = os.path.join(config.working_path, f)
            if os.stat(path).st_mtime < (now - config.days_to_keep_files * 86400):
                if os.path.isfile(path):
                    log.info("Removing old file %s" % path)
                    os.remove(path)
開發者ID:mikebirduk,項目名稱:wikimedia-fundraising-tools,代碼行數:10,代碼來源:export.py

示例8: run_queries

def run_queries(db, queries):
    """
    Build silverpop_export database from CiviCRM.
    """
    i = 1
    for query in queries:
        no_prefix = query[query.index("\n") + 1 :]
        info = (i, no_prefix[:80])
        log.info("Running query #%s: %s" % info)
        db.execute(query)
        i += 1
開發者ID:wikimedia,項目名稱:wikimedia-fundraising-tools,代碼行數:11,代碼來源:update.py

示例9: export_data

def export_data(output_path=None):
    db = DbConnection(**config.silverpop_db)

    log.info("Starting full data export")
    exportq = DbQuery()
    exportq.tables.append('silverpop_export_view')
    exportq.columns.append('*')
    run_export_query(
        db=db,
        query=exportq,
        output=output_path,
        sort_by_index="ContactID"
    )
開發者ID:mikebirduk,項目名稱:wikimedia-fundraising-tools,代碼行數:13,代碼來源:export.py

示例10: connect

 def connect(self):
     log.info("Connecting to {host}".format(host=config.sftp.host))
     transport = paramiko.Transport((config.sftp.host, 22))
     params = {
         'username': config.sftp.username,
     }
     if hasattr(config.sftp, 'host_key'):
         params['hostkey'] = make_key(config.sftp.host_key)
     if hasattr(config.sftp, 'password'):
         params['password'] = config.sftp.password
     if hasattr(config.sftp, 'private_key'):
         params['pkey'] = make_key(config.sftp.private_key)
     transport.connect(**params)
     self.client = paramiko.SFTPClient.from_transport(transport)
開發者ID:mikebirduk,項目名稱:wikimedia-fundraising-tools,代碼行數:14,代碼來源:client.py

示例11: export_unsubscribes

def export_unsubscribes(output_path=None):
    db = DbConnection(**config.silverpop_db)

    log.info("Starting unsubscribe data export")
    exportq = DbQuery()
    exportq.tables.append('silverpop_export')
    exportq.columns.append('contact_id')
    exportq.columns.append('email')
    exportq.where.append('opted_out=1')
    run_export_query(
        db=db,
        query=exportq,
        output=output_path,
        sort_by_index="contact_id"
    )
開發者ID:mikebirduk,項目名稱:wikimedia-fundraising-tools,代碼行數:15,代碼來源:export.py

示例12: addMatch

 def addMatch(job_id, oldId, newId, action, match):
     log.info("Found a match: {old} -> {new} : {match}".format(old=oldId, new=newId, match=match))
     db.get_db(config.drupal_schema).execute("""
         INSERT INTO donor_review_queue
             SET
                 job_id = %(job_id)s,
                 old_id = %(old_id)s,
                 new_id = %(new_id)s,
                 action_id = %(action_id)s,
                 match_description = %(match)s
         """, {
             'job_id': job_id,
             'old_id': oldId,
             'new_id': newId,
             'action_id': action.id,
             'match': match,
         })
開發者ID:adamwight,項目名稱:wikimedia-fundraising-tools,代碼行數:17,代碼來源:review_queue.py

示例13: export_and_upload

def export_and_upload():
    log.info("Begin Silverpop Export")

    make_sure_path_exists(config.working_path)

    updatefile = os.path.join(
        config.working_path,
        'DatabaseUpdate-' + time.strftime("%Y%m%d%H%M%S") + '.csv'
    )
    unsubfile = os.path.join(
        config.working_path,
        'Unsubscribes-' + time.strftime("%Y%m%d%H%M%S") + '.csv'
    )

    export_data(output_path=updatefile)
    export_unsubscribes(output_path=unsubfile)
    upload([updatefile, unsubfile])
    rotate_files()

    log.info("End Silverpop Export")
開發者ID:mikebirduk,項目名稱:wikimedia-fundraising-tools,代碼行數:20,代碼來源:export.py

示例14: execute

    def execute(self, sql, params=None):
        cursor = self.db_conn.cursor(cursorclass=Dbi.cursors.DictCursor)

        if self.debug:
            if params:
                log.debug(str(sql) + " % " + repr(params))
            else:
                log.debug(str(sql))

        if params:
            cursor.execute(sql, params)
        elif hasattr(sql, 'uninterpolated_sql') and sql.params:
            cursor.execute(sql.uninterpolated_sql(), sql.params)
        else:
            cursor.execute(str(sql))
        #for row in cursor.fetchall():
        #	yield row
        out = cursor.fetchall()
        cursor.close()
        return out
開發者ID:adamwight,項目名稱:wikimedia-fundraising-tools,代碼行數:20,代碼來源:db.py

示例15: is_fr_test

def is_fr_test(test):
    if test.label and test.banners and test.campaign:
        is_chapter = re.search(config.fr_chapter_test, test.banners[0])
        if is_chapter:
            log.debug("Determined test {title} belongs to a chapter".format(title=test.label))
        else:
            log.debug("Determined test {title} belongs to Fundraising".format(title=test.label))
        return not is_chapter

    log.warn("missing data for test {title}".format(title=test.label))
開發者ID:mikebirduk,項目名稱:wikimedia-fundraising-tools,代碼行數:10,代碼來源:spec.py


注:本文中的process.logging.Logger類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。