1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
#!/usr/bin/python
#------------------------------------------------------------------------------
#
# This script generates an XML file with a table with issues in Jira. See the
# variable 'conditions' for query details. It is used bu the make system in
# the generation of the release notes.
#
# The result is printed to STDOUT.
#
# It is possible to override the generation. If there is a file named
# jiraissues_override.xml in the current directory, then that file will be
# printed instead. This mechanism can be used if the table needs manual
# modifications.
#
#------------------------------------------------------------------------------
from subprocess import check_output
import json, re, datetime
import time
try:
with open("book-enea-linux-release-info/doc/jiraissues_override.xml") as f:
print f.read(),
exit(0)
except SystemExit:
# Printing the override file was successful. Exception raised by
# the exit() call in the try block.
exit(0)
except IOError:
# Accessing the override file failed. Assume that it does not exist
# and proceed with normal operation.
pass
jd = json.JSONDecoder()
def jira_query(query):
jira_url = "http://eneaissues.enea.com"
fields = "key,summary"
query = query.replace(" ", "+")
cmd = ["curl",
"-s",
"-D-",
"-u", "rest_reader:jira123",
"-X", "GET",
"-H", "Content-Type: application/json",
jira_url + "/rest/api/2/search?jql=" + query + "&fields=" + fields
]
tmp = check_output(cmd).splitlines()
tmp = jd.decode(tmp[-1])
return tmp["issues"]
conditions = ("project=LXCR",
"issueType=bug",
"resolution=Unresolved",
'affectedversion="NFV_Access_1.1.1"'
)
bugs = []
time_str = time.strftime("%Y-%m-%d, %H:%M:%S (%Z)")
for issue in jira_query(" and ".join(conditions)):
bugs.append((issue["key"], issue["fields"]["summary"]))
print '<?xml version="1.0" encoding="ISO-8859-1"?>'
print '<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"'
print '"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">'
print '<section id="relinfo-extracted-from-jira">'
print ' <title>Extracted from Jira</title>'
print
print ' <para>'
print ' This section lists open bugs in Jira. Extracted at %s.' % time_str
print ' </para>'
print
print ' <remark>Jira query: (%s)</remark>' % "\n and ".join(conditions)
print
print ' <informaltable>'
print ' <tgroup cols="2">'
print ' <colspec colwidth="6*" colname="c1"/>'
print
print ' <colspec align="center" colwidth="1*" colname="c2"/>'
print
print ' <thead>'
print ' <row>'
print ' <entry align="center">Summary</entry>'
print
print ' <entry>Enea Ref</entry>'
print ' </row>'
print ' </thead>'
print
print ' <tbody>',
if bugs:
for bug in sorted(bugs):
print
print ' <row>'
print ' <entry>%s</entry>' % bug[1]
print
print ' <entry>%s</entry>' % bug[0]
print ' </row>'
else:
print ' <row>'
print ' <entry namest="c1" nameend="c2" align="center">'
print ' No issues found'
print ' </entry>'
print ' </row>'
print ' </tbody>'
print ' </tgroup>'
print ' </informaltable>'
if bugs:
print ' <para>Number of open bugs: %d</para>' % len(bugs)
print '</section>'
|