給TRAC添加用戶(hù)和密碼
在trac中通過(guò)login進(jìn)入時(shí)出現(xiàn)Authentication information not available. Please refer to the installation documentation.
在網(wǎng)上查了許久才解決,沒(méi)有設(shè)置用戶(hù).可能通過(guò)腳本來(lái)創(chuàng)建一個(gè)用戶(hù)和密碼, 腳本代碼如下:
from optparse import OptionParser
import md5
# build the options
usage = "usage: %prog [options]"
parser = OptionParser(usage=usage)
parser.add_option("-u", "--username",action="store", dest="username", type = "string",
help="the username for whom to generate a password")
parser.add_option("-p", "--password",action="store", dest="password", type = "string",
help="the password to use")
(options, args) = parser.parse_args()
# check options
if (options.username is None) or (options.password is None):
parser.error("You must supply both the username and password")
# Generate the string to enter into the htdigest file
realm = 'developer'
kd = lambda x: md5.md5(':'.join(x)).hexdigest()
print ':'.join((options.username, realm, kd([options.username, realm, options.password])))
名字保存為trac-digest.py,存放目錄自己決定.
中間這句
realm = 'developer'
是設(shè)定用戶(hù)組的。這里建議和SVN一樣
通過(guò)命令:C:\Python24>python 存放目錄/trac-digest.py -u admin -p admin >> 存放目錄\trac-user.txt
可以看見(jiàn)在trac下建立了一個(gè)trac-user.txt的密碼文檔。打開(kāi)內(nèi)容如下:
bugx:developer:9a3e2c7267643ec735505f944643835b
-u后面表示用戶(hù)名,-p表示密碼,trac-user.txt表示輸出的文件,里面有用戶(hù)名和加密的密碼
在桌面上建立一個(gè)批處理,用來(lái)啟動(dòng)Trac。
@echo off
echo trac is now starting...
cd \
cd python24
python scripts/tracd --port 8080 --auth *,盤(pán)符:\trac\trac-user.txt,developer 盤(pán)符:/trac/project
:end
--port 8080是監(jiān)聽(tīng)端口。
--auth * 是所有的項(xiàng)目用相同的帳號(hào)登陸
盤(pán)符:/trac/project 是項(xiàng)目的路徑。多個(gè)項(xiàng)目就 空格隔開(kāi)
(
注意上面輸出與輸入文本的文件名要一樣.我開(kāi)始就是少了一個(gè)字母半天也沒(méi)弄好..花費(fèi)了許多的時(shí)間)