delete test gist that is created by --check-github#3031
Merged
migueldiascosta merged 1 commit intoeasybuilders:developfrom Sep 24, 2019
Merged
delete test gist that is created by --check-github#3031migueldiascosta merged 1 commit intoeasybuilders:developfrom
migueldiascosta merged 1 commit intoeasybuilders:developfrom
Conversation
Member
Author
|
I had a whole bunch of these test gists, here's a script to clean them up if you have too... from easybuild.base.rest import RestClient
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.github import GITHUB_API_URL, HTTP_STATUS_OK, fetch_github_token
HTTP_DELETE_OK = 204
username = 'boegel'
token = fetch_github_token(username)
gh = RestClient(GITHUB_API_URL, username=username, token=token)
gists_to_delete = []
cur_page = 1
while True:
status, gists = gh.gists.get(per_page=100, page=cur_page)
print("Collecting gists (page %d), found %d gists to delete" % (cur_page, len(gists_to_delete)))
if gists:
cur_page += 1
for gist in gists:
if gist['description'] == 'test123' and gist['files'].keys() == ['test.txt']:
gists_to_delete.append(gist)
else:
break
cnt = len(gists_to_delete)
print("Deleting %d gists..." % cnt)
for idx, gist in enumerate(gists_to_delete):
gh.gists[gist["id"]].delete()
print("Deleted %d/%s" % (idx, cnt)) |
migueldiascosta
approved these changes
Sep 24, 2019
Member
migueldiascosta
left a comment
There was a problem hiding this comment.
lgtm, and works as advertised
Member
|
Going in, thanks @boegel! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--check-githubcreates a test gist, but doesn't clean it up afterwards, fixed here...