Attention List #4

Closed
sgode wants to merge 16 commits from (deleted):attention_list into main
Showing only changes of commit 92a057cb1b - Show all commits

95
tools/attention_list.py Normal file
View File

@ -0,0 +1,95 @@
#!/usr/bin/python
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import logging
import requests
import json
def main():
parser = argparse.ArgumentParser(
description='Bootstrap repositories.')
parser.add_argument(
'--orgs',
nargs='+',
default=['docs'],
help='One or more organizations to be queried for failed Pull '
'Requests.\n'
'Default: [docs]'
)
parser.add_argument(
'--token',
default='682ac3d176cf614cec4ecf9c8392880c89d07488',
help='API Token'
)
parser.add_argument(
'--url',
default='https://gitea.eco.tsi-dev.otc-service.com/api/v1/',
help='Base URL for API request.'
)
args = parser.parse_args()
# logging.basicConfig(level=logging.DEBUG)
path = 'orgs/docs/repos?limit=50&page='
headers = {}
headers['accept'] = 'application/json'
headers['Authorization'] = 'token ' + args.token
repositories = []
i = 1
while True:
try:
url = args.url + path + str(i)
res = requests.request('GET', url=url, headers=headers)
if res.json():
for repo in res.json():
repositories.append(repo)
i+=1
continue
Outdated
Review

actually instead of that I was expecting rather going through current metadata analyzing only repositories that we care about (smth like in any other script). Please adapt to to consume metadata and rather take parameters “environment” which is then set in the metadata

actually instead of that I was expecting rather going through current metadata analyzing only repositories that we care about (smth like in any other script). Please adapt to to consume metadata and rather take parameters "environment" which is then set in the metadata
Outdated
Review

we added the option to provide the token as metadata. Do you think the other stuff should also be added there or what did you mean?

Regarding the git sources: We build the script to use it as a general tool. If it should gather the data from metadata, we will do this or try to do this.

we added the option to provide the token as metadata. Do you think the other stuff should also be added there or what did you mean? Regarding the git sources: We build the script to use it as a general tool. If it should gather the data from metadata, we will do this or try to do this.
else:
break
except Exception as e:
print("An error has occured: " + str(e))
print("The request status is: " + str(res.status_code) + " | " + str(res.reason))
break
pull_path = 'repos/docs/'
pulls = []
for repo in repositories:
try:
url = args.url + pull_path + repo['name'] + '/pulls?state=open'
res = requests.request('GET', url=url, headers=headers)
if res.json():
for pull in res.json():
pulls.append(pull)
continue
else:
continue
except Exception as e:
print("An error has occured: " + str(e))
print("The request status is: " + str(res.status_code) + " | " + str(res.reason))
break
# print(len(pulls))
if __name__ == '__main__':
main()