def removetask(request): "删除一个task" from utils import generate_dict info=valid_tid(request) if info==False: buff=generate_dict(False,"该task不存在") else: task=info[1] result=run_serve_fun("removedaemon",task.tid) if result==True: buff=generate_dict(True,"Success!") else: buff=generate_dict(*result) return HttpResponse(json.dumps(buff,ensure_ascii=False),mimetype="application/javascript")
def starttask(request): "start one task" info=valid_tid(request) from utils import generate_dict if info==False: buff=dict([("status",False),("message","该task不存在!")]) else: task=info[1] result=run_serve_fun("startdaemon",task.tid) if result==True: buff=generate_dict(True,"Success!") else: buff=generate_dict(*result) return HttpResponse(json.dumps(buff,ensure_ascii=False),mimetype="application/javascript")
def modifytask(request): "更改一个task" from utils import generate_dict getinfo=request.GET postinfo=request.POST tid=getinfo.get("tid") _ip=postinfo.get("ip") ip_list=postinfo.getlist("ip") name=postinfo.get("name") svnpath=postinfo.get("url").strip() version=postinfo.get("version") svnuser=postinfo.get("svnuser") svnpasswd=postinfo.get("svnpasswd") info=postinfo.get("fn") _type=postinfo.get("type") args="" filename=postinfo.get("filename") __info=valid_tid(request) if __info==False: buff=generate_dict(False,"此task非法!") else: task=__info[1] ip=task.ip if _ip!=ip: buff=generate_dict(False,"不允许修改IP!") elif name!=task.name: buff=generate_dict(False,"不允许修改后台任务名!") elif len(ip_list)>1: buff=generate_dict(False,"不可选择多台主机!") else: result=valid_input(ip,name,svnpath,version,svnuser,svnpasswd,info,args,filename) if result!=True: buff=generate_dict(*result) else: if version=="*": versioninfo=get_svn_top_version(svnpath,svnuser,svnpasswd) if versioninfo[0]==False: buff=generate_dict(versioninfo[0],versioninfo[1]) else: version=versioninfo[1] if not locals().has_key("buff"): result= run_serve_fun("modifydaemon",task.tid,name,svnpath,str(version),svnuser,svnpasswd,info,args,filename) if result==True: buff=generate_dict(True,"Success!") else: buff=generate_dict(*result) return HttpResponse(json.dumps(buff,ensure_ascii=False,indent=True),mimetype="application/javascript")