The only one that has been ordered is the Python script, well, is that really supposed to be a bit of a ready-made scripting tool?
First of all, the production environment of this thing
People in the outsourcing company, the size of a small, standard what do not talk about, completely no
Javaweb project after deployment to update the code each time you have to see what the modified files, manually copy the change file to the server to replace the individual, in particular, changed a bunch of bugs involved in various java,jsp files more than 10 more than 20 times ... Manually copying and compiling a compiled class from Tomcat is quite painful.
However, it is said that there is no standard and no ready tools ... So I thought about it, and I wrote a script that was responsible for automatic packaging.
The unit project is mainly ECLIPSE+SVN,SVN is the use of the sqlite3 as a local data store to store file change list, then the use of SVN can easily quickly get the file update information
Given the different IDE's project file structure, this script can only be used in the same environment (ECLIPSE+SVN) application
Usage is simple, follow the prompts to enter the SVN project directory/package start version number/TOMCAT application directory/Generate diff directory, will automatically read the SVN corresponding version number to start to the last version of all the file change information, and go to Tomcat to find the corresponding file (class/jsp, etc.), Copy to the corresponding location where the diff directory is generated, and finally only need to back up the original application, and then replace the entire folder with a replacement restart even if the update is complete
Did not learn python casually write, variable name AH norms what is ignored it ....
ImportSqlite3ImportTracebackImportOSImportOs.path fromShutilImportCopy##The purpose of this tool is to automatically go to the Tomcat directory to copy the change class to make the update package according to the SVN file change record .#only eclipse projects are supported (different IDE-created project file directory structure is different)#defAddlog (oldlog,logtext):Print(LogText)returnoldlog+"\ n"+LogTextdefGetdirbypath (dirpath):returnDirpath[0:dirpath.rindex ("/")]defGetfilenamebypath (dirpath):returnDirpath[dirpath.rindex ("/") +1: Len (dirpath)]defMycopyfile (c_srcfile,c_desfile):if(os.path.exists (c_srcfile) = =False):returnFalseif(Os.path.exists (Getdirbypath (c_desfile)) = =False): Os.makedirs (Getdirbypath (c_desfile))#if it is a class that automatically traverses related inner classes, copy the Classname$xxx.class format file together if anyTmpfile =Getfilenamebypath (c_srcfile)if(Tmpfile.endswith (". Class")): Tmpdir=Getdirbypath (c_srcfile) tmpfile= Tmpfile[0:len (tmpfile)-6] +"$" forDinchOs.listdir (tmpdir):if(D.startswith (tmpfile)): Copy (Tmpdir+"/"+d,getdirbypath (C_desfile) +"/"+d) Copy (C_srcfile,c_desfile)returnTruePrint("Welcome to the SVN diff automatic Packaging script, the following requires no \ \ symbol at the end of the input path")Print("This script only applies to the Java EE Project of Eclipse")Print("the internal classes are copied all, and if necessary, manually remove the extra internal classes") path= Input ("Please enter the SVN project directory:")Try: CX= Sqlite3.connect (path +"\\.svn\\wc.db") CU=cx.cursor () ver= Input ("Please enter a package version number:") Cu.execute ("Select Local_relpath,changed_revision from NODES where kind= ' file ' and changed_revision>="+ ver +"ORDER BY Changed_revision") Srcpath= Input ("Please enter the Tomcat project folder:") Despath= Input ("Please enter a location to save the diff file:") Log=""Log= Addlog (log,"[Start processing diff file, from version"+ver+"] Start:") while(True): Data=Cu.fetchone ()if(Data = =None): Break #determine the conversion path based on the extension if(Data[0].startswith ("webcontent/")): #webcontent Resource ConversionSrcfile = Srcpath + data[0][10: Len (data[0])] Desfile= Despath + data[0][10: Len (data[0])if(Mycopyfile (srcfile,desfile)): Log= Addlog (log,"[processed] [version number:"+str (data[1]) +"]"+data[0])Else: Print(srcfile) Log= Addlog (log,"[not processed] [version number:"+str (data[1]) +"] in the file ["+data[0]+"] does not exist! ") elif(Data[0].startswith ("src/")): #src Path Conversion if(Data[0].endswith ("Java")): TMP= Data[0][3:len (data[0]) -4]+"class" Else: tmp= Data[0][3: Len (data[0])] TMP="/web-inf/classes"+tmp srcfile= Srcpath +tmp desfile= Despath +tmpif(Mycopyfile (srcfile,desfile)): Log= Addlog (log,"[processed] [version number:"+str (data[1]) +"]"+data[0])Else: Log= Addlog (log,"[not processed] [version number:"+str (data[1]) +"] in the file ["+data[0]+"] does not exist! ") elif(Data[0].startswith ("config/")): #Config path conversionSrcfile = Srcpath +"/web-inf/classes"+ data[0][6: Len (data[0])] Desfile= Despath +"/web-inf/classes"+ data[0][6: Len (data[0])if(Mycopyfile (srcfile,desfile)): Log= Addlog (log,"[processed] [version number:"+str (data[1]) +"]"+data[0])Else: Log= Addlog (log,"[not processed] [version number:"+str (data[1]) +"] in the file ["+data[0]+"] does not exist! ") Else: #Other resources write log temporarily not processedLog = Addlog (log,"[not processed] [version number:"+str (data[1]) +"] in the file ["+data[0]+"] not recognized, please handle it manually! ") File_object= Open (Despath +"/chuli.log",'W') file_object.write (log) file_object.close ()Print("The program executes and the log is written to the ["+srcpath+"\\chuli.log], see Manual handling of [unhandled] items as needed")except: Print("Program Execution Exception") Traceback.print_exc ()
[Python] Java EE Project update package Packaging tool