From 257878e6cb958e79af470a05e186b0e21d298641 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 11 May 2018 17:52:11 +0200 Subject: [PATCH 1/2] Typoe --- app/scripts/maintenancePing/maintenance_ping_body | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/scripts/maintenancePing/maintenance_ping_body b/app/scripts/maintenancePing/maintenance_ping_body index d90a37e..0a21c25 100644 --- a/app/scripts/maintenancePing/maintenance_ping_body +++ b/app/scripts/maintenancePing/maintenance_ping_body @@ -16,4 +16,4 @@ Either don't do anything, or add a comment to explicitly state that you do not i ## You wish to become the new maintainer of this app ? :smile: -You are welcome and free to comment in this thread that you wish to become the new maintainer, amd/or to create the corresponding pull request to fix this issue ! (If you do not already have commit rights on this repo, we can then arrange things with the rest of the app team. :wink:) Once this issue is closed, the app will then be flagged again as *maintained* ! +You are welcome and free to comment in this thread that you wish to become the new maintainer, and/or to create the corresponding pull request to fix this issue ! (If you do not already have commit rights on this repo, we can then arrange things with the rest of the app team. :wink:) Once this issue is closed, the app will then be flagged again as *maintained* ! From 7c45f7fbad0d8ec5583ebb56084072609583b66a Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 11 May 2018 17:52:35 +0200 Subject: [PATCH 2/2] Use global credentials from settings at root --- app/scripts/maintenancePing/maintenancePing.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/scripts/maintenancePing/maintenancePing.py b/app/scripts/maintenancePing/maintenancePing.py index 16569d9..844b336 100755 --- a/app/scripts/maintenancePing/maintenancePing.py +++ b/app/scripts/maintenancePing/maintenancePing.py @@ -5,14 +5,16 @@ import requests import json from functools import partial -LOGIN=open("./login").read().strip() -TOKEN=open("./token").read().strip() +import sys +sys.path.insert(0, '../..') +from settings import GITHUB_USER, GITHUB_TOKEN + MAINTENANCE_PING_BODY=open("./maintenance_ping_body").read().strip() UNMAINTAINED_WARNING=open("./unmaintained_warning").read().strip() def get_github(uri): with requests.Session() as s: - s.headers.update({"Authorization": "token {}".format(TOKEN)}) + s.headers.update({"Authorization": "token {}".format(GITHUB_TOKEN)}) r = s.get("https://api.github.com" + uri) #assert r.status_code == 200, "Couldn't get {uri} . Reponse : {text}".format(uri=uri, text=r.text) @@ -69,14 +71,14 @@ def create_maintenance_ping(repo): } with requests.Session() as s: - s.headers.update({"Authorization": "token {}".format(TOKEN)}) + s.headers.update({"Authorization": "token {}".format(GITHUB_TOKEN)}) s.post(api_url, json.dumps(issue)) def warn_unmaintained_if_needed(repo, issue): issue_id = issue["number"] comments = get_github("/repos/{repo}/issues/{id}/comments".format(repo=repo, id=issue_id)) - existing_warning = [ c for c in comments if c["user"]["login"] == LOGIN + existing_warning = [ c for c in comments if c["user"]["login"] == GITHUB_USER and c["body"].startswith(UNMAINTAINED_WARNING[:20]) ] # Nothing to do if there's already a warning about unmaintenained status... if existing_warning: @@ -87,7 +89,7 @@ def warn_unmaintained_if_needed(repo, issue): .format(repo=repo, id=issue_id) comment = { "body": UNMAINTAINED_WARNING } with requests.Session() as s: - s.headers.update({"Authorization": "token {}".format(TOKEN)}) + s.headers.update({"Authorization": "token {}".format(GITHUB_TOKEN)}) s.post(api_url, json.dumps(comment)) @@ -163,5 +165,6 @@ def main(): print("--------") for app in to_ping: print(app) + #todo[app](app) main()