本文整理汇总了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()
示例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()
示例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))
示例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)
示例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
示例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)
示例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)
示例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
示例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"
)
示例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)
示例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"
)
示例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,
})
示例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")
示例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
示例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))