community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject svn commit: r1664682 - /comdev/reporter.apache.org/readjira.py
Date Fri, 06 Mar 2015 17:38:20 GMT
Author: humbedooh
Date: Fri Mar  6 17:38:20 2015
New Revision: 1664682

URL: http://svn.apache.org/r1664682
Log:
cron job for refreshing JIRA stats

Added:
    comdev/reporter.apache.org/readjira.py

Added: comdev/reporter.apache.org/readjira.py
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/readjira.py?rev=1664682&view=auto
==============================================================================
--- comdev/reporter.apache.org/readjira.py (added)
+++ comdev/reporter.apache.org/readjira.py Fri Mar  6 17:38:20 2015
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+
+import re, os, json, urllib2, base64, time
+from os import listdir
+from os.path import isfile, join
+
+mypath = "/var/www/reporter.apache.org/data/JIRA"
+myfiles = [ f for f in listdir(mypath) if isfile(join(mypath,f)) ]
+
+jirapass = ""
+with open("/var/www/reporter.apache.org/data/jirapass.txt", "r") as f:
+    jirapass = f.read().strip()
+    f.close()
+    
+def getJIRAS(project):
+    refresh = True
+    if refresh:
+        base64string = base64.encodestring('%s:%s' % ('githubbot', jirapass))[:-1]
+
+        try:
+            req = req = urllib2.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(urllib2.urlopen(req).read())
+            req = req = urllib2.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(urllib2.urlopen(req).read())
+            with open("/var/www/reporter.apache.org/data/JIRA/%s.json" % project, "w") as
f:
+                f.write(json.dumps([cdata['total'], rdata['total'], project]))
+                f.close()
+            return cdata['total'], rdata['total'], project
+        except Exception as err:
+            with open("/var/www/reporter.apache.org/data/JIRA/%s.json" % project, "w") as
f:
+                f.write(json.dumps([0,0,None]))
+                f.close()
+            return 0,0, None
+
+for project in myfiles:
+    jiraname = project.replace(".json", "")
+    print("Refreshing JIRA stats for " + jiraname)
+    getJIRAS(jiraname)
+    time.sleep(2)
+    
\ No newline at end of file



Mime
View raw message