From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id D955813877A for ; Mon, 1 Sep 2014 21:20:53 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A24DEE0BB2; Mon, 1 Sep 2014 21:20:52 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2F193E0BB2 for ; Mon, 1 Sep 2014 21:20:52 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8F7E233BE2D for ; Mon, 1 Sep 2014 21:20:50 +0000 (UTC) Received: by oystercatcher.gentoo.org (Postfix, from userid 2238) id 3F4004765; Mon, 1 Sep 2014 21:20:49 +0000 (UTC) From: "Markos Chandras (hwoarang)" To: gentoo-commits@lists.gentoo.org Reply-To: gentoo-dev@lists.gentoo.org, hwoarang@gentoo.org Subject: [gentoo-commits] gentoo commit in src/gwn: get_glsas.py X-VCS-Repository: gentoo X-VCS-Files: get_glsas.py X-VCS-Directories: src/gwn X-VCS-Committer: hwoarang X-VCS-Committer-Name: Markos Chandras Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Message-Id: <20140901212049.3F4004765@oystercatcher.gentoo.org> Date: Mon, 1 Sep 2014 21:20:49 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 2975586f-6459-4825-9039-042fe2a2ed9d X-Archives-Hash: fb9d49942214518fa4e3985b5e9adc36 hwoarang 14/09/01 21:20:49 Modified: get_glsas.py Log: get_glsas.py: Multiple fixes - Add command line arguments for start-stop date - Escape ',' in description since it conflicts with the wordpress pluging for tables - Take care of GLSAs for multiple packages - improve code to construct the GLSA id hyperlink Revision Changes Path 1.4 src/gwn/get_glsas.py file : http://sources.gentoo.org/viewvc.cgi/gentoo/src/gwn/get_glsas.py?rev=1.4&view=markup plain: http://sources.gentoo.org/viewvc.cgi/gentoo/src/gwn/get_glsas.py?rev=1.4&content-type=text/plain diff : http://sources.gentoo.org/viewvc.cgi/gentoo/src/gwn/get_glsas.py?r1=1.3&r2=1.4 Index: get_glsas.py =================================================================== RCS file: /var/cvsroot/gentoo/src/gwn/get_glsas.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- get_glsas.py 26 Nov 2013 18:54:44 -0000 1.3 +++ get_glsas.py 1 Sep 2014 21:20:49 -0000 1.4 @@ -25,13 +25,12 @@ if td.a: # Fetch GLSA id and reconstruct the href glsanum = str(td.a).split() - if str(date_from) in str(glsanum[2]): - foundone = 1 - glsanum = glsanum[0] + " " + \ - glsanum[1] + glsanum[2] + glsanum[3] - glsa_list.append(glsanum) - else: - return + if any(str(date_from) in date for date in glsanum): + foundone = 1 + glsanum = glsanum[0] + " " + glsanum[1] + glsanum[2] + glsanum[3] + glsa_list.append(glsanum) + else: + break passt += 1 else: # Ignore table headers @@ -43,14 +42,26 @@ elif passt == 2: # Fetch package name and construct href - package = str(td.string).strip() - package = "%s" % (package, package) + if td.a: + # This is usually for GLSAs for + # multiple packages. + # FIXME: There has to be a better way + # to do that... + package = td.find_next(text=True).strip().split()[0] + extra_pkg = \ + td.find_next(text=True).strip() + " more)" + package = \ + "%s" \ + % (package, extra_pkg) + else: + package = str(td.string).strip() + package = "%s" % (package, package) package_list.append(package) passt += 1 elif passt == 3: # Fetch description - description = str(td.string).strip() + description = str(td.string).strip().replace(',','\,') description_list.append(description) passt += 1 @@ -66,6 +77,15 @@ # get dates from command line, else use now (time.time()) starttime = time.gmtime(time.time() - (60 * 60 * 24 * 1)) endtime = time.gmtime(time.time() + (60 * 60 * 24 * 31)) + if len(sys.argv) >=1: + if len(sys.argv) >= 2: + starttime = time.strptime(str(int(sys.argv[1])), "%Y%m%d") + endtime = time.strptime(str(int(sys.argv[2])), "%Y%m%d") + else: + print "Usage: " + os.path.basename(sys.argv[0]) + " [start-date] [end-date]" + print "dates must be passed in 'yyyymmdd' format" + print "if no dates are specified then it defaults to a date range of the last 31 days" + # Format the string to what we expect date_to = time.strftime("%Y%m", endtime) date_from = time.strftime("%Y%m", starttime)