-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add initial python script #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add initial python script #23
Conversation
**Details**: Add initial v2query.py script which generates a json file containing all the project items for a given team NEEDS CLEANUP and to be turned into a class **Related Issue(s)**: closes #2 Signed-off-by: Roger Barker <roger.barker@swirldslabs.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds an initial Python script (v2query.py) that generates a JSON file containing project items for a specified team by querying GitHub organizations, filtering projects by team name, fetching items via a CLI fallback, and consolidating them into a single file.
- Implements GitHub API calls to retrieve organizations and projects.
- Uses a command line tool to fetch project items and consolidates the results into a JSON file.
- Cleans up temporary files after processing.
# so we use a subprocess call or GitHub REST if available. | ||
# We'll fallback to CLI for now. | ||
out_path = TEMP_DIR / f"{org}-{number}.items.json" | ||
os.system( f'gh project item-list --owner "{org}" {number} --format json > "{out_path}"') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using subprocess.run instead of os.system for improved error handling and to reduce potential command injection risks.
os.system( f'gh project item-list --owner "{org}" {number} --format json > "{out_path}"') | |
with open(out_path, "w") as out_file: | |
subprocess.run( | |
["gh", "project", "item-list", "--owner", org, str(number), "--format", "json"], | |
stdout=out_file, | |
check=True | |
) |
Copilot uses AI. Check for mistakes.
"https://api.github.com/graphql", | ||
json={"query": query, "variables": {"login": org}}, | ||
headers=headers | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider checking the HTTP response status code before processing the JSON to ensure the API call succeeded.
) | |
) | |
if response.status_code != 200: | |
print(f"[red]Failed to fetch projects for org: {org}. HTTP {response.status_code}: {response.text}[/red]") | |
continue |
Copilot uses AI. Check for mistakes.
…rom-github-given-a-user-or-team
…rom-github-given-a-user-or-team
Details:
Add initial v2query.py script which generates a json file containing all the project items for a given team
NEEDS CLEANUP and to be turned into a class
Related Issue(s):
closes #2