fix: Use urllib instead of requests

Simply because "too much effort" to add another library pfft
This commit is contained in:
Gavin D'souza 2021-08-25 13:25:40 +05:30
parent e01ef7ff52
commit fe060bda0e

View file

@ -1,11 +1,18 @@
import json
import os
import re
import requests
import shlex
import subprocess
import sys
import urllib.request
def get_files_list(pr_number):
req = urllib.request.Request(f"https://api.github.com/repos/frappe/frappe/pulls/{pr_number}/files")
res = urllib.request.urlopen(req)
dump = json.loads(res.read().decode('utf8'))
return [change["filename"] for change in dump]
def get_output(command, shell=True):
print(command)
command = shlex.split(command)
@ -31,8 +38,7 @@ if __name__ == "__main__":
pr_number = os.environ.get("PR_NUMBER")
if not files_list and pr_number:
res = requests.get(f"https://api.github.com/repos/frappe/frappe/pulls/{pr_number}/files")
files_list = [f["filename"] for f in res.json()]
files_list = get_files_list(pr_number=pr_number)
if not files_list:
print("No files' changes detected. Build is shutting")