Return-Path: X-Original-To: apmail-community-commits-archive@minotaur.apache.org Delivered-To: apmail-community-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DCD0A19931 for ; Sat, 12 Mar 2016 15:00:37 +0000 (UTC) Received: (qmail 40521 invoked by uid 500); 12 Mar 2016 15:00:37 -0000 Delivered-To: apmail-community-commits-archive@community.apache.org Received: (qmail 40495 invoked by uid 500); 12 Mar 2016 15:00:37 -0000 Mailing-List: contact commits-help@community.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@community.apache.org Delivered-To: mailing list commits@community.apache.org Received: (qmail 40486 invoked by uid 99); 12 Mar 2016 15:00:37 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 12 Mar 2016 15:00:37 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 49FC6C64E0 for ; Sat, 12 Mar 2016 15:00:37 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.999 X-Spam-Level: X-Spam-Status: No, score=0.999 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id DOxZ7oNiohvx for ; Sat, 12 Mar 2016 15:00:36 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with ESMTP id 9827C5F1B3 for ; Sat, 12 Mar 2016 15:00:35 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id A8A90E0185 for ; Sat, 12 Mar 2016 15:00:34 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 953E93A0046 for ; Sat, 12 Mar 2016 15:00:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1734712 - /comdev/reporter.apache.org/trunk/scripts/readjira.py Date: Sat, 12 Mar 2016 15:00:34 -0000 To: commits@community.apache.org From: sebb@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160312150034.953E93A0046@svn01-us-west.apache.org> Author: sebb Date: Sat Mar 12 15:00:34 2016 New Revision: 1734712 URL: http://svn.apache.org/viewvc?rev=1734712&view=rev Log: Add code to handle JIRA downtime Modified: comdev/reporter.apache.org/trunk/scripts/readjira.py Modified: comdev/reporter.apache.org/trunk/scripts/readjira.py URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/scripts/readjira.py?rev=1734712&r1=1734711&r2=1734712&view=diff ============================================================================== --- comdev/reporter.apache.org/trunk/scripts/readjira.py (original) +++ comdev/reporter.apache.org/trunk/scripts/readjira.py Sat Mar 12 15:00:34 2016 @@ -44,6 +44,14 @@ if py3: else: base64string = base64.encodestring(__AUTHSTRING)[:-1] # python2 adds a trailing eol +JIRATIMEOUT=90 # This may need to be adjusted +jiraerrors = 0 # count how many errors occurred +def handleError(): + global jiraerrors + jiraerrors += 1 + if jiraerrors > 5: + raise Exception("Too many errors - quitting") + def getProjects(): """Update the list of projects in data/JIRA/projects.json""" PROJECT_JSON = "%s/data/JIRA/projects.json" % MYHOME @@ -54,23 +62,23 @@ def getProjects(): try: req = Request("https://issues.apache.org/jira/rest/api/2/project.json") req.add_header("Authorization", "Basic %s" % base64string) - x = json.loads(urlopen(req).read().decode('utf-8')) + x = json.loads(urlopen(req, timeout=JIRATIMEOUT).read().decode('utf-8')) with open(PROJECT_JSON, "w") as f: json.dump(x, f, indent=1) f.close() print("Created %s" % PROJECT_JSON) except Exception as e: print("Err: could not refresh %s: %s" % (PROJECT_JSON, e)) - pass + handleError() def getJIRAS(project): try: req = Request("""https://issues.apache.org/jira/rest/api/2/search?jql=project%20=%20'""" + project + """'%20AND%20created%20%3E=%20-91d""") req.add_header("Authorization", "Basic %s" % base64string) - cdata = json.loads(urlopen(req).read().decode('utf-8')) + cdata = json.loads(urlopen(req, timeout=JIRATIMEOUT).read().decode('utf-8')) req = Request("""https://issues.apache.org/jira/rest/api/2/search?jql=project%20=%20'""" + project + """'%20AND%20resolved%20%3E=%20-91d""") req.add_header("Authorization", "Basic %s" % base64string) - rdata = json.loads(urlopen(req).read().decode('utf-8')) + rdata = json.loads(urlopen(req, timeout=JIRATIMEOUT).read().decode('utf-8')) with open("%s/data/JIRA/%s.json" % (MYHOME, project), "w") as f: json.dump([cdata['total'], rdata['total'], project], f, indent=1) f.close() @@ -80,6 +88,7 @@ def getJIRAS(project): with open("%s/data/JIRA/%s.json" % (MYHOME, project), "w") as f: json.dump([0,0,None], f, indent=1) f.close() + handleError() return 0,0, None getProjects()