Metadata-Version: 2.4
Name: pywats-api
Version: 0.1.0b2
Summary: Python API library for WATS (Web-based Automated Test System) - manufacturing test data management
Author-email: Virinco AS <support@virinco.com>
Maintainer-email: Virinco AS <support@virinco.com>
License: MIT License
        
        Copyright (c) 2024-2025 Virinco AS
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/olreppe/pyWATS
Project-URL: Documentation, https://github.com/olreppe/pyWATS#readme
Project-URL: Repository, https://github.com/olreppe/pyWATS
Project-URL: Issues, https://github.com/olreppe/pyWATS/issues
Project-URL: Changelog, https://github.com/olreppe/pyWATS/blob/main/CHANGELOG.md
Keywords: wats,test-automation,manufacturing,test-data,api,virinco
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Manufacturing
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Scientific/Engineering
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Classifier: Typing :: Typed
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.24.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: python-dateutil>=2.8.0
Requires-Dist: attrs>=22.0.0
Provides-Extra: client
Requires-Dist: PySide6>=6.4.0; extra == "client"
Requires-Dist: watchdog>=3.0.0; extra == "client"
Requires-Dist: aiofiles>=23.0.0; extra == "client"
Provides-Extra: client-headless
Requires-Dist: watchdog>=3.0.0; extra == "client-headless"
Requires-Dist: aiofiles>=23.0.0; extra == "client-headless"
Provides-Extra: mcp
Requires-Dist: mcp>=1.0.0; extra == "mcp"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: black>=22.0; extra == "dev"
Requires-Dist: isort>=5.0; extra == "dev"
Requires-Dist: flake8>=5.0; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx>=5.0; extra == "docs"
Requires-Dist: sphinx-rtd-theme>=1.0; extra == "docs"
Dynamic: license-file

# pyWATS

[![PyPI version](https://badge.fury.io/py/pywats-api.svg)](https://badge.fury.io/py/pywats-api)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A Python library for interacting with the [WATS](https://wats.com) (Web-based Automated Test System) API.

> **⚠️ Beta Release**: This is a beta version. The API is stabilizing but may have changes before 1.0.

## Requirements

- **Python 3.8** or later
- **WATS Server 2025.3.9.824** or later

## Features

- **pyWATS Library** - Core API library for WATS integration
  - Product management
  - Asset management  
  - Report creation and submission
  - Production/serial number management
  - RootCause ticket system
  - Software distribution
  - Statistics and analytics

- **pyWATS Client** - Desktop and headless client application
  - Connection management
  - Converter configuration
  - Report queue management
  - **GUI Mode**: Qt-based desktop application (Windows, macOS, Linux)
  - **Headless Mode**: CLI and HTTP API for servers, Raspberry Pi, embedded systems

## Installation

### From PyPI (Recommended)

```bash
# Install core API library only
pip install pywats-api

# Install with GUI client (requires Qt)
pip install pywats-api[client]

# Install headless client (no Qt - for Raspberry Pi, servers)
pip install pywats-api[client-headless]

# Install with MCP server (for AI assistant integration)
pip install pywats-api[mcp]
```

### From Source (Development)

```bash
# Clone the repository
git clone https://github.com/olreppe/pyWATS.git
cd pyWATS

# Create virtual environment
python -m venv .venv
.venv\Scripts\activate  # Windows
source .venv/bin/activate  # Linux/Mac

# Install in development mode
pip install -e ".[dev]"
```

## Configuration

Create a configuration with your WATS credentials:

```python
from pywats import pyWATS

api = pyWATS(
    base_url="https://your-server.wats.com",
    token="your_base64_encoded_token"
)
```

Or use environment variables:

```env
WATS_BASE_URL=https://your-server.wats.com
WATS_AUTH_TOKEN=your_base64_encoded_token
```

## Quick Start

```python
from pywats import pyWATS, WATSFilter

# Initialize API
api = pyWATS(
    base_url="https://your-server.wats.com",
    token="your_token"
)

# Test connection
if api.test_connection():
    print(f"Connected! Server version: {api.get_version()}")

# Get products
products = api.product.get_products()
for p in products:
    print(f"{p.part_number}: {p.name}")

# Query recent reports
filter = WATSFilter(top_count=10)
headers = api.report.query_uut_headers(filter)
```

### Enable Debug Logging

```python
from pywats import pyWATS, enable_debug_logging

# Quick debug mode - shows all library operations
enable_debug_logging()

# Or configure logging your way
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger('pywats').setLevel(logging.DEBUG)

# Now use the API with detailed logging
api = pyWATS(base_url="...", token="...")
```

See [LOGGING_STRATEGY.md](LOGGING_STRATEGY.md) for comprehensive logging documentation.

## Running the GUI Client

```bash
python -m pywats_client
```

### GUI Configuration

The GUI supports modular tab configuration and logging control:

- **Tab Visibility**: Show/hide tabs (Software, SN Handler, etc.) based on your needs
- **Logging Integration**: Automatic pyWATS library logging when debug mode is enabled
- **Multiple Instances**: Run multiple client instances with separate configurations

See [GUI Configuration Guide](src/pywats_client/GUI_CONFIGURATION.md) for detailed setup instructions.

## Running Headless (Raspberry Pi, Servers)

For systems without display or Qt support:

```bash
# Initialize configuration
pywats-client config init

# Test connection
pywats-client test-connection

# Run service with HTTP control API
pywats-client start --api --api-port 8765

# Run as daemon (Linux)
pywats-client start --daemon
```

### CLI Commands

```bash
pywats-client config show          # Show configuration
pywats-client config set key value # Set config value
pywats-client status               # Show service status
pywats-client converters list      # List converters
```

### HTTP Control API

When running with `--api`, manage the service remotely:

```bash
curl http://localhost:8765/status    # Get status
curl http://localhost:8765/config    # Get configuration
curl -X POST http://localhost:8765/restart  # Restart services
```

See [Headless Operation Guide](src/pywats_client/control/HEADLESS_GUIDE.md) for complete documentation.

## Project Structure

```
pyWATS/
├── src/
│   ├── pywats/              # Core library
│   │   ├── models/          # Pydantic data models
│   │   ├── modules/         # High-level API modules
│   │   └── rest_api/        # REST API wrappers
│   └── pywats_client/       # Client application
│       ├── core/            # Core client functionality
│       ├── gui/             # Qt GUI components (optional)
│       ├── control/         # Headless control (CLI, HTTP API)
│       └── services/        # Background services
├── converters/              # User converter plugins
├── docs/                    # Documentation
│   ├── api_specs/           # OpenAPI specifications
│   ├── examples/            # Usage examples
│   └── gui_screens/         # GUI screenshots
├── pyproject.toml           # Project configuration
└── requirements.txt         # Dependencies
```

## Documentation

- [Architecture Overview](docs/ARCHITECTURE.md) - System design and layered architecture
- [Report Module](docs/usage/REPORT_MODULE.md) - Test reports and factory methods
- [Product Module](docs/usage/PRODUCT_MODULE.md) - Product/BOM management
- [Production Module](docs/usage/PRODUCTION_MODULE.md) - Serial number and unit tracking

## Testing

```bash
# Run all tests
pytest

# Run with coverage
pytest --cov=src --cov-report=html
```

## Contributing

This project is maintained by [Virinco AS](https://virinco.com). 

## License

MIT License - see [LICENSE](LICENSE) for details.

## Links

- [WATS Website](https://wats.com)
- [Virinco](https://virinco.com)
- [GitHub Repository](https://github.com/olreppe/pyWATS)
- [Changelog](CHANGELOG.md)
