def delete_version_cookie(requestInfo, publisher): ''' 调用delete-version.sh脚本 实现线上版本正式改变 ''' version = requestInfo['version'] if 'version' in requestInfo else '' type = requestInfo['type'] if 'type' in requestInfo else '' which = requestInfo['which'] if 'which' in requestInfo else '' branch_name = requestInfo['branch_name'] if 'branch_name' in requestInfo else '' if not version: return if not type: return # 记录发布人 versions = CookieVersion.objects.filter(name=version,branch_type=type) for v in versions: v.publish_cookie_deleted_no = publisher v.publish_cookie_deleted = time.strftime("%Y-%m-%d %X", time.localtime()) v.save() shellPath = settings.SHELL_PATH os.chdir(shellPath) opResult = os.popen(shellPath+"delete-version.sh %s %s %s" % (version,type,which)) outputs = "<br />".join(opResult.readlines()) #insert log Git.insertShellLog(10,1,outputs) return outputs
def update_git(requestInfo, publisher): which = requestInfo['which'] if 'which' in requestInfo else '' type = requestInfo['type'] if 'type' in requestInfo else '' shellPath = settings.SHELL_PATH os.chdir(shellPath) opResult = os.popen(shellPath+"update-git.sh %s %s" % (which,type)) outputs = "<br />".join(opResult.readlines()) #insert log Git.insertShellLog(10,1,outputs) return outputs
def rsyncToPg(requestInfo,user): import os from django.conf import settings if requestInfo.has_key('branchName'): branchName = requestInfo['branchName'] fpxx = requestInfo['fpxx'] remote = requestInfo['remote'] shellPath = settings.SHELL_PATH os.chdir(shellPath) opResult = os.popen(shellPath+"remote-refresh-pg.sh %s %s %s" % (branchName,remote,fpxx)) outputs = "<br/>".join(opResult.readlines()) # 输出的log日志 errorSyntax = outputs.find("Syntax Error") #insert log 日志 if errorSyntax>=0: return False,str(outputs),[] else: # 将项目状态由正在开发改成正在测试 projectId = requestInfo['projectId'] project = Project.objects.get(id=projectId) project.setStatus(3) #insert log 日志 Git.insertShellLog(1,requestInfo['projectId'],outputs,user.first_name) # 将项目信息更新到Branch的pdevInfo字段 from project.models import Branch branches = Branch.objects.filter(name=branchName) if len(branches) > 0: branch = Branch.objects.filter(name=branchName)[0] branch.pdevInfo = '' branch.save() else: import time selectedFpPath = settings.PG_DEV_PATH+branchName # /home/www/release/v2/pmt-15111 branch = Branch(project=project, name=branchName, pdevInfo=selectedFpPath, pcreateDateTime=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), status=1).save() return True,"代码已同步至 "+str(branchName),str(branchName)