|
7 | 7 | from github import Github |
8 | 8 | import json |
9 | 9 |
|
| 10 | + |
| 11 | +# Configure the logger |
| 12 | +logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') |
| 13 | + |
10 | 14 | # Get the GitHub token from the environment variable |
11 | 15 | access_token = os.environ.get('GITHUB_TOKEN') |
12 | 16 |
|
13 | 17 | g = Github(access_token) |
14 | 18 | repo = g.get_repo("vkt1414/ExtensionsIndex") |
15 | 19 |
|
16 | | -# Define the target extension name |
17 | | -slicerExtensionName = 'IDCBrowser' |
18 | | - |
| 20 | +logging.info("Calling slicer cdash api to get the build info for all extensions") |
19 | 21 | # API data retrieval and processing |
20 | 22 | api_url = f"https://slicer.cdash.org/api/v1/index.php?project=SlicerPreview" |
21 | 23 | response = requests.get(api_url) |
|
53 | 55 | api_df['ErrorSum'] = api_df['ConfigureErrors'] + api_df['CompilationErrors'] + api_df['TestFail'] |
54 | 56 | api_df['WarningSum'] = api_df['ConfigureWarnings'] + api_df['CompilationWarnings'] |
55 | 57 | else: |
56 | | - print(f"Failed to retrieve data. Status code: {response.status_code}") |
| 58 | + logging.error(f"Failed to retrieve data. Status code: {response.status_code}") |
57 | 59 |
|
58 | 60 | # Process the CODEOWNERS file |
59 | 61 | # url = "https://raw.githubusercontent.com/vkt1414/ExtensionsIndex/main/CODEOWNERS" |
|
184 | 186 | # Check if the issue title matches the pattern and is not in the list |
185 | 187 | for issue in existing_issues: |
186 | 188 | if header in issue.title and extension_name not in extensions_with_issues_list: |
187 | | - print(f'Closing issue for {extension_name}') |
| 189 | + logging.info(f'Closing issue for {extension_name}') |
188 | 190 | # Add a comment |
189 | 191 | issue.create_comment("No errors or warnings found anymore, so closing this issue.") |
190 | 192 | # Close the issue |
|
206 | 208 | while True: |
207 | 209 | try: |
208 | 210 | new_issue = repo.create_issue(title=header, body=body) |
209 | | - print(f"Issue created for {extension_name} - {new_issue.html_url}") |
| 211 | + logging.info(f"Issue created for {extension_name} - {new_issue.html_url}") |
210 | 212 | time.sleep(30) |
211 | 213 | break |
212 | 214 | except Exception as e: |
213 | | - print(header) |
214 | | - print(body) |
215 | | - print(f"Failed to create issue: {e}") |
| 215 | + logging.error(header) |
| 216 | + logging.error(body) |
| 217 | + logging.error(f"Failed to create issue: {e}") |
216 | 218 | time.sleep(30) |
0 commit comments