From: William Zhang Date: Wed, 9 May 2012 02:28:56 +0000 (+0800) Subject: add update_config and post_data X-Git-Tag: v0.2.23~296^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5246e154f99bc072a9e8cce8ab2e67f5f85449b0;p=tools%2Fpython-jenkinsapi.git add update_config and post_data --- diff --git a/jenkinsapi/jenkinsbase.py b/jenkinsapi/jenkinsbase.py index f41f2fd..61eede8 100644 --- a/jenkinsapi/jenkinsbase.py +++ b/jenkinsapi/jenkinsbase.py @@ -72,6 +72,11 @@ class JenkinsBase(object): raise return result + def post_data(self, url, content): + request = urllib2.Request(url, content) + result = urllib2.urlopen(request).read().strip() + return result + def hit_url(self, url ): fn_urlopen = self.get_jenkins_obj().get_opener() try: diff --git a/jenkinsapi/job.py b/jenkinsapi/job.py index 9a94884..df03007 100644 --- a/jenkinsapi/job.py +++ b/jenkinsapi/job.py @@ -202,3 +202,7 @@ class Job(JenkinsBase): def get_config(self): '''Returns the config.xml from the job''' return self.hit_url("%(baseurl)s/config.xml" % self.__dict__) + + def update_config(self, config): + '''Update the config.xml to the job''' + return self.post_data("%(baseurl)s/config.xml" % self.__dict__, jobconfig)