in fact i want usage SVN as PyBlosxom's content synchroscope.
don't through ftp, commit custom and blog with svn auto co.
now i design the post-commit.py usage autoco(dirs,svn,mark,aim,mod) done
::
#!/usr/local/bin/python
#coding=utf-8
import sys,os,time
LOOK = "/usr/local/bin/svnlook"
SVN = "/usr/local/bin/svn"
LOGFILE = "/usr/local/svnrepos/pyblosxom/hooks/script/post-commit.log"
f = open( LOGFILE, "a+" )
TSTAMP = "%s"%time.strftime("%y-%m-%d %H:%M:%S", time.localtime())
### hook matter
MARK = "zoomquiet.org"
MOD = "zoomquiet.org"
AIM = "/usr/local/www/data/pyblosxom/"
def autoco(dirs,svn,mark,aim,mod):
"""自动检出指定项目的代码到指定目录
- dirs 本次修改的目录
- svn svn 命令所在地
- mark 匹配项
- aim 输出目标
- mod 检出的模块
要求目标路径有预先检出的环境!
"""
#print >> f,len(dirs)
print >> f,dirs
if mark in dirs:
print >> f,TSTAMP+" mark::OK! up::"+aim+mod
upsvn = svn+" update %s"%(aim+mod)
print >> f,TSTAMP+upsvn
up = os.popen(upsvn).read().strip()
print >> f,up
else:
print >> f,TSTAMP+" mark::NO! up::nothing"
def changedirs(look,rev,repos):
"""使用 svnlook 得到修改的路径
"""
dirs = os.popen( LOOK+" changed -r "+ rev + " " + repos).read().strip()
return dirs
def usage():
print "Usage: " + sys.argv[0] + " REPOS REV\n"
sys.exit(0)
if __name__ == '__main__':
if len(sys.argv) != 3:
usage()
# start hook matter...
repos = sys.argv[1]
rev = sys.argv[2]
print >> f,TSTAMP+" repos::"+repos+" rev::"+rev
#print >> f,TSTAMP+str()
autoco(changedirs(LOOK,rev,repos),SVN,MARK,AIM,MOD)
it working good, BUT! i commit in windows through TortoriseSVN, when autoco,
that aim dir file is all
-rw-r--r-- 1 root wheel
?!??! how can i make svn update out file is all 755 www:www ?
thanx for any suggest.
--
# Time is unimportant, only life important!
## 面朝开源,我心自由!
Received on Tue Jan 10 07:55:18 2006