开发者

deploying a war to tomcat using python

I'm trying to deploy a war to a Apache Tomcat server (Build 6.0.24) using python (2.4.2) as part of a build process.

I'm using the following code

import urllib2
import base64

war_file_contents = open('war_file.war','rb').read()

username='some_user'
password='some_pwd'

base64string =  base64.encodestring('%s:%s' % (username, password))[:-1]
authheader =  "Basic %s" % base64string

opener = urllib2.build_opener(urllib2.HTTPHandler)
request = urllib2.Request('http://localhost:8080/manager/deploy?path=war_file', data=war_file_contents)

request.add_header('Content-Type', 'application/octet-stream')
request.add_header("Authorization", authheader)

request.get_method = lambda: 'PUT'
url = opener.open(request)

the url.code is 200, and the url.msg is "OK". However the web archive doesn't appear on the manager list applicatio开发者_JS百科ns page.

Thanks.


Okay, figured it out.

The urllib2.Request line needs to have a slash in front of the path so:-

request = urllib2.Request('http://localhost:8080/manager/deploy?path=/war_file', data=war_file_contents)

All then works fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜