代码拉取完成,页面将自动刷新
同步操作将从 茹憶/MySQLMTOP 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/env python
#-*-coding:utf-8-*-
import MySQLdb
import string
import sys
reload(sys)
sys.setdefaultencoding('utf8')
import ConfigParser
import smtplib
from email.mime.text import MIMEText
from email.message import Message
from email.header import Header
def get_config(group,config_name):
config = ConfigParser.ConfigParser()
config.readfp(open('./etc/config.ini','rw'))
config_value=config.get(group,config_name).strip(' ').strip('\'').strip('\"')
return config_value
host = get_config('monitor_server','host')
port = get_config('monitor_server','port')
user = get_config('monitor_server','user')
passwd = get_config('monitor_server','passwd')
dbname = get_config('monitor_server','dbname')
def mysql_exec(sql,param):
conn=MySQLdb.connect(host=host,user=user,passwd=passwd,port=int(port),connect_timeout=5,charset='utf8')
conn.select_db(dbname)
cursor = conn.cursor()
if param <> '':
cursor.execute(sql,param)
else:
cursor.execute(sql)
conn.commit()
cursor.close()
conn.close()
def mysql_query(sql):
conn=MySQLdb.connect(host=host,user=user,passwd=passwd,port=int(port),connect_timeout=5,charset='utf8')
conn.select_db(dbname)
cursor = conn.cursor()
count=cursor.execute(sql)
if count == 0 :
result=0
else:
result=cursor.fetchall()
return result
cursor.close()
conn.close()
def get_option(key):
conn=MySQLdb.connect(host=host,user=user,passwd=passwd,port=int(port),connect_timeout=5,charset='utf8')
conn.select_db(dbname)
cursor = conn.cursor()
sql="select value from options where name=+'"+key+"'"
count=cursor.execute(sql)
if count == 0 :
result=0
else:
result=cursor.fetchone()
return result[0]
cursor.close()
conn.close()
mail_host = get_config('mail_server','mail_host')
mail_user = get_config('mail_server','mail_user')
mail_pass = get_config('mail_server','mail_pass')
mail_postfix = get_config('mail_server','mail_postfix')
def send_mail(to_list,sub,content):
'''
to_list:发给谁
sub:主题
content:内容
send_mail("aaa@126.com","sub","content")
'''
me=mail_user
#me=mail_user+"<</span>"+mail_user+"@"+mail_postfix+">"
msg = MIMEText(content, _subtype='html', _charset='utf8')
msg['Subject'] = Header(sub,'utf8')
msg['From'] = Header(me,'utf8')
msg['To'] = ";".join(to_list)
try:
s = smtplib.SMTP()
s.connect(mail_host)
s.login(mail_user,mail_pass)
s.sendmail(me,to_list, msg.as_string())
s.close()
return True
except Exception, e:
print str(e)
return False
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。