This project provides a Golang based tool to automatically identify, delete, and manage old Python virtual environments (venvs) on your local computer. It also logs the paths of deleted environments and manages these logs by periodically cleaning up older entries.
-
Automatic Identification of Virtual Environments:
- Scans specified directories to find Python virtual environments (
venvor.venvfolders). - Deletes virtual environments that are older than a user-defined threshold (e.g., 30 days).
- Scans specified directories to find Python virtual environments (
-
Logging:
- Logs the paths of all deleted virtual environments.
- Logs are stored in a specified directory and are timestamped for easy reference.
-
Automated Log Cleanup:
- Periodically cleans up old log files based on user-defined retention policies.
- Provides a summary report after each cleanup, showing the logs retained and those deleted.
-
Summary Reporting:
- After each run, generates a summary report detailing:
- The paths of deleted virtual environments.
- The number of log files cleaned up.
- Any errors encountered during the process.
- After each run, generates a summary report detailing:
-
Clone the Repository:
git clone https://github.com/Ashad/envwipe.git cd envwipe -
Build the Project:
go build -o envwipe main.go
-
Configure the Script:
- Modify the
config.jsonfile to specify the directories to scan, the age threshold for deleting virtual environments, and log retention policies.
- Modify the
-
Run the Script:
./envwipe
-
Dry Run Mode:
- To see what would be deleted without actually deleting anything:
./envwipe --dry-run
- To see what would be deleted without actually deleting anything:
-
Specify a Custom Config File:
- Use a custom configuration file:
./envwipe --config /path/to/your/config.json
- Use a custom configuration file:
The config.json file allows you to customize the behavior of the script. Key settings include:
- Directories to Scan: Specify the directories where the script should look for virtual environments.
- Age Threshold: Define how old a virtual environment must be before it is considered for deletion.
- Log Retention Policy: Set how long logs should be kept before they are automatically deleted.
Example config.json:
{
"scanDirectories": [
"/path/to/projects",
"/another/path/to/scan"
],
"thresholdDays": 30,
"logDirectory": "/path/to/logs",
"logRetentionDays": 60
}Contributions are welcome! Please fork the repository and create a pull request with your changes.
This project is licensed under the MIT License.