er_code = 0
er_info = ""
sMetadata = "CHANGE MASTER TO MASTER_HOST='%s',MASTER_LOG_FILE='%s',MASTER_LOG_POS=%s,MASTER_USER='rep_user',MASTER_PASSWORD='meizu.com'" % (master_host, log_file, log_pos )
return (er_code, er_info, master_host, sMetadata)
def execute(cmd):
'''
1.执行 shell 命令
2.返回执行信息 (returncode = 0 则执行成功, std_err 为报错的错误信息)
'''
try:
returncode, std_err = commands.getstatusoutput(cmd)
return (returncode, std_err)
except os.error, e:
# 异常返回 1001 错误
return (1001, e)
def call_proc(my_args):
# 备份信息写入数据库
try:
conn = mydb.connect(host = '127.0.0.1', user = 'test', passwd = 'zxc/213?', db = 'meizu_item')
cur = conn.cursor()
cur.callproc('sp_backup_i',[my_args[0], my_args[1], my_args[2], my_args[3], my_args[4], my_args[5], my_args[6], my_args[7], my_args[8], my_args[9], my_args[10], my_args[11], my_args[12]])
conn.commit()
except mydb.Error, e:
pass
# print "Mysql Error %d: %s" % (e.args[0], e.args[1])
finally:
cur.close(); conn.close()
if __name__ == '__main__':
main()