Automated weekly inventory report generator for York University's Making & Media Creation Lab (MMCL). This script fetches equipment data from LibCal's API, merges availability status, and generates Excel and CSV reports.
The automatially-scheduled should will create datestamped files in the output/ directory.
- 🤖 Automated Weekly Reports: Runs every Friday at 9:00 AM EST via GitHub Actions
- 📊 Dual Format Output: Generates both Excel (.xlsx) and CSV files
- 🔄 Checkout Status Tracking: Shows which items are checked out vs. available
- 🧹 Automatic Cleanup: Deletes reports older than 3 months
- 🔒 Secure Credentials: Uses GitHub Secrets for API credentials
The workflow runs automatically:
- Every Friday at 9:00 AM EST (1:00 PM UTC)
- Can also be triggered manually from the Actions tab
- Authentication: Connects to LibCal API using OAuth credentials
- Data Collection:
- Fetches complete equipment list from
/equipment/items/{id} - Fetches checkout status from
/equipment/items/status/{id}
- Fetches complete equipment list from
- Data Merge: Combines both datasets using equipment ID and barcode
- Report Generation: Creates formatted Excel and CSV files
- Cleanup: Removes reports older than 90 days
- Commit: Pushes reports to the repository
Reports are saved in the output/ directory with filenames like:
2024-11-22_Loanable_Inventory.xlsx2024-11-22_Loanable_Inventory.csv
Each report includes:
- Item Name
- Barcode Number
- Asset Number
- Serial Number
- Checkout Status (CHECKED OUT / Available)
- DSA Notes (empty column for manual annotation)
- Current Notes on Damage
To run the script locally:
# Install dependencies
pip install -r requirements.txt
# Set environment variables
export LIBCAL_CLIENT_ID="your_client_id"
export LIBCAL_CLIENT_SECRET="your_client_secret"
export LIBCAL_LOCATION_ID="2632"
# Run the script
python generate_inventory.py- Check that GitHub Actions is enabled for your repository
- Verify the workflow file is in
.github/workflows/ - Check the Actions tab for any error messages
- Verify your secrets are set correctly in repository settings
- Ensure the client ID and secret are valid and active in LibCal
- Check that the API credentials haven't expired
- Verify the
LIBCAL_LOCATION_IDmatches your LibCal location - Check that the API account has appropriate permissions
- Review the workflow logs in the Actions tab for specific errors
The workflow only commits files if there are changes. If the inventory hasn't changed since the last run, no new commit will be created. The reports are still generated and available as workflow artifacts.
Edit the cron expression in .github/workflows/weekly-inventory.yml:
schedule:
- cron: '0 13 * * 5' # Current: Friday at 1:00 PM UTCCron format: minute hour day-of-month month day-of-week
Examples:
0 13 * * 1: Monday at 1:00 PM UTC0 13 * * 1,5: Monday and Friday at 1:00 PM UTC30 14 * * 5: Friday at 2:30 PM UTC
Modify the days_threshold parameter in generate_inventory.py:
cleanup_old_files(output_dir, days_threshold=90) # Change 90 to desired daysUpdate the LIBCAL_LOCATION_ID variable in your repository settings, or modify the default in the script.
This project uses Springshare's LibCal API 1.1:
- Equipment Items:
/equipment/items/{id} - Equipment Status:
/equipment/items/status/{id}
For more information, see the LibCal API documentation in your LibCal admin interface.
For issues or questions:
- Check the Actions tab for workflow run logs
- Review the troubleshooting section above
- Consult LibCal API documentation
- Contact MMCL technical staff
Internal use for York University Libraries' Making & Media Creation Lab.