❶ 求助關於python使用svn的問題
你是想使用python操作svn吧,你可以安裝svn的第三方庫。
https://pypi.python.org/pypi/svn/0.3.25
具體使用:
importsvn.local
importpprint
r=svn.local.LocalClient('/dev/repo')
r.export('/tmp/export')
pprint.pprint(r.info())
importsvn.remote
r=svn.remote.RemoteClient('https://repo.local/svn')
r.checkout('/tmp/working')
如果解決了您的問題請採納!
如果未解決請繼續追問!
❷ python3如何將遠端svn上的文件下載到本地
這還不簡單, 根本不需要python, A機器上面ssh到B機器上面去, 執行svn up
PS: python也有ssh庫, 也可以手動寫程序去連
❸ 什麼是目前比較常用的Python擴展庫管理工具
這個網站左上角有documentation鏈接的,點進去看看。
像exe,msi如果別人已經編譯過了就看不到源碼了,說明作者並不希望你看到源碼。第三方庫開源軟體比較多,有網頁論壇可以找,所以直接進模塊目錄就可以看到源碼。
元格中輸入公式:=RIGHT(A,),確認後即顯示
❹ 如何將 SVN 源碼庫轉換為 Mercurial
首先得安裝 Subversion 庫函數
wget http://mirrors.hust.e.cn/apache/subversion/subversion-1.8.8.tar.gz
tar xzf subversion-1.8.8.tar.bz2
cd subversion-1.8.8
subversion-1.8.8 aliang$ ./autogen.sh
buildcheck: checking installation...
buildcheck: autoconf not found.
You need autoconf version 2.59 or newer installed.
brew install autoconf
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/autoconf-2.69.mavericks.bottle.tar.gz
#################################################### 100.0%
==> Pouring autoconf-2.69.mavericks.bottle.tar.gz
🍺 /usr/local/Cellar/autoconf/2.69: 69 files, 2.0M
./autogen.sh
buildcheck: checking installation...
buildcheck: autoconf version 2.69 (ok)
buildcheck: autoheader version 2.69 (ok)
buildcheck: libtool not found.
You need libtool version 1.4 or newer installed
brew install libtool
Warning: A newer Command Line Tools release is available
Update them from Software Update in the App Store.
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/libtool-2.4.2.mavericks.bottle.2.tar.gz
##################################################### 100.0%
==> Pouring libtool-2.4.2.mavericks.bottle.2.tar.gz
==> Caveats
In order to prevent conflicts with Apple''s own libtool we have prepended a "g"
so, you have instead: glibtool and glibtoolize.
==> Summary
🍺 /usr/local/Cellar/libtool/2.4.2: 66 files, 2.2M
./autogen.sh
buildcheck: checking installation...
buildcheck: autoconf version 2.69 (ok)
buildcheck: autoheader version 2.69 (ok)
buildcheck: libtool version 2.4.2 (ok)
Copying libtool helper: /usr/local/share/aclocal/libtool.m4
Copying libtool helper: /usr/local/share/aclocal/ltoptions.m4
Copying libtool helper: /usr/local/share/aclocal/ltsugar.m4
Copying libtool helper: /usr/local/share/aclocal/ltversion.m4
Copying libtool helper: /usr/local/share/aclocal/lt~obsolete.m4
Creating build-outputs.mk...
Creating svn_private_config.h.in...
Creating configure...
You can run ./configure now.
Running autogen.sh implies you are a maintainer. You may prefer
to run configure in one of the following ways:
./configure --enable-maintainer-mode
./configure --disable-shared
./configure --enable-maintainer-mode --disable-shared
./configure --disable-optimize --enable-debug
./configure CUSERFLAGS='--flags-for-C' CXXUSERFLAGS='--flags-for-C++'
Note: If you wish to run a Subversion HTTP server, you will need
Apache 2.x. See the INSTALL file for details.
brew install swig
==> Downloading http://downloads.sourceforge.net/project/swig/swig/swig-2.0.11/swig-2.0.11.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/swig/2.0.11
==> make
==> make install
🍺 /usr/local/Cellar/swig/2.0.11: 597 files, 6.2M, built in 10.1 minutes
./configure --with-swig=/usr/local/bin/swig
configure: Configuring Subversion 1.8.8
... ...
==================================================================
WARNING: You have chosen to compile Subversion with a different
compiler than the one used to compile Apache.
Current compiler: gcc
Apache's compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc
This could cause some problems.
==================================================================
... ...
make swig-py
make install
make check-swig-py
sudo make install-swig-py
sudo cp -r /usr/local/lib/svn-python/ /Library/Python/2.7/site-packages/
執行轉換命令
mkdir hgpath
cd hgpath
hg init
hg convert -s svn -d hg ${local_path} ./hgpath
注意,這里轉換的 SVN 目錄只能是倉庫目錄而不是工作目錄
❺ 怎麼用python更新SVN、獲取SVN版本號、獲取SVN兩個版本號之間的修改日誌。
1) 執行shell命令,最好用popen打開,不過中間會有一些交互,除非事先的鑒權信息保存在系統中了。參考buildbot中對這些版本管理軟體的用法。
2)好像有個pySVN的庫可以用。
❻ python如何獲取svn路徑是文件還是文件夾
GetFilesFromSVN.py
#----------------------------------------------
# Author : Jeff Yu
# Date : 2012-8-13
# Function : get files from SVN
#----------------------------------------------
#----------------------------------
# Step1: Get INFO
#----------------------------------
import sys,ConfigParser
try:
configFile = open("config.ini","r")
except IOError:
print "config.ini is not found"
raw_input("")
sys.exit()
config = ConfigParser.ConfigParser()
config.readfp(configFile)
configFile.close()
# get baseurl
try:
baseurl = config.get("INFO","baseurl")
# incase last "/" is missing in baseurl
baseurl = baseurl.rstrip("/")
baseurl = "%s/"%baseurl
except ConfigParser.NoOptionError:
print "baseurl is not found under section INFO in config.ini."
raw_input("")
sys.exit()
# get user
try:
user = config.get("INFO","user")
except ConfigParser.NoOptionError:
meg = "user is not found under section INFO in config.ini."
raw_input("")
sys.exit()
# get passwd
try:
passwd = config.get("INFO","passwd")
except ConfigParser.NoOptionError:
meg = "passwd is not found under section INFO in config.ini."
raw_input("")
sys.exit()
# get fileList
try:
fileList = config.get("INFO","fileList")
except ConfigParser.NoOptionError:
meg = "fileList is not found under section INFO in config.ini."
raw_input("")
sys.exit()
#----------------------------------
# Step2: Auth
#----------------------------------
import urllib2
realm = "Subversion Repositories"
auth = urllib2.HTTPBasicAuthHandler()
auth.add_password(realm, baseurl, user, passwd)
opener = urllib2.build_opener(auth, urllib2.CacheFTPHandler)
urllib2.install_opener(opener)
#----------------------------------
# Step3: Create Folder
#----------------------------------
import os
folderName = "svnFile"
if not os.path.exists(folderName):
os.mkdir(folderName)
#----------------------------------
# Step4: Get Files
#----------------------------------
fr = open(fileList,'r')
for i in fr:
i = i.strip("\n")
i = i.strip(" ")
# ignore the blank line
if i != "":
url = "%s%s"%(baseurl,i)
try:
data = urllib2.urlopen(url)
fw = open("%s/%s"%(folderName,i),'w')
fw.write(data.read())
fw.close()
print "Download: %s."%i
except urllib2.HTTPError, e:
# HTTPError is a subclass of URLError
# need to catch this exception first
mesg = str(e).split(" ")
errCode = mesg[2].rstrip(":")
if errCode == "401":
# HTTP Error 401: basic auth failed
print "Can not login in, please check the user and passwd in config.ini."
break
elif errCode == "404":
# HTTP Error 404: Not Found
print "Not Found: %s"%i
else:
print e
print "Failed to download %s"%i
except urllib2.URLError:
# 1.SVN server is down
# 2.URL is not correct
print "Please check SVN Server status and baseurl in config.ini."
break
fr.close()
raw_input("")
config.ini
[INFO]
baseurl = https://xxx/xxx/xxx/xxx/
user = 用戶名
passwd = 密碼
fileList= fileList.txt
fileList.txt
aaaaa.txt
bbbbb.txt
ccccc.txt
使用方法:
1.配置config.ini,配置好需要check out文件所在文件夾的URL(baseurl),用戶名(user),密碼(passwd)和存儲文件列表的文件名稱(fileList)
2.將要check out的文件列表放在文本文件裡面(fileList.txt),每一個文件佔一行.
3.雙擊GetFilesFromSVN.py運行,下載的文件將放在當前文件夾下用過名為svnFile的文件夾裡面.
PS:獲取realm
在這個腳本中,我hardcode了一段代碼(064行) realm = "Subversion Repositories"
關於這個realm,可以使用下面腳本獲取:
import urllib2
import sys
url = '這里寫URL'
username = '這里寫用戶名'
password = '這里寫密碼'
req = urllib2.Request(url)
try:
handle = urllib2.urlopen(req)
except IOError, e:
pass
else:
print "This page isn't protected by authentication."
sys.exit(1)
getrealm = e.headers['www-authenticate']
print getrealm
❼ svn的commit功能,怎麼用python實現
真不太清楚你什麼意思,好吧照我理解的來,給你個ci的def
def co_file(src):
co_cmd="svn co "+src
os.system(co_cmd)
#function: ci file with log comments
def ci_file():
current_path=os.getcwd()
svn_path=current_path+"/scm"
os.chdir(svn_path)
ci_cmd="svn ci -F comments.txt --force-log"
os.system(ci_cmd)
os.system("rm -f scm/*")
os.chdir(current_path)
❽ python pysvn 怎麼使用
pysvn是Python下svn的第三方庫。需要安裝
1、首先需要安裝svn客戶端。
2、安裝svn之前需要安裝apr和apr-util。
3、安裝pysvn。
❾ python svn腳本如何進行文件刪除
其中實現功能的核心代碼寫得太過冗長,其實很簡單的4行代碼就能達到目的,如下:
1 import os
2 for (p,d,f) in os.walk("要刪除的目錄路徑"):
3 if p.find('.svn')>0:
4 os.popen('rd /s /q %s'%p)
❿ 怎麼在程序中(java/python)操作eclipse從設定好的svn中更新到最新版本
幹嘛要讓eclipse來做這件事呢?一般的做法是利用post-commit這個鉤子,這個鉤子是在SVN伺服器端該版本庫hooks文件夾內,這個鉤子會在每次完成commit操作時被自動執行。
這個鉤子實際就是一個批處理文件,你可以在這個鉤子里利用SVN的命令行,在伺服器端update得到最新版本,然後再傳送到你的linux伺服器。這樣每次有提交,都會傳送新版本到測試伺服器。
一般我會把SVN伺服器和測試伺服器放在同一台主機上,這樣就省事多了。