Metadata-Version: 2.4
Name: supdater
Version: 0.1.0
Summary: A simple update checker and logger for your Python application
Project-URL: Homepage, https://github.com/yourname/supdater
Project-URL: Repository, https://github.com/yourname/supdater
Project-URL: Issues, https://github.com/yourname/supdater/issues
Author-email: Your Name <you@example.com>
License: MIT
License-File: LICENSE
Keywords: auto-update,logging,pocketbase,sdk,update-checker
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
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: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Logging
Classifier: Topic :: System :: Software Distribution
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# Supdater

[![Python](https://img.shields.io/pypi/pyversions/supdater.svg)](https://pypi.org/project/supdater/)
[![PyPI](https://img.shields.io/pypi/v/supdater.svg)](https://pypi.org/project/supdater/)
[![License](https://img.shields.io/pypi/l/supdater.svg)](https://github.com/yourname/supdater/blob/main/LICENSE)

通用软件更新检测与日志上报 SDK，基于 PocketBase 后端，**框架无关**。

适用于 tkinter、PyQt/PySide、Kivy、命令行工具等任何 Python 项目。

## 功能

- 🔍 **版本检测** — 从 PocketBase 拉取最新版本信息，对比本地版本
- 📤 **日志上报** — 自动上报启动日志、错误日志、心跳等使用数据
- 🧵 **非阻塞** — 所有网络操作支持异步模式，不卡 UI
- 🖥️ **GUI 集成** — 内置 tkinter 版本标签组件，PyQt 示例
- 🪶 **零依赖** — 仅使用 Python 标准库

## 安装

```bash
pip install supdater
```

## 快速开始

```python
from supdater import Supdater

# 1. 初始化
sup = Supdater(
    base_url="https://your-pocketbase.com",
    soft_id="your_soft_record_id",
    app_version="1.0.0",
)

# 2. 启动时上报日志
sup.send_log_async("startup")

# 3. 后台检查更新
def on_version(info):
    if info.version != sup.app_version:
        print(f"发现新版本: {info.version}")
        print(f"更新内容: {info.updatelog}")

sup.check_update_async(callback=on_version)
```

## API 参考

### 版本检查

```python
# 同步检查（阻塞）
has_update, info = sup.check_update()
if has_update:
    print(f"新版本: {info.version}")

# 异步检查（不阻塞，推荐）
sup.check_update_async(callback=on_version)

# 仅拉取远程信息
info = sup.fetch_remote_version()
```

### 日志上报

```python
# 启动日志
sup.send_log_async("startup")

# 错误日志（附带元数据）
import json
sup.send_log_async("error", meta=json.dumps({"msg": "除以零"}))

# 同步发送（获取返回值）
result = sup.send_log("startup")
```

### tkinter 集成

```python
import tkinter as tk

root = tk.Tk()
version_widget = sup.create_tk_widget(root, bg="#f0f0f0")
version_widget.pack(side=tk.BOTTOM, anchor=tk.E)
root.mainloop()
```

## PocketBase 数据结构

| 表名 | 用途 | 关键字段 |
|------|------|----------|
| `softs` | 软件信息 | `name`, `version`(关联 versions) |
| `versions` | 版本记录 | `version`, `updatelog`, `download` |
| `logs` | 使用日志 | `relation`(关联 softs), `type`, `version`, `platform`, `ipaddr`, `meta` |

## 许可

MIT License
