def get_new_user_id_by_day(self, date, exist_tables): new_id_map = {'google': 0, 'facebook': 0, 'dolphin': 0, 'total': 0} date_str = get_date_str(date) table_name = get_table_name('DolphinID_new', date) if table_name in exist_tables: select_str = 'select user_id,login_type from %s' % table_name datas = self._mysql_conn.query_sql(select_str) else: datas = None logger.info("the table %s do not exist" % table_name) if datas: for item in datas: if item[1] == 11: new_id_map['facebook'] += 1 elif item[1] == 10: new_id_map['google'] += 1 elif item[1] == 0: new_id_map['dolphin'] += 1 else: print "not found the info %s" % item[1] logger.info("not found the info %s" % item[1]) new_id_map['total'] = len(datas) else: new_id_map = {'google': 0, 'facebook': 0, 'dolphin': 0, 'total': 0} return new_id_map
def get_sync_site_statistics(self, date): exist_tables = self.get_exist_tables() table_name = get_table_name('Site_Statistics_', date) if table_name in exist_tables: select_str = 'select site_url,count from %s where api_type=1' % table_name datas = self._mysql_conn.query_sql(select_str) return datas else: logger.info("the table %s do not exist" % table_name) datas = [["no data", 0]] return datas
"Content-Disposition"] = 'attachment;filename = %s.png' % project_name msg.attach(msgImgage) except IOError: logger.error("File %s not exits" % path) except Exception, e: logger.error("exception accured in add image![%s]" % e) def send_email(subject, body, async=True, to_list=MAIL_TO, is_picture=False, is_api=True): try: if async: t = Process(target=send_email, args=(subject, body, False, to_list, is_picture, is_api)) t.daemon = False t.start() logger.info( "start a process to send email, subject[%s], tolist[%s]" % (subject, to_list)) else: msg = _prepare_msg(subject, body, mail_to=to_list, is_picture=is_picture, is_api=is_api) smtp = _prepare_smtp() smtp.sendmail(MAIL_FROM, to_list, msg.as_string()) smtp.quit() except Exception, e: logger.error("exception accured in send email![%s]" % e) pass html_str = '<html><head></head><body><h1>测试 again test mail</h1>\ <br /><img src="cid:image1" /><img src="cid:image2"></body></html>' if __name__ == "__main__": # send_email("[subject] Test Email", html_str, filepath=filepath,True)