community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1867028 - in /comdev/reporter.apache.org/trunk: scripts/rapp/drafts.py scripts/rapp/kibble.py site/wizard/kibble.py
Date Mon, 16 Sep 2019 22:19:21 GMT
Author: sebb
Date: Mon Sep 16 22:19:21 2019
New Revision: 1867028

URL: http://svn.apache.org/viewvc?rev=1867028&view=rev
Log:
Shut files after use

Modified:
    comdev/reporter.apache.org/trunk/scripts/rapp/drafts.py
    comdev/reporter.apache.org/trunk/scripts/rapp/kibble.py
    comdev/reporter.apache.org/trunk/site/wizard/kibble.py

Modified: comdev/reporter.apache.org/trunk/scripts/rapp/drafts.py
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/scripts/rapp/drafts.py?rev=1867028&r1=1867027&r2=1867028&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/scripts/rapp/drafts.py (original)
+++ comdev/reporter.apache.org/trunk/scripts/rapp/drafts.py Mon Sep 16 22:19:21 2019
@@ -54,7 +54,8 @@ def fetch(environ, user):
     if os.path.exists(os.path.join(DRAFTS_DIR, filename)):
         project = m.group(1)
         if has_access(user, project):
-            report = open(os.path.join(DRAFTS_DIR, filename), "r").read()
+            with open(os.path.join(DRAFTS_DIR, filename), "r") as f:
+                report = f.read()
             return {'report': report}
     return {}
 
@@ -157,7 +158,8 @@ def forgotten(environ, user):
                             applicables.append(filename)
                     if applicables:
                         has_draft = True
-                        last_report = open(os.path.join(DRAFTS_DIR, applicables[-1]), "r").read()
+                        with open(os.path.join(DRAFTS_DIR, applicables[-1]), "r") as f:
+                            last_report = f.read()
                         e, p, t, u = applicables[-1].split('-', 3)
                         ts = int(t)
                         last_author = u.replace('.draft', '')

Modified: comdev/reporter.apache.org/trunk/scripts/rapp/kibble.py
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/scripts/rapp/kibble.py?rev=1867028&r1=1867027&r2=1867028&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/scripts/rapp/kibble.py (original)
+++ comdev/reporter.apache.org/trunk/scripts/rapp/kibble.py Mon Sep 16 22:19:21 2019
@@ -1,5 +1,5 @@
 #!/usr/bin/env python3
-""" Script for fetching somekibble data for reports """
+""" Script for fetching some kibble data for reports """
 import requests
 import json
 import time
@@ -7,7 +7,8 @@ import re
 import os
 
 RAO_HOME = '/var/www/reporter.apache.org'
-TOKEN = open('/usr/local/etc/tokens/kibble.txt').read().strip()
+with open("/usr/local/etc/tokens/kibble.txt", "r") as f:
+    TOKEN = f.read().strip()
 
 def stats(project, jira = [], mlid = None):
     BEFORE = int(time.time() - (91*86400))
@@ -21,9 +22,9 @@ def stats(project, jira = [], mlid = Non
     runit = True
     js = {}
     if (os.path.exists(cache_file) and os.path.getmtime(cache_file) > (time.time() - 86400)):
-        output = open(cache_file, "r").read()
         try:
-            js = json.loads(output)
+            with open(cache_file, "r") as json_file:
+                js = json.load(json_file)
             assert('prs' in js)
             runit = False
         except:

Modified: comdev/reporter.apache.org/trunk/site/wizard/kibble.py
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/kibble.py?rev=1867028&r1=1867027&r2=1867028&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/kibble.py (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/kibble.py Mon Sep 16 22:19:21 2019
@@ -1,5 +1,5 @@
 #!/usr/bin/env python3
-""" Script for fetching somekibble data for reports """
+""" Script for fetching some kibble data for reports """
 import requests
 import cgi
 import json
@@ -10,7 +10,8 @@ import sys
 
 BEFORE = int(time.time() - (90*86400))
 RAO_HOME = '/var/www/reporter.apache.org'
-TOKEN = open('/usr/local/etc/tokens/kibble.txt').read().strip()
+with open("/usr/local/etc/tokens/kibble.txt", "r") as f:
+    TOKEN = f.read().strip()
 
 def main():
     form = cgi.FieldStorage()
@@ -30,9 +31,9 @@ def main():
     cache_file = '/tmp/kibble-cache-%s.json' % project
     runit = True
     if (os.path.exists(cache_file) and os.path.getmtime(cache_file) > (time.time() - 86400)):
-        output = open(cache_file, "r").read()
         try:
-            js = json.loads(output)
+            with open(cache_file, "r") as json_file:
+                js = json.load(json_file)
             assert('prs' in js)
             runit = False
         except:



Mime
View raw message