1 |
hwoarang 14/09/01 21:20:49 |
2 |
|
3 |
Modified: get_glsas.py |
4 |
Log: |
5 |
get_glsas.py: Multiple fixes |
6 |
|
7 |
- Add command line arguments for start-stop date |
8 |
- Escape ',' in description since it conflicts with the wordpress pluging for |
9 |
tables |
10 |
- Take care of GLSAs for multiple packages |
11 |
- improve code to construct the GLSA id hyperlink |
12 |
|
13 |
Revision Changes Path |
14 |
1.4 src/gwn/get_glsas.py |
15 |
|
16 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo/src/gwn/get_glsas.py?rev=1.4&view=markup |
17 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo/src/gwn/get_glsas.py?rev=1.4&content-type=text/plain |
18 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo/src/gwn/get_glsas.py?r1=1.3&r2=1.4 |
19 |
|
20 |
Index: get_glsas.py |
21 |
=================================================================== |
22 |
RCS file: /var/cvsroot/gentoo/src/gwn/get_glsas.py,v |
23 |
retrieving revision 1.3 |
24 |
retrieving revision 1.4 |
25 |
diff -u -r1.3 -r1.4 |
26 |
--- get_glsas.py 26 Nov 2013 18:54:44 -0000 1.3 |
27 |
+++ get_glsas.py 1 Sep 2014 21:20:49 -0000 1.4 |
28 |
@@ -25,13 +25,12 @@ |
29 |
if td.a: |
30 |
# Fetch GLSA id and reconstruct the href |
31 |
glsanum = str(td.a).split() |
32 |
- if str(date_from) in str(glsanum[2]): |
33 |
- foundone = 1 |
34 |
- glsanum = glsanum[0] + " " + \ |
35 |
- glsanum[1] + glsanum[2] + glsanum[3] |
36 |
- glsa_list.append(glsanum) |
37 |
- else: |
38 |
- return |
39 |
+ if any(str(date_from) in date for date in glsanum): |
40 |
+ foundone = 1 |
41 |
+ glsanum = glsanum[0] + " " + glsanum[1] + glsanum[2] + glsanum[3] |
42 |
+ glsa_list.append(glsanum) |
43 |
+ else: |
44 |
+ break |
45 |
passt += 1 |
46 |
else: |
47 |
# Ignore table headers |
48 |
@@ -43,14 +42,26 @@ |
49 |
|
50 |
elif passt == 2: |
51 |
# Fetch package name and construct href |
52 |
- package = str(td.string).strip() |
53 |
- package = "<a href=\"http://packages.gentoo.org/package/%s\">%s</a>" % (package, package) |
54 |
+ if td.a: |
55 |
+ # This is usually for GLSAs for |
56 |
+ # multiple packages. |
57 |
+ # FIXME: There has to be a better way |
58 |
+ # to do that... |
59 |
+ package = td.find_next(text=True).strip().split()[0] |
60 |
+ extra_pkg = \ |
61 |
+ td.find_next(text=True).strip() + " more)" |
62 |
+ package = \ |
63 |
+ "<a href=\"http://packages.gentoo.org/package/%s\">%s</a>" \ |
64 |
+ % (package, extra_pkg) |
65 |
+ else: |
66 |
+ package = str(td.string).strip() |
67 |
+ package = "<a href=\"http://packages.gentoo.org/package/%s\">%s</a>" % (package, package) |
68 |
package_list.append(package) |
69 |
passt += 1 |
70 |
|
71 |
elif passt == 3: |
72 |
# Fetch description |
73 |
- description = str(td.string).strip() |
74 |
+ description = str(td.string).strip().replace(',','\,') |
75 |
description_list.append(description) |
76 |
passt += 1 |
77 |
|
78 |
@@ -66,6 +77,15 @@ |
79 |
# get dates from command line, else use now (time.time()) |
80 |
starttime = time.gmtime(time.time() - (60 * 60 * 24 * 1)) |
81 |
endtime = time.gmtime(time.time() + (60 * 60 * 24 * 31)) |
82 |
+ if len(sys.argv) >=1: |
83 |
+ if len(sys.argv) >= 2: |
84 |
+ starttime = time.strptime(str(int(sys.argv[1])), "%Y%m%d") |
85 |
+ endtime = time.strptime(str(int(sys.argv[2])), "%Y%m%d") |
86 |
+ else: |
87 |
+ print "Usage: " + os.path.basename(sys.argv[0]) + " [start-date] [end-date]" |
88 |
+ print "dates must be passed in 'yyyymmdd' format" |
89 |
+ print "if no dates are specified then it defaults to a date range of the last 31 days" |
90 |
+ |
91 |
# Format the string to what we expect |
92 |
date_to = time.strftime("%Y%m", endtime) |
93 |
date_from = time.strftime("%Y%m", starttime) |