In my last post, I introduced a python script to export files in a revision range. Now I write a script to upload changed files in an working copy.
If you have a website, then make use subversion to store source is a good choice. But if you had changed files in different directory, then you should pick a ftp client and upload every file carefully. Upload the whole directory would be too slow and upload the .svn directory underlying.
I write this script which can automatically detect the changed files and upload them to the target host with ftp. The script can downloaded from http://svn-script.googlecode.com/svn/trunk/tools/svnchanged_ftp.py, download it and put on anywhere of your local path. Then write a BAT as below:
python.exe F:rocksunsvn-scripttoolssvnchanged_ftp.py –ftphost 192.168.0.121 –ftpuser username –ftppassword userpassword –ftppath www F:websitesrocksun.cnwww
The options –ftphost、–ftpuser、–ftppassword、–ftppath indicate the ftp’s host ip, user, password and the relative path. The last parameter is the base directory of working copy. Run the bat, and you will find all changed files would be uploaded to the ftp server’s relative directory.
This script also need pysvn to run.
Posted in Subversion.
Tagged with ftp, pysvn, python, Subversion, upload.
By admin
January 15, 2009
A friend of mine asked me if subversion has a function to export changed Files in a revision range, because she want to send the zipped exported directory to customer to overwrite the old version. After googled, I find a Windows BAT(with linux tools) , a java and a TortoiseSVN solution. I think the solutions above all have its own defect, So I decided to write a cross platform script with python.
The script is here: http://svn-script.googlecode.com/svn/trunk/tools/svnchanged_export.py. This script needs python 2.5 or greater and pysvn. To export files changed between 20 and HEAD(newest) at URL svn://192.168.101.1/lynx/trunk/ to directory dist, we can input:
python svnchanged_export.py -u username -p password -r 20:HEAD svn://192.168.101.1/lynx/trunk/ dist
The exported files will organized as the original structure, and the revision is HEAD. The -u(–username) and (-p)(–password) is optional. If omited, the script may use the cached authentication information. The files will export to directory dist. The -r(–revision) also accept integer value like “-r 10:20″, then the exported file’s revision would be 20.
Any problems can comment here.
Posted in Subversion.
Tagged with changed, export, pysvn, python, revision.
Look at this photo.
Fat Girl?
It seems a little fat? In my previouse post, I had introduced the resize script. The method resize script used was a direct resize. If the ratio of the original file is not same as the target file, the file will get into distortion. I write a script can automatically crop the image to the target ratio. The new result is here.
Cropped Image
This script crop the top and bottom part of the image, so the result image can fit my favorite ratio, compare the images below.
Not Cropped
Cropped
The girl become slim again.
Now let’s see the gimp script rs-center-crop.scm:
(define (script-fu-rs-center-crop filename outfilename width height)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image))))
(let* ((original-width (car (gimp-image-width image)))
(original-height (car (gimp-image-height image)))
(new-width original-width)
(new-height original-height)
(offset-x 0)
(offset-y 0))
(if (<= (/ original-width original-height) (/ width height))
(gimp-image-crop image original-width (* original-width (/ height width)) 0 (/ (- original-height (* original-width (/ height width))) 2) )
(gimp-image-crop image (* original-height (/ width height)) original-height (/ (- original-width (* original-height (/ width height))) 2) 0)
)
)
(set! drawable (car (gimp-image-get-active-layer image)))
(gimp-file-save RUN-NONINTERACTIVE image drawable outfilename outfilename)
(gimp-image-delete image)))
|
Copy the rs-center-crop.scm to “D:Program FilesGIMP-2.0sharegimp2.0scripts”(If your GIMP installed at D:Program FilesGIMP-2.0 ). Now we can write a bat rs-center-crop.bat to run this script.
set str=%1
set str=%str:=/%
set str2=%2
set str2=%str2:=/%
"D:Program FilesGIMP-2.0bingimp-2.6.exe" -i --verbose -b "(script-fu-rs-center-crop "%str%" "%str2%" 200 120)" -b "(gimp-quit 0)"
|
In the last line, “200″ and “100″ is the target ratio. Because my file will resize to 200*120, so I set the ratio as 200 and 120. At last, we add it into the context menu, we write the reg file rs-center-crop.reg.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINESOFTWAREClasses*shellRSGimpCrop]
@="Crop as 200*120"
[HKEY_LOCAL_MACHINESOFTWAREClasses*shellRSGimpCropcommand]
@="F:\rocksun\gimp-script\rs-center-crop\rs-center-crop.bat "%1" "%1""
|
All files you can download or checkout with subversion from http://gimp-script.googlecode.com/svn/trunk/rs-center-crop/ . I create this project to collect and produce gimp script, you can join it.
Posted in design.
Tagged with crop, GIMP, resize, script, script-fu.
By admin
December 20, 2008