Skip to content

Commit fed3de3

Browse files
committed
cporg: cleanup no-longer-used code from pre-AWS libraries.json
1 parent 5669989 commit fed3de3

File tree

1 file changed

+2
-74
lines changed

1 file changed

+2
-74
lines changed

adabot/update_cp_org_libraries.py

Lines changed: 2 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,11 @@
2121
# THE SOFTWARE.
2222

2323
import argparse
24-
import base64
2524
import datetime
2625
import inspect
2726
import json
2827
import os
2928
import re
30-
import sh
31-
from sh.contrib import git
32-
import sys
3329

3430
from adabot.lib import common_funcs
3531
from adabot.lib import circuitpython_library_validators as cpy_vals
@@ -49,6 +45,7 @@
4945

5046
sort_re = re.compile("(?<=\(Open\s)(.+)(?=\sdays)")
5147

48+
5249
def get_open_issues_and_prs(repo):
5350
""" Retreive all of the open issues (minus pull requests) for the repo.
5451
"""
@@ -86,6 +83,7 @@ def get_open_issues_and_prs(repo):
8683

8784
return open_issues, open_pull_requests
8885

86+
8987
def get_contributors(repo):
9088
contributors = []
9189
reviewers = []
@@ -125,74 +123,6 @@ def get_contributors(repo):
125123

126124
return contributors, reviewers, merged_pr_count
127125

128-
def update_json_file(json_string):
129-
""" Uses GitHub API to do the following:
130-
- Creates branch on fork 'adafruit-adabot/circuipython-org'
131-
- Updates '_data/libraries.json'
132-
- Creates pull request from fork to upstream
133-
134-
Note: adapted from Scott Shawcroft's code found here
135-
https://github.com/adafruit/circuitpython/blob/master/tools/build_board_info.py
136-
"""
137-
master_url = "/repos/adafruit/circuitpython-org/"
138-
fork_url = "/repos/adafruit-adabot/circuitpython-org/"
139-
commit_date = datetime.date.today()
140-
branch_name = "libraries_update_" + commit_date.strftime("%d-%b-%y")
141-
142-
response = github.get(master_url + "git/refs/heads/master")
143-
if not response.ok:
144-
raise RuntimeError(
145-
"Failed to retrieve master sha:\n{}".format(response.text)
146-
)
147-
commit_sha = response.json()["object"]["sha"]
148-
149-
response = github.get(
150-
master_url + "contents/_data/libraries.json?ref=" + commit_sha
151-
)
152-
if not response.ok:
153-
raise RuntimeError(
154-
"Failed to retrieve libraries.json sha:\n{}".format(response.text)
155-
)
156-
blob_sha = response.json()["sha"]
157-
158-
branch_info = {
159-
"ref": "refs/heads/" + branch_name,
160-
"sha": commit_sha
161-
}
162-
response = github.post(fork_url + "git/refs", json=branch_info)
163-
if not response.ok and response.json()["message"] != "Reference already exists":
164-
raise RuntimeError(
165-
"Failed to create branch:\n{}".format(response.text)
166-
)
167-
168-
commit_msg = "Automated Libraries update for {}".format(commit_date.strftime("%d-%b-%y"))
169-
content = json_string.encode("utf-8") + b"\n"
170-
update_json = {
171-
"message": commit_msg,
172-
"content": base64.b64encode(content).decode("utf-8"),
173-
"sha": blob_sha,
174-
"branch": branch_name
175-
}
176-
response = github.put(fork_url + "contents/_data/libraries.json",
177-
json=update_json)
178-
if not response.ok:
179-
raise RuntimeError(
180-
"Failed to update libraries.json:\n{}".format(response.text)
181-
)
182-
183-
pr_info = {
184-
"title": commit_msg,
185-
"head": "adafruit-adabot:" + branch_name,
186-
"base": "master",
187-
"body": commit_msg,
188-
"maintainer_can_modify": True
189-
}
190-
response = github.post(master_url + "pulls", json=pr_info)
191-
if not response.ok:
192-
raise RuntimeError(
193-
"Failed to create pull request:\n{}".format(response.text)
194-
)
195-
196126

197127
if __name__ == "__main__":
198128
cmd_line_args = cmd_line_parser.parse_args()
@@ -202,7 +132,6 @@ def update_json_file(json_string):
202132
run_time = datetime.datetime.now()
203133

204134
working_directory = os.path.abspath(os.getcwd())
205-
#cp_org_dir = os.path.join(working_directory, ".cp_org")
206135

207136
startup_message = [
208137
"Run Date: {}".format(run_time.strftime("%d %B %Y, %I:%M%p"))
@@ -320,7 +249,6 @@ def update_json_file(json_string):
320249
}
321250
json_obj = json.dumps(build_json, indent=2)
322251

323-
#update_json_file(json_obj)
324252
if local_file_output:
325253
with open(output_filename, "w") as json_file:
326254
json.dump(build_json, json_file, indent=2)

0 commit comments

Comments
 (0)