1 """CMS TagCollector Python API
4 __author__ =
"Miguel Ojeda"
5 __copyright__ =
"Copyright 2010-2011, CERN CMS"
6 __credits__ = [
"Miguel Ojeda"]
7 __license__ =
"Unknown"
8 __maintainer__ =
"Miguel Ojeda"
9 __email__ =
"mojedasa@cern.ch"
10 __status__ =
"Staging"
12 _tagcollector_url =
'https://cmstags.cern.ch/tc/'
20 import simplejson
as json
22 import ws_sso_content_reader
25 """CMS TagCollector Python API"""
28 self.
_url = _tagcollector_url
33 self.
_cj = cookielib.CookieJar()
34 self.
_opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.
_cj))
39 def _open(self, page, params = None, data = None):
40 url = self.
_url + page +
'?'
42 url += urllib.urlencode(params)
44 data = urllib.urlencode(data)
48 return self._opener.open(url, data).
read()
49 except urllib2.HTTPError, e:
52 def _openjson(self, page, params = None, data = None):
53 return json.loads(self.
_open(page, params, data))
55 def signIn(self, username, password):
57 """Sign in to TagCollector."""
58 self.
_open(
'signIn', data = {
'password': password,
'user_name': username})
63 """Sign in to TagCollector, asking for the username and password."""
64 username = raw_input(
'Username: ')
65 password = getpass.getpass()
66 self.
signIn(username, password)
71 """Sign out of TagCollector."""
76 """Get the tags published in TagCollector for a package.
77 Note: TagCollector's published tags are a subset of CVS' tags."""
78 return self.
_openjson(
'public/py_getPackageTags', {
'package': package})
81 """Get the first line of the descriptions of a tag."""
82 return self.
_openjson(
'public/py_getPackageTagDescriptionFirstLine', {
'package': package,
'tag': tag})
85 """Get the releases where a tag is."""
86 return self.
_openjson(
'public/py_getPackageTagReleases', {
'package': package,
'tag': tag})
89 """Get the tags of one or more release.
90 Optionally, return only the tags that differ between releases."""
91 releases = json.dumps(releases)
92 diff = json.dumps(diff)
93 return self.
_openjson(
'public/py_getReleasesTags', {
'releases': releases,
'diff': diff})
96 """Get the tags of one release."""
100 """Get the tags of one tagset."""
101 return self.
_openjson(
'public/py_getTagsetTags', {
'tagset': tagset})
104 """Get the information of one tagset."""
105 return self.
_openjson(
'public/py_getTagsetInformation', {
'tagset': tagset})
108 """Prints Pending Approval tags of one or more releases,
109 one or more tagsets, or both (i.e. it joins all the tags).
110 Prints an error if several tags appear for a single package.
111 Suitable for piping to addpkg (note: at the moment,
112 addpkg does not read from stdin, use "-f" instead)."""
113 args = json.dumps(args)
114 allow_multiple_tags = json.dumps(allow_multiple_tags)
115 return self.
_openjson(
'public/py_getPendingApprovalTags', {
'args': args,
'allow_multiple_tags': allow_multiple_tags})
118 """Prints Pending Signature tags of one or more releases,
119 one or more tagsets, or both (i.e. it joins all the tags).
120 Prints an error if several tags appear for a single package.
121 Suitable for piping to addpkg (note: at the moment,
122 addpkg does not read from stdin, use "-f" instead)."""
123 if not release_names ==
None:
124 return self.
_openjson(
'public/py_getTagsetsTagsPendingSignatures', {
'user_name': user_name,
'show_all': show_all,
'author_tagsets': author_tagsets,
'release_names': json.dumps(release_names)})
126 return self.
_openjson(
'public/py_getTagsetsTagsPendingSignatures', {
'user_name': user_name,
'show_all': show_all,
'author_tagsets': author_tagsets})
129 """Comment one or more tagsets.
130 Requirement: Signed in."""
131 tagset_ids = json.dumps(tagset_ids)
133 raise Exception(
"Error: Expected a comment.")
134 self.
_open(
'commentTagsets', {
'tagset_ids': tagset_ids,
'comment': comment})
137 """Sign one or more tagsets.
138 Requirement: Signed in as a L2."""
139 tagset_ids = json.dumps(tagset_ids)
140 self.
_open(
'signTagsets', {
'tagset_ids': tagset_ids,
'comment': comment})
143 """Sign all one or more tagsets.
144 Requirement: Signed in as a top-level admin."""
145 tagset_ids = json.dumps(tagset_ids)
146 self.
_open(
'signTagsetsAll', {
'tagset_ids': tagset_ids,
'comment': comment})
149 """Reject one or more tagsets Pending Signatures.
150 Requirement: Signed in as a L2s or as a Release Manager
151 for the tagset's release or as the author of the tagset."""
152 tagset_ids = json.dumps(tagset_ids)
153 self.
_open(
'rejectTagsetsPendingSignatures', {
'tagset_ids': tagset_ids,
'comment': comment})
156 """Approve one or more tagsets.
157 Requirement: Signed in as a Release Manager for each tagset's release."""
158 tagset_ids = json.dumps(tagset_ids)
159 self.
_open(
'approveTagsets', {
'tagset_ids': tagset_ids,
'comment': comment})
162 """Bypass one or more tagsets.
163 Requirement: Signed in as a Release Manager for each tagset's release."""
164 tagset_ids = json.dumps(tagset_ids)
165 self.
_open(
'bypassTagsets', {
'tagset_ids': tagset_ids,
'comment': comment})
168 """Reject one or more tagsets Pending Approval.
169 Requirement: Signed in as a Release Manager."""
170 tagset_ids = json.dumps(tagset_ids)
171 self.
_open(
'rejectTagsetsPendingApproval', {
'tagset_ids': tagset_ids,
'comment': comment})
174 """Remove one or more tagsets from the History (i.e. stack of the release).
175 Requirement: Signed in as a Release Manager."""
176 tagset_ids = json.dumps(tagset_ids)
177 self.
_open(
'removeTagsets', {
'tagset_ids': tagset_ids,
'comment': comment})
180 """Get New Package Requests which are Pending Approval."""
181 return self.
_openjson(
'public/py_getPackagesPendingApproval')
184 """Get the Package Managers (administrators and developers) requested in a New Package Request."""
185 return self.
_openjson(
'public/py_getPackageManagersRequested', {
'package': package})
188 """Searches for releases, packages, tagsets, users and categories.
189 Requirement: Signed in."""
190 return self.
_openjson(
'search', {
'term': term})
193 """Approve a New Package Request.
194 Requirement: Signed in as a Creator (i.e. people in the top-level .admin/developers file).
195 Warning: This does *not* create the package in CVS."""
196 self.
_open(
'approveNewPackageRequest', {
'package_name': package})
199 """Get the name and creation date of Integration Builds.
200 By default, it only returns the latest 10 IBs.
201 Optionally, filter by name."""
202 return self.
_openjson(
'public/py_getIBs', {
'filt': filt,
'limit': limit})
204 def deprecateReleases(self, *releases):
205 """ Deprecate releases"""
207 raise Exception(
"Error: Not logged in?!")
208 self.
_open(
'deprecateReleases', {
"releases":
",".
join(releases)})
210 def createRelease(self, base_release_name, new_release_name, new_state, new_private, new_type, new_description, release_managers, copy_queues, tags):
211 """Create a new release.
212 Requirement: Signed in as a release manager."""
214 self.
_open(
'copyRelease', {
'release_name': base_release_name,
'new_release_name': new_release_name,
'new_state': new_state,
'new_private': new_private,
'new_type': new_type,
'new_description': new_description,
'release_managers': release_managers,
'copy_queues': copy_queues,
'tags': tags})
216 raise Exception(
"Error: Not logged in?!")
219 """Request a CustomIB.
220 Requirement: Signed in."""
222 self.
_open(
'requestCustomIB', {
'release_name': release_name,
'architecture_names': architectures,
'tags': tags})
224 raise Exception(
"Error: Not logged in?!")
227 """Returns release architectures."""
228 return self.
_openjson(
'public/py_getReleaseArchitectures', {
'release': release,
'default': default})
def rejectTagsetsPendingSignatures
def getPackageManagersRequested
def getPackagesPendingApproval
def getTagsetsTagsPendingSignatures
def getReleaseArchitectures
def getPackageTagReleases
def rejectTagsetsPendingApproval
static std::string join(char **cmd)
def getPackageTagDescriptionFirstLine
def getPendingApprovalTags