浏览 9829 次
锁定老帖子 主题:开发中的一些常用工具
精华帖 (0) :: 良好帖 (1) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2010-08-17
@explorer.exe %1% 保存为o.bat eg:一般我只用下面两个 ①o . ②o .. 2.SVN更新 @set src_path1=C:\AAA\BBB\CCC @echo 更新中… @TortoiseProc.exe /command:update /path:"%src_path1%" /closeonend:1 @echo 更新完成 另外更新SVN @TortoiseProc.exe /command:commit /path:"%src_path%" /closeonend:0 3.ClearCase更新 @set projectPath=C:\AAAAAA @cleartool update %projectPath%\ libs @cleartool update %projectPath%\ utils @rem 一些需要手动拷贝的地方 @xcopy %projectPath%\ libs\o /R /S /Y /D %projectPath%\libs\dest @pause 4.部署的脚本 # coding: UTF-8 import os C_7Z_EXE = '"C:\\Program Files\\7-Zip\\7z.exe"' SERVER_DEPLOY_PATH = "\\\\192.168.1.111\\AAAA\\BBB\\build\\" def main(): copyfile = raw_input("请输入要部署的文件名:") print u"开始拷贝。。。" print SERVER_DEPLOY_PATH + copyfile # 将部署文件拷贝到自己临时目录 os.system("@XCOPY " + SERVER_DEPLOY_PATH + copyfile + " /R /Y /D " + "C:\\env") print u"拷贝结束" # 解压缩拷贝过来的文件 os.chdir("C:\\env") a_7z_cmd = C_7Z_EXE + ' x ' + copyfile + ' -o' + "C:\\env" + '\\' os.system("@" + a_7z_cmd) print u"\n 解压缩完成" # 将自己解压缩出来的文件拷贝到部署目录 os.system("@XCOPY " + "C:\\env\\" + copyfile[:-4] +"\\DPS\\cuidef" + " /R /Y /D " + "C:\\DPS\\cuidef") os.system("@XCOPY " + "C:\\env\\" + copyfile[:-4] +"\\DPS\\lib" + " /R /Y /D " + "C:\\DPS\\lib") os.system("@XCOPY " + "C:\\env\\" + copyfile[:-4] +"\\DPS\\extdef" + " /R /Y /D " + "C:\\DPS\\extdef") print u"拷贝结束" os.chdir("C:\\env\\" + copyfile[:-4] + "\\DPS\\ear") unzipEAR("C:\\env\\" + copyfile[:-4] + "\\DPS\\ear") def unzipEAR(path): # 还有一些其他的部署,但是基本思路和上面是一致的 if __name__ == "__main__": main() 5.提取检查测试结果 这个要根据具体的情况进行修改,我只是随便写的,减轻劳动量。 # coding: UTF-8 import sys import os import time import keyword, token, tokenize workpath = "\\\\192.168.1.111\\AAAAAAAAAAAAAAAAAAAA" temppath = "C:\\functiontestlog" exepath = os.getcwd() def main(): copyfile = raw_input("需要从服务器中拷贝日志文件吗?(Y/N)") if copyfile == "Y" or copyfile == "y": print "开始拷贝" os.system('RD /s /q ' + temppath) os.mkdir(temppath) os.mkdir(temppath + '\\temp') copyLog(0, workpath) print "拷贝结束" time.sleep(1) checkng = raw_input("检查测试结果不正确的文件?(Y/N)") if checkng == "Y" or checkng == "y": #开始记录 print "开始查找" epochValue = time.time() timeString = time.ctime(epochValue) mylogFile = open(temppath + "\\_result.html", "w") os.chdir(exepath) mytcfIdfile = open('tcfidlist.txt') #遍历查找文件中存在NG的文件,并且把文件名纪录下来 #没有必要细看 for tcfid in mytcfIdfile.readlines(): tcfid = tcfid.replace("\n", "") tcfLog = searchfile(0, temppath, tcfid) if None != tcfLog: currentLogFile = open(tcfLog) logContent = currentLogFile.read() if logContent.find("》@COMPAREM\nNG") != -1: logContent.replace("\n", "<br>\n"); print tcfLog[:-4] mylogFile.write('<font color=red>NG case:</font>' + "<a href=" + tcfLog[:-4] + ".html" + " target=_top >" + tcfLog[:-5] + "</a><br>" + '\n') currentLogFile.close() else: #找不到测试结果的情况下 mylogFile.write("No Log:" + tcfid + '<br>\n') mytcfIdfile.close() mylogFile.close() rename(temppath,".LOG",".html") print "查找结束" os.system('start file://C:\\functiontestlog\\_result.html') sys.exit() #文件重命名 def rename(path,old_ext,new_ext): for (path, dirs, files) in os.walk(path): for filename in files: ext=os.path.splitext(filename)[1] if (cmp(ext,old_ext)==0): newname=filename.replace(old_ext,new_ext) oldpath=path+"\\"+filename newpath=path+"\\"+newname try: os.rename(oldpath, newpath) except ValueError: print "Error when rename the file " + oldpath except NameError: print "Error when rename the file " + oldpath except OSError: print newpath + " The file is already exist!" #按照一定的规则进行拷贝文件, def copyLog(level, path): for i in os.listdir(path): currentPath = path + '\\' + i if os.path.isdir(path + '\\' + i): copyLog(level + 1, path + '\\' + i) elif os.path.isfile(path + '\\' + i): if currentPath.find('TESTRESULT_') != -1: os.system("@XCOPY " + currentPath + " /R /Y /D " + temppath + '\\temp') os.chdir(temppath + '\\temp') try: print u'' + currentPath[-47:], u'' + currentPath[-39:] os.rename(u'' + currentPath[-47:], u'' + currentPath[-39:]) os.system("@XCOPY " + currentPath[-39:] + " /R /Y /D " + temppath) os.system("del " + temppath + '\\temp\\' + currentPath[-39:]) except: try: print u'' + currentPath[-50:], u'' + currentPath[-42:] os.rename(u'' + currentPath[-50:], u'' + currentPath[-42:]) os.system("@XCOPY " + currentPath[-42:] + " /R /Y /D " + temppath) os.system("del " + temppath + '\\temp\\' + currentPath[-42:]) except: print u'' + currentPath[-49:] print u'' + currentPath[-41:] os.rename(u'' + currentPath[-49:], u'' + currentPath[-41:]) os.system("@XCOPY " + currentPath[-41:] + " /R /Y /D " + temppath) os.system("del " + temppath + '\\temp\\' + currentPath[-41:]) def searchfile(level, path, tcfid): for i in os.listdir(path): currentPath = path + '\\' + i tcfid = tcfid.replace("\n", "") # 文件名符合当前要求? index = currentPath.find(tcfid) if index != -1: return currentPath if __name__ == "__main__": sys.exit(main()) 6,EJB中工程编译,打包,部署 set path=%path%;C: \apache-ant-1.7.0\bin set path=%path%;C:\Oracle\Middleware\jdk160_18\bin set module_name=%1% @rem 指定Source目录 set base_path=C:\AAAAAA\dps.%module_name% @rem 工作的jar包目录 set org_path_jar=C:\ AAAAA\ libs\dest\ @rem EJB部署目录 set dest_path_jar=C:\FuncTest\dpsall\ cd %base_path% @rem 调用ant脚本,编译,打包 cmd /c ant compilel pack.jar @rem 将jar文件拷贝到部署目录 xcopy %org_path_jar%dps.%module_name%.jar %dest_path_jar% /y startweblogic 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2010-08-18
引用 Java代码 @explorer.exe %1% 保存为o.bat eg:一般我只用下面两个 ①o . ②o .. 我用win+E ![]() |
|
返回顶楼 | |
发表时间:2010-08-19
unika_ly12 写道 引用 Java代码 @explorer.exe %1% 保存为o.bat eg:一般我只用下面两个 ①o . ②o .. 我用win+E ![]() start . |
|
返回顶楼 | |
发表时间:2010-08-20
这是批处理吧
|
|
返回顶楼 | |
发表时间:2010-08-28
我还是ant用的多些,获取依赖的jar包使用maven,另外加一些简单的bat和sh
|
|
返回顶楼 | |