# Quick Start Guide ## Choose Your Tool ### Option 1: Simple Batch Import (wrike_import.py) **Best for:** One-time imports, manual runs, testing ```bash # Install pip install requests # Run python wrike_import.py /path/to/json/files/ # That's it! Files processed and moved to Processed/ ``` --- ### Option 2: Real-time Monitor Service (wrike_monitor.py) **Best for:** Production, 24/7 monitoring, automatic processing ```bash # Install pip install -r requirements.txt # Configure (edit these lines in wrike_monitor.py): # Line 41: HOT_FOLDER = Path("your/input/folder") # Line 42: PROCESSED_FOLDER = Path("your/processed/folder") # Line 52: WRIKE_SPACE_ID = "your_space_id" # Line 79: REPORT_EMAILS = ["your@email.com"] # Run locally for testing python wrike_monitor.py # Deploy as service (see INSTALLATION.md) ``` --- ## Configuration Quick Reference ### wrike_monitor.py - Key Settings | Setting | Line | Description | |---------|------|-------------| | `HOT_FOLDER` | 41 | Input folder to watch | | `PROCESSED_FOLDER` | 42 | Where processed files go | | `FAILED_FOLDER` | 43 | Where failed files go | | `REPORTS_DIR` | 44 | Where reports are saved | | `WRIKE_TOKEN` | 49 | Your Wrike API token | | `WRIKE_SPACE_ID` | 52 | Target Wrike space ID | | `WRIKE_SPACE_NAME` | 53 | Space name (for logs) | | `REPORT_EMAILS` | 79 | Who gets daily reports | | `DAILY_REPORT_TIME` | 84 | When to send report (24h format) | | `CLEANUP_PROCESSED_HOURS` | 98 | Delete processed files after X hours | | `PERIODIC_SCAN_INTERVAL` | 88 | How often to scan for missed files | ### Custom Field IDs (Lines 57-68) Update these if you're using a different Wrike space with different custom field IDs. --- ## Example Workflows ### Workflow 1: Local Testing ```bash # 1. Create test folder mkdir -p ~/wrike-test/json_files # 2. Edit wrike_monitor.py # Set HOT_FOLDER = Path("/Users/yourname/wrike-test/json_files") # 3. Run monitor python wrike_monitor.py # 4. Drop JSON files into json_files/ # Watch them get processed automatically! ``` ### Workflow 2: Production Deployment ```bash # 1. Configure paths for production in wrike_monitor.py # 2. Copy to server scp wrike_monitor.py wrike-monitor.service server:/root/wrike-import/ # 3. SSH to server and install service ssh server sudo cp /root/wrike-import/wrike-monitor.service /etc/systemd/system/ sudo systemctl daemon-reload sudo systemctl enable wrike-monitor sudo systemctl start wrike-monitor # 4. Monitor logs sudo journalctl -u wrike-monitor -f # 5. Get daily reports at 7PM via email! ``` ### Workflow 3: Batch Import Existing Files ```bash # Use wrike_import.py for one-time batch python wrike_import.py /path/to/existing/json/files/ # All files processed and moved to Processed/ # Switch to wrike_monitor.py for ongoing monitoring ``` --- ## Testing Checklist Before deploying to production: - [ ] Test with sample JSON files locally - [ ] Verify folders/projects created correctly in Wrike - [ ] Check duplicate detection works (reprocess same file) - [ ] Confirm files move to Processed/ folder - [ ] Test failed file handling (drop invalid JSON) - [ ] Verify email settings (check inbox at report time) - [ ] Review custom field IDs match your space - [ ] Test with production paths (but staging space first!) --- ## Common Configuration Scenarios ### Scenario: Multiple Environments Create separate config files: ```python # wrike_monitor_staging.py - points to Staging space # wrike_monitor_production.py - points to LGL Team space ``` Or use environment variables: ```python import os WRIKE_SPACE_ID = os.environ.get('WRIKE_SPACE_ID', 'MQAAAABpz7l_') ``` ### Scenario: Different Report Times ```python # Morning report at 9AM DAILY_REPORT_TIME = "09:00" # Multiple reports per day - use schedule in setup_daily_reporting(): schedule.every().day.at("09:00").do(self.generate_daily_report) schedule.every().day.at("17:00").do(self.generate_daily_report) schedule.every().day.at("19:00").do(self.generate_daily_report) ``` ### Scenario: Longer File Retention ```python # Keep processed files for 7 days instead of 24 hours CLEANUP_PROCESSED_HOURS = 168 # 7 days * 24 hours ``` --- ## Troubleshooting Quick Fixes ### Files not being processed ```bash # Check folder permissions chmod 777 /your/input/folder # Check if monitor is running ps aux | grep wrike_monitor ``` ### Duplicates being created - Sequential processing is enabled (BATCH_SIZE=1, MAX_WORKERS=1) - Caches persist during runtime - Restart service if caches get stale: `sudo systemctl restart wrike-monitor` ### Email not sending - Check SMTP credentials in Config - Test manually: send test email from server - Check firewall allows SMTP port 587 ### High memory usage - Reduce BATCH_SIZE (line 82) - Increase PERIODIC_SCAN_INTERVAL (line 88) - Clear old logs: `rm /PRODUCTION/WRIKE_LOGS/*.log.old` --- ## Getting Space IDs ```bash # Get all spaces curl -X GET "https://www.wrike.com/api/v4/spaces" \ -H "Authorization: Bearer YOUR_TOKEN" # Find your space and copy the ID ``` ## Getting Custom Field IDs ```bash # Get all custom fields curl -X GET "https://www.wrike.com/api/v4/customfields" \ -H "Authorization: Bearer YOUR_TOKEN" # Update CUSTOM_FIELDS in Config with your IDs ``` --- **Need Help?** Check the main [README.md](README.md) for detailed documentation.