提交 8a8d5683 编写于 作者: mydemo4's avatar mydemo4

删除TOOL

上级 d125ee07
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
class Properties(object):
def __init__(self, fileName):
self.fileName = fileName
self.properties = {}
def __getDict(self, strName, dictName, value):
if (strName.find('.') > 0):
k = strName.split('.')[0]
dictName.setdefault(k, {})
return self.__getDict(strName[len(k) + 1:], dictName[k], value)
else:
dictName[strName] = value
return
def getProperties(self):
try:
pro_file = open(self.fileName, 'Ur')
for line in pro_file.readlines():
line = line.strip().replace('\n', '')
if line.find("#") != -1:
line = line[0:line.find('#')]
if line.find('=') > 0:
strs = line.split('=')
strs[1] = line[len(strs[0]) + 1:]
self.__getDict(strs[0].strip(), self.properties, strs[1].strip())
except Exception as e:
raise e
else:
pro_file.close()
return self.properties
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#assign ibizsys_base_file = '${pub.getPSApplication().getPFType()}'>
<#if pub.getPSApplication().getPSPFStyle().getVersionString()?? && (pub.getPSApplication().getPSPFStyle().getVersionString()!='')>
<#assign ibizsys_base_file += '-${pub.getPSApplication().getPSPFStyle().getVersionString()}'>
</#if>
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import git
import time
import sys
import os
import pycurl
import platform
from ReadProperties import Properties
if(sys.argv[1]=='begin' or sys.argv[1]=='rebuild'):
#初始化GIT目录
if(platform.system()=="Linux"):
pro = Properties('${codefolder}/${sys.getPSDevCenterDomain()}/${sys.getPubSystemId()}/${sys.getVCName()}/.TOOL/repo.properties').getProperties()
else:
pro = Properties('${codefolder}\\${sys.getPSDevCenterDomain()}\\${sys.getPubSystemId()}\\${sys.getVCName()}\\.TOOL\\repo.properties').getProperties()
git_user = pro["git_user"]
git_pass = pro["git_pass"].replace("@", "%40")
git_path = pro["git_path"]
#git_path = pro["git_path"].replace("//", "//" + git_user + ":" + git_pass + "@")
#git_api = git_path+"/api/v4/projects"
#git_repo = git_path+"/"+git_user+"/${sys.codeName}"
git_repo = git_path
if(platform.system()=="Linux"):
git_local = "${codefolder}/${sys.getPSDevCenterDomain()}/${sys.getPubSystemId()}/${sys.getVCName()}/${sys.codeName}"
else:
git_local = "${codefolder}\\${sys.getPSDevCenterDomain()}\\${sys.getPubSystemId()}\\${sys.getVCName()}\\${sys.codeName}"
if os.path.exists(git_local+os.sep+".git"):
repo = git.Repo(path=git_local)
repo.git.config("user.name",git_user)
repo.git.config("user.email",git_user)
repo.git.fetch("--all")
repo.git.reset('--hard','origin/master')
else:
#c = pycurl.Curl()
#c.setopt(c.URL, git_api) # (网址)
#c.setopt(c.HTTPHEADER, ["PRIVATE-TOKEN: axMxnfp_oyYpDGp-rP4J"]) # 网址头部
#c.setopt(c.POST, 1) # 1表示调用post方法而不是get
#c.setopt(c.POSTFIELDS, "name=${sys.codeName}") # 数据
#c.setopt(c.CONNECTTIMEOUT, 60) # 超时中断
#c.setopt(c.TIMEOUT, 600) # 下载超时
#c.perform() # 提交
if(platform.system()=="Linux"):
repo = git.Repo.clone_from(url=git_repo, to_path="${codefolder}/${sys.getPSDevCenterDomain()}/${sys.getPubSystemId()}/${sys.getVCName()}/${sys.codeName}")
else:
repo = git.Repo.clone_from(url=git_repo, to_path="${codefolder}\\${sys.getPSDevCenterDomain()}\\${sys.getPubSystemId()}\\${sys.getVCName()}\\${sys.codeName}")
repo.git.config("user.name",git_user)
repo.git.config("user.email",git_user)
if(sys.argv[1]=='rebuild'):
if os.path.exists(git_local+os.sep+".git"):
flag=False
rootdir = git_local
for root,dirs,files in os.walk(r,rootdir):
for i in files:
path = os.path.join(root,i)
if os.path.isfile(path) and path.find(".git")==-1:
edituser=repo.git.log(path).split("\n")[1].split(" ")[1]
if edituser=="" or edituser==git_user:
flag=True
repo.git.rm(path)
if flag:
repo.git.commit("-m 123")
repo.git.push("origin", "master")
#创建目录
if(platform.system()=="Linux"):
os.system(r"mkdir -p ${codefolder}/${sys.getPSDevCenterDomain()}/${sys.getPubSystemId()}/${sys.getVCName()}/${sys.codeName}/app_${pub.getPSApplication().getPKGCodeName()}")
else:
os.system(r"mkdir -p ${codefolder}\${sys.getPSDevCenterDomain()}\${sys.getPubSystemId()}\${sys.getVCName()}\${sys.codeName}\app_${pub.getPSApplication().getPKGCodeName()}")
#拷贝初始文件
if(platform.system()=="Linux"):
os.system(r"cp -p -rf ${toolfolder}/APP/${ibizsys_base_file}/APP/ ${codefolder}\${sys.getPSDevCenterDomain()}\${sys.getPubSystemId()}\${sys.getVCName()}\${sys.codeName}\app_${pub.getPSApplication().getPKGCodeName()}/")
else:
os.system(r"xcopy ${toolfolder}\APP\${ibizsys_base_file}\APP\*.* ${codefolder}\${sys.getPSDevCenterDomain()}\${sys.getPubSystemId()}\${sys.getVCName()}\${sys.codeName}\app_${pub.getPSApplication().getPKGCodeName()} /I/E/Y/D")
if(sys.argv[1]=='end'):
if(platform.system()=="Linux"):
pro = Properties('${codefolder}/${sys.getPSDevCenterDomain()}/${sys.getPubSystemId()}/${sys.getVCName()}/.TOOL/repo.properties').getProperties()
else:
pro = Properties('${codefolder}\\${sys.getPSDevCenterDomain()}\\${sys.getPubSystemId()}\\${sys.getVCName()}\\.TOOL\\repo.properties').getProperties()
git_user = pro["git_user"]
git_pass = pro["git_pass"].replace("@", "%40")
git_path = pro["git_path"]
#git_path = pro["git_path"].replace("//", "//" + git_user + ":" + git_pass + "@")
if(platform.system()=="Linux"):
repo = git.Repo(path="${codefolder}/${sys.getPSDevCenterDomain()}/${sys.getPubSystemId()}/${sys.getVCName()}/${sys.codeName}")
else:
repo = git.Repo(path="${codefolder}\\${sys.getPSDevCenterDomain()}\\${sys.getPubSystemId()}\\${sys.getVCName()}\\${sys.codeName}")
flag=False
for i in (repo.git.status("-s").split("\n")):
if i.startswith(" M"):
flag = True
editfile=i.split(" ")[2]
edituser=repo.git.log(editfile).split("\n")[1].split(" ")[1]
print("***"+edituser+"****")
if edituser=="" or edituser==git_user:
repo.git.add(editfile,"-f")
elif i.startswith("??"):
flag = True
editfile = i.split(" ")[1]
repo.git.add(editfile, "-f")
if flag:
repo.git.commit("-m 123")
repo.git.push("origin", "master")
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
<#if sys.getPSSVNInstRepo().getSVNType()=="GIT">
git_user=${sys.getPSSVNInstRepo().getGitUserName()}
git_pass=
git_path=${sys.getPSSVNInstRepo().getGitPath()}
</#if>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册