本文整理汇总了Python中db.Db.updateInfo方法的典型用法代码示例。如果您正苦于以下问题:Python Db.updateInfo方法的具体用法?Python Db.updateInfo怎么用?Python Db.updateInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.Db
的用法示例。
在下文中一共展示了Db.updateInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LogBak
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import updateInfo [as 别名]
class LogBak():
def __init__(self):
self.sndb = Db()
def main(self,ip,path,regular,isdel,lbtid):
#验证是否有client脚本
cmd = """ ssh [email protected]%s "cd /root;ls -l |grep -w '%s'|wc -l" """ % (ip,newclient)
ret = os.popen(cmd).readlines()[0].strip('\r\n')
if int(ret) == 1:
pass
else:
cmd = """ ssh [email protected]%s "cd /root;rm -fr %s" """ % (ip,oldclient)
os.popen(cmd)
cmd = """ scp %s [email protected]%s:/root/ """ % (newclient,ip)
os.popen(cmd)
cmd = """ ssh [email protected]%s "cd /root;chmod 700 %s" """ % (ip,newclient)
os.popen(cmd)
#获取软件类型和系统名称
cmd = """ curl -s http://itsm.cnsuning.com/traffic-web-in/XOpenApi/ipToSoftStaff.htm?ip=%s """ % ip
data = os.popen(cmd).readlines()[0]
ret = json.loads(data)
systemname,softtype = ret[0]['systemFename'],ret[0]['softType']
if systemname != "" and softtype != "":
logpath = path+"/"+regular
rq = time.strftime('%Y-%m-%d',time.localtime(time.time()) )
backuppath = systemname+"/"+rq+"/"+softtype+"/"+ip
cmd = """ ssh [email protected]%s "cd /root;./%s '%s' %s %s" """ % (ip,newclient,logpath,backuppath,isdel)
ret = ip+" "+str(os.popen(cmd).readlines()[0].strip('\r\n'))
if not re.search('fail',ret) and not re.search('exist',ret) and not re.search('problem',ret):
sql = "update sn_logbacktask set logbacktask_upddate = now(),logbacktask_status = '成功',logbacktask_des = '%s' where logbacktask_id = '%s' " % (ret,lbtid)
ret = self.sndb.updateInfo(sql)
if ret == "U-SUCESS":
pass
else:
print "%s 更新失败" % lbtid
else:
sql = " update sn_logbacktask set logbacktask_upddate = now(),logbacktask_status = '失败',logbacktask_des = '%s' where logbacktask_id = '%s' " % (ret,lbtid)
ret = self.sndb.updateInfo(sql)
if ret == "U-SUCESS":
pass
else:
print "%s 更新失败" % lbtid
else:
msg = "%s systemname:%s---softtype:%s" % (ip,systemname,softtype)
sql = " update sn_logbacktask set logbacktask_upddate = now(),logbacktask_status = '失败',logbacktask_des = '%s' where logbacktask_id = '%s' " % (msg,lbtid)
ret = self.sndb.updateInfo(sql)
if ret == "U-SUCESS":
pass
else:
print "%s 更新失败" % lbtid