Aplikacja do automatycznego odlinkowania WIP (Work In Progress) przez Mendix API w systemie JEMS.
- π Unlink WIPs via Mendix API endpoint
/api/assembleall/{wipId}/disassemble - π Check WIP genealogy before unlinking
- π Support for STG and PRD environments
- π§΅ Multi-threaded processing for batch operations
- π Process serial numbers from files (TXT, CSV, JSON) or command line
- π Organized structure with logs, tests, and resources
- β Confirmation before executing operations
- πΎ Token caching for External API (8-hour validity)
- Python 3.7+
- Access to Jabil JEMS API (STG or PRD)
- Required tokens: UserToken and MendixToken
- Network access (VPN if remote)
-
Clone or download the project
git clone <repository-url> cd UNLINK_QUICK
-
Install dependencies
pip install -r requirements.txt
-
Create
.envfilecopy .env.example .env # Windows # or cp .env.example .env # Linux/Mac
-
Configure
.envwith your credentialsENVIRONMENT=STG SITE_NAME=Kwidzyn EXTERNAL_API_USERNAME=your_username EXTERNAL_API_PASSWORD=your_password MENDIX_TOKEN=your_mendix_token # ... see .env.example for full configuration
Check genealogy (without unlinking):
python main.py -s "SN123456789" -cUnlink single serial number:
python main.py -s "SN123456789" -e STGUnlink from file (multi-threaded):
python main.py -sf resources/hmi800.txt -e STGSpecify number of threads:
python main.py -sf resources/hmi800.txt -e STG --threads 10Production environment (auto-execution):
python main.py -sf resources/production.txt -e PRD| Parameter | Short | Description | Required |
|---|---|---|---|
--serial |
-s |
Single serial number to process | No* |
--serial-file |
-sf |
File with serial numbers (one per line) | No* |
--wips |
-w |
WIP pair (format: parent:child) | No* |
--file |
-f |
File with WIP pairs | No* |
--environment |
-e |
Environment: STG or PRD (default from .env) | No |
--token |
-t |
Mendix Token (optional, default from .env) | No |
--check |
-c |
Check genealogy only (no unlinking) | No |
--threads |
- | Number of threads (default: 5) | No |
--log-file |
- | Log file name (default: auto-generated) | No |
* One of: -s, -sf, -w, -f is required
UNLINK_QUICK/
β
βββ main.py # Main CLI application
βββ api_client.py # API clients (External & Mendix)
βββ config.py # Environment and context configuration
βββ requirements.txt # Python dependencies
βββ README.md # This file (English)
βββ INSTRUKCJA.md # Full instruction (Polish)
βββ DESCRIPTION.md # Technical description
β
βββ .env # Environment configuration (not in repo)
βββ .env.example # Example configuration
βββ .token_cache.json # Token cache (not in repo)
β
βββ logs/ # Application logs
β βββ unlink_app_*.log # Application logs
β βββ unlink_results_*.json # Operation results
β
βββ tests/ # Unit and integration tests
β βββ test_auth.py
β βββ test_disassemble.py
β βββ test_genealogy.py
β βββ ...
β
βββ resources/ # Example files and test data
βββ hmi800.txt # Example serial number list
βββ disassemble_request.json # Example request
βββ disassemble_response.json # Example response
βββ ...
The application uses environment-based configuration via .env file:
ENVIRONMENT- Default environment (STG/PRD)SITE_NAME- Site name (e.g., Kwidzyn)EXTERNAL_API_USERNAME- External API usernameEXTERNAL_API_PASSWORD- External API passwordMENDIX_TOKEN- Mendix authentication tokenSTG_EXTERNAL_API_URL- STG External API URLSTG_MENDIX_API_URL- STG Mendix API URLPRD_EXTERNAL_API_URL- PRD External API URLPRD_MENDIX_API_URL- PRD Mendix API URL
Edit config.py to set:
USER_CONTEXT- User data (userId, userName, email, employeeNumber)STATION_CONTEXT- Station data (routeId, factoryId, stationType)
- Uses
ThreadPoolExecutorfor parallel processing - Default: 5 threads (configurable via
--threads) - Thread-safe logging and counters
- Progress tracking per thread
- External API tokens are cached in
.token_cache.json - Tokens valid for 8 hours
- Automatic refresh on expiration
- Separate cache per environment
- Console output with progress indicators
- File logging with timestamps and thread info
- JSON results file with detailed operation data
- All logs saved to
logs/directory
2026-01-22 14:30:00 - [ThreadPoolExecutor-0_0] - INFO - Processing SN: SN123456789
{
"serial_number": "SN123456789",
"timestamp": "2026-01-22T14:30:00",
"environment": "STG",
"thread": "ThreadPoolExecutor-0_0",
"success": true,
"error": null,
"details": {
"parent_wip_id": 4585913,
"children_unlinked": [...],
"total_children": 1,
"successful_unlinks": 1
}
}Best practices:
- β
.envfile is in.gitignore - β Use environment variables for sensitive data
- β Keep credentials secure and rotate regularly
- β Always test on STG before PRD
- β PRD executes automatically without confirmation
- Check credentials in
.env - Verify network access (VPN if remote)
- Ensure API URLs are correct
- Delete
.token_cache.jsonand retry
- Add
MENDIX_TOKENto.env - Or provide via
-tparameter
- Verify serial number is correct
- Check
SITE_NAMEin.env - Ensure WIP exists in selected environment
- Application automatically disables SSL verification for corporate proxies
- Check system proxy settings if issues persist
# 1. Check genealogy before unlinking
python main.py -s "SN123456789" -c -e STG
# 2. If OK, unlink the WIP
python main.py -s "SN123456789" -e STG
# 3. Confirm operation
Do you want to process 1 serial numbers in environment STG? (tak/nie): tak
[1/1] [ThreadPoolExecutor-0_0] Processing SN: SN123456789
β Success - Parent WIP: 4585913, Children unlinked: 1
=== Summary ===
Success: 1
Errors: 0
Results saved to: logs/unlink_results_20260122_143000.jsonRun tests from the tests/ directory:
# Run all tests
cd tests
python test_auth.py
python test_genealogy.py
python test_disassemble.py
# ... etc- INSTRUKCJA.md - Full Polish instruction with detailed examples
- DESCRIPTION.md - Technical description and API documentation
- config.py - Configuration reference
Amadeusz Kusz (2969118)
Β© 2026 Jabil. All rights reserved.
Internal use only.