This repository contains Python scripts to:
- Fetch a list of INDI 3rd-party drivers and extract their version and latest Git commit hash.
- Retrieve a list of Debian-packaged INDI drivers, extracting their Debian version and corresponding Git hash.
This script interacts with the GitHub API to retrieve information about drivers from the indi-3rdparty
repository. It fetches driver names, their versions from changelog files, and the latest commit hashes along with the associated commit dates. The script efficiently handles GitHub rate limits and utilizes basic authentication with a GitHub Personal Access Token.
Make sure you have the following installed:
- Python 3.x
requests
library- Installation:
- Debian and Debian-Based Distros (like Ubuntu):
- Using apt
sudo apt install python3-requests
- Using pip
pip3 install requests
- Debian and Debian-Based Distros (like Ubuntu):
- Installation:
-
Set your GitHub Personal Access Token as an environment variable:
export GITHUB_TOKEN='your_personal_access_token'
-
Run the script:
python task_1.py
or
./task_1.py
This will initiate the process of fetching driver information and display it in the console.
The main entry point of the script that initiates the fetching process of driver information.
A wrapper function to perform GET requests that respect GitHub's rate limits. It retries requests if the rate limit is exceeded.
-
Arguments:
url
: The URL to send the GET request to.headers
: Optional headers for the GET request.
-
Returns: The response from the GET request.
Fetches a list of drivers from the GitHub repository, extracting information such as driver name, version, and the latest commit hash.
- Returns: A list of dictionaries containing driver information.
Fetches the changelog file for a specific driver.
-
Arguments:
driver_name
: The name of the driver whose changelog is being fetched.
-
Returns: The content of the changelog file if found, otherwise
None
.
Extracts the version number from the changelog content.
-
Arguments:
file_content
: The content of the changelog file.
-
Returns: The extracted version, or "Unknown" if not found.
The script uses a GitHub Personal Access Token for authentication. You must set this token as an environment variable named GITHUB_TOKEN
before running the script.
The script handles various exceptions, including:
- Rate limit errors (HTTP status 403)
- Timeout errors
- General request exceptions
In case of an error, a message will be printed to standard error, and the script will attempt to retry if applicable.
This script interacts with the Salsa GitLab API to retrieve information about Debian-packaged INDI drivers. It fetches the package names, their Debian version from changelog files, and the corresponding Git commit hash. The script allows for asynchronous requests using aiohttp
to improve performance, and it provides an option to skip certain packages or directories by specifying an ignore file.
Make sure you have the following installed:
- Python 3.6+
aiohttp
library- Installation:
- Debian and Debian-Based Distros (like Ubuntu):
- Using apt
sudo apt install python3-aiohttp
- Using pip
pip3 install aiohttp
- Debian and Debian-Based Distros (like Ubuntu):
- Installation:
-
Set up the Salsa GitLab API token by configuring it in the script or passing it via environment variables.
export GITLAB_TOKEN='your_personal_access_token' # Salsa access token
-
Run the script:
- Note: The
[IGNORE DIRS FILE]
is optional. It contains the directories you want to skip during the fetch process. If not provided, the script defaults to fetch all.
python task_2.py [IGNORE DIRS FILE]
or
./task_2.py [IGNORE DIRS FILE]
- Example:
python task_2.py ignore_dirs.txt OR ./task_2.py ignore_dirs.txt
where
ignore_dirs.txt
is a file containing all the directories you'd like the program to ignore. - Note: The
This will fetch the Debian-packaged INDI drivers' names, versions from changelogs, and their Git commit hashes, printing them to the console.
The entry point of the script, responsible for orchestrating the fetch process and outputting driver information.
Fetches a list of projects from the Salsa GitLab API under the Debian Astro team, specifically targeting INDI-related packages.
- Returns: A list of project names available in the Debian Astro team repository.
Retrieves the Debian version of the package and the corresponding Git hash by parsing the changelog file of the provided project.
-
Arguments:
project_name
: The name of the project whose changelog and version are being fetched.
-
Returns: A dictionary containing the project name, version, and Git commit hash.
Extracts the version number from the changelog content.
-
Arguments:
changelog_content
: The content of the changelog file.
-
Returns: The extracted version or "Unknown" if not found.
Attempts to retrieve the changelog file from different branches of the project's repository.
-
Arguments:
project_name
: The name of the project whose changelog is being retrieved.branch
: The branch to look for the changelog file in.
-
Returns: The content of the changelog file or
None
if not found.
Retrieves the default branch of the project.
-
Arguments:
project_name
: The name of the project.
-
Returns: The name of the default branch, typically "master" or "main".
Parses the ignore file to get a list of directories or projects to skip during the fetch process.
-
Arguments:
ignore_file_path
: Path to the file that contains directories or project names to be ignored.
-
Returns: A list of directories or projects to ignore.
You must configure a GitLab API token for accessing private repositories or avoiding API rate limits. The token can be set as an environment variable named GITLAB_TOKEN
.
The script handles various potential errors, including:
- Network errors (e.g., connection timeouts)
- Handling unavailable changelog files
- Handling non-existent or empty branches
In case of an error, the script logs the message and skips the problematic project or directory, continuing the fetch process for others.