Add snapshot.zip export with manifest/catalog/library, deterministic checksum, --no-notes/--include-dlc, plus an upload client with idempotency, token config and import polling.
This commit is contained in:
1 parent
1fc1aec825
commit
ffe9e76a5b
11 files changed
+850
-5
No files matched your search
@@ -0,0 +1,339 @@
|
||||
"""Export a SteamBase library snapshot for SteamBaseServer.
|
||||
|
||||
python tools/export_snapshot.py --out snapshot.zip --handle strsv
|
||||
python tools/export_snapshot.py --out snapshot.zip --no-notes
|
||||
python tools/export_snapshot.py --out snapshot.zip --include-dlc
|
||||
|
||||
The archive follows the server contract in SteamBaseServer/docs/snapshot-contract.md:
|
||||
manifest.json, catalog.jsonl, library.jsonl and optional attributes/feedback/moods.
|
||||
The snapshot never includes API keys, tokens, logs or the database file itself.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import zipfile
|
||||
from datetime import datetime, timezone
|
||||
|
||||
for stream in (sys.stdout, sys.stderr):
|
||||
try:
|
||||
stream.reconfigure(encoding="utf-8")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
import db
|
||||
|
||||
FORMAT = "steambase-snapshot"
|
||||
FORMAT_VERSION = 1
|
||||
CHECKSUM_FILES = ("catalog.jsonl", "library.jsonl", "attributes.jsonl",
|
||||
"feedback.jsonl", "moods.json")
|
||||
VERSION_FILE = os.path.join(BASE_DIR, "VERSION")
|
||||
|
||||
|
||||
def app_version():
|
||||
try:
|
||||
with open(VERSION_FILE, encoding="utf-8") as handle:
|
||||
return handle.read().strip() or "0.0.0"
|
||||
except OSError:
|
||||
return "0.0.0"
|
||||
|
||||
|
||||
def _line(value):
|
||||
return json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":")) + "\n"
|
||||
|
||||
|
||||
def _checksum(parts):
|
||||
digest = hashlib.sha256()
|
||||
for name in CHECKSUM_FILES:
|
||||
data = parts.get(name)
|
||||
if data is None:
|
||||
continue
|
||||
digest.update(name.encode("utf-8"))
|
||||
digest.update(b"\0")
|
||||
digest.update(str(len(data)).encode("ascii"))
|
||||
digest.update(b"\0")
|
||||
digest.update(data)
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
def _load_json(value, fallback):
|
||||
try:
|
||||
return json.loads(value)
|
||||
except (TypeError, ValueError):
|
||||
return fallback
|
||||
|
||||
|
||||
def _game_tags(con):
|
||||
tags = {}
|
||||
for row in con.execute("""
|
||||
SELECT gt.appid, tn.name
|
||||
FROM game_tags gt JOIN tag_names tn ON tn.tag_id = gt.tag_id
|
||||
ORDER BY gt.appid, tn.name
|
||||
"""):
|
||||
tags.setdefault(row["appid"], []).append(row["name"])
|
||||
return tags
|
||||
|
||||
|
||||
def _game_genres(con):
|
||||
genres = {}
|
||||
for row in con.execute("SELECT appid, genre FROM game_genres ORDER BY appid, genre"):
|
||||
genres.setdefault(row["appid"], []).append(row["genre"])
|
||||
return genres
|
||||
|
||||
|
||||
def _details_map(con):
|
||||
return {row["appid"]: row for row in con.execute("SELECT * FROM game_details")}
|
||||
|
||||
|
||||
def _translations_map(con):
|
||||
return {row["appid"]: row for row in con.execute("SELECT * FROM game_translations")}
|
||||
|
||||
|
||||
def collect(con, handle=None, steamid=None, notes=True, translations=True,
|
||||
include_dlc=False, mode="replace"):
|
||||
"""Build snapshot files in memory and return (manifest, files)."""
|
||||
if mode not in ("replace", "merge"):
|
||||
raise ValueError("mode must be replace or merge")
|
||||
handle = (handle or os.environ.get("STEAMBASE_SERVER_HANDLE") or "").strip()
|
||||
row = con.execute("SELECT value FROM schema_meta WHERE key = 'steamid'").fetchone()
|
||||
steamid = (steamid or (row[0] if row else "") or "").strip()
|
||||
|
||||
tags = _game_tags(con)
|
||||
genres = _game_genres(con)
|
||||
details = _details_map(con)
|
||||
translations = _translations_map(con) if translations else {}
|
||||
|
||||
where = "" if include_dlc else "WHERE LOWER(g.type) = 'game'"
|
||||
catalog_lines = []
|
||||
catalog_count = 0
|
||||
for game in con.execute(f"""
|
||||
SELECT g.* FROM games g {where} ORDER BY g.appid
|
||||
"""):
|
||||
appid = game["appid"]
|
||||
entry = {
|
||||
"appid": appid,
|
||||
"name": game["name"],
|
||||
"type": game["type"],
|
||||
"release_date": game["release_date"],
|
||||
"metacritic": game["metacritic"],
|
||||
"review_pct": game["review_pct"],
|
||||
"parent_appid": game["parent_appid"],
|
||||
"genres": genres.get(appid, []),
|
||||
"tags": tags.get(appid, []),
|
||||
}
|
||||
detail = details.get(appid)
|
||||
if detail:
|
||||
entry["details"] = {
|
||||
"short_description": detail["short_description"],
|
||||
"about": detail["about"],
|
||||
"header_image": detail["header_image"],
|
||||
"developers": detail["developers"],
|
||||
"publishers": detail["publishers"],
|
||||
"release_date": detail["release_date"],
|
||||
"lang": detail["lang"],
|
||||
"status": detail["status"],
|
||||
"source_appid": detail["source_appid"],
|
||||
}
|
||||
translation = translations.get(appid)
|
||||
if translation:
|
||||
entry["translation"] = {
|
||||
"lang": translation["lang"],
|
||||
"short_description": translation["short_description"],
|
||||
"about": translation["about"],
|
||||
"provider": translation["provider"],
|
||||
"translated_at": translation["translated_at"],
|
||||
}
|
||||
if any(game[key] is not None for key in
|
||||
("hltb_main", "hltb_extra", "hltb_complete", "hltb_id", "hltb_checked_at")):
|
||||
entry["hltb"] = {
|
||||
"main": game["hltb_main"],
|
||||
"extra": game["hltb_extra"],
|
||||
"complete": game["hltb_complete"],
|
||||
"hltb_id": game["hltb_id"],
|
||||
"checked_at": game["hltb_checked_at"],
|
||||
"match": bool(game["hltb_match"]),
|
||||
"updated_at": game["hltb_updated_at"],
|
||||
}
|
||||
catalog_lines.append(_line(entry))
|
||||
catalog_count += 1
|
||||
|
||||
library_lines = []
|
||||
library_count = 0
|
||||
for row in con.execute("""
|
||||
SELECT g.appid, COALESCE(p.minutes, 0) AS minutes, p.last_played,
|
||||
COALESCE(i.installed, 0) AS installed, i.size_bytes,
|
||||
COALESCE(pe.status, 'backlog') AS status, pe.rating,
|
||||
COALESCE(pe.favorite, 0) AS favorite, pe.notes, o.owned
|
||||
FROM games g
|
||||
LEFT JOIN game_playtime p ON p.appid = g.appid
|
||||
LEFT JOIN game_install i ON i.appid = g.appid
|
||||
LEFT JOIN personal pe ON pe.appid = g.appid
|
||||
LEFT JOIN game_ownership o ON o.appid = g.appid
|
||||
WHERE LOWER(g.type) = 'game'
|
||||
ORDER BY g.appid
|
||||
"""):
|
||||
item = {
|
||||
"appid": row["appid"],
|
||||
"minutes": row["minutes"],
|
||||
"last_played": row["last_played"],
|
||||
"installed": bool(row["installed"]),
|
||||
"size_bytes": row["size_bytes"],
|
||||
"status": row["status"],
|
||||
"rating": row["rating"],
|
||||
"favorite": bool(row["favorite"]),
|
||||
"owned": None if row["owned"] is None else bool(row["owned"]),
|
||||
}
|
||||
if notes:
|
||||
item["notes"] = row["notes"]
|
||||
library_lines.append(_line(item))
|
||||
library_count += 1
|
||||
|
||||
attributes = [
|
||||
_line({"appid": row["appid"], "key": row["key"], "value": row["value"]})
|
||||
for row in con.execute("""
|
||||
SELECT appid, key, value FROM attributes ORDER BY appid, key
|
||||
""")
|
||||
]
|
||||
feedback = [
|
||||
_line({"appid": row["appid"], "mood_key": row["mood_key"],
|
||||
"verdict": row["verdict"], "created_at": row["created_at"]})
|
||||
for row in con.execute("""
|
||||
SELECT appid, mood_key, verdict, created_at FROM reco_feedback
|
||||
ORDER BY appid, mood_key
|
||||
""")
|
||||
]
|
||||
builtins = set(db.MOOD_PRESETS)
|
||||
moods = []
|
||||
for row in con.execute("SELECT name, description, genres, tags, updated_at FROM moods ORDER BY name"):
|
||||
if row["name"] in builtins:
|
||||
continue
|
||||
moods.append({
|
||||
"name": row["name"],
|
||||
"description": row["description"],
|
||||
"genres": _load_json(row["genres"], []),
|
||||
"tags": _load_json(row["tags"], {}),
|
||||
"updated_at": row["updated_at"],
|
||||
})
|
||||
|
||||
files = {
|
||||
"catalog.jsonl": "".join(catalog_lines).encode("utf-8"),
|
||||
"library.jsonl": "".join(library_lines).encode("utf-8"),
|
||||
}
|
||||
if attributes:
|
||||
files["attributes.jsonl"] = "".join(attributes).encode("utf-8")
|
||||
if feedback:
|
||||
files["feedback.jsonl"] = "".join(feedback).encode("utf-8")
|
||||
if moods:
|
||||
files["moods.json"] = _line(moods).encode("utf-8")
|
||||
|
||||
manifest = {
|
||||
"format": FORMAT,
|
||||
"format_version": FORMAT_VERSION,
|
||||
"app_version": app_version(),
|
||||
"generated_at": datetime.now(timezone.utc).isoformat(timespec="seconds"),
|
||||
"user": {"handle": handle, "steamid": steamid, "display_name": handle or steamid},
|
||||
"mode": mode,
|
||||
"counts": {
|
||||
"catalog": catalog_count,
|
||||
"library": library_count,
|
||||
"attributes": len(attributes),
|
||||
"feedback": len(feedback),
|
||||
"moods": len(moods),
|
||||
},
|
||||
"checksum_sha256": _checksum(files),
|
||||
}
|
||||
return manifest, files
|
||||
|
||||
|
||||
def write_snapshot(con, out_path, **options):
|
||||
manifest, files = collect(con, **options)
|
||||
out_dir = os.path.dirname(os.path.abspath(out_path)) or "."
|
||||
os.makedirs(out_dir, exist_ok=True)
|
||||
tmp_path = out_path + ".tmp"
|
||||
try:
|
||||
with zipfile.ZipFile(tmp_path, "w", zipfile.ZIP_DEFLATED) as archive:
|
||||
archive.writestr("manifest.json", _line(manifest))
|
||||
for name in CHECKSUM_FILES:
|
||||
data = files.get(name)
|
||||
if data is not None:
|
||||
archive.writestr(name, data)
|
||||
os.replace(tmp_path, out_path)
|
||||
finally:
|
||||
if os.path.exists(tmp_path):
|
||||
os.unlink(tmp_path)
|
||||
return manifest
|
||||
|
||||
|
||||
def snapshot_checksum(path):
|
||||
"""Recompute the checksum of an existing snapshot (manifest excluded)."""
|
||||
with zipfile.ZipFile(path) as archive:
|
||||
parts = {}
|
||||
for name in CHECKSUM_FILES:
|
||||
try:
|
||||
parts[name] = archive.read(name)
|
||||
except KeyError:
|
||||
continue
|
||||
return _checksum(parts)
|
||||
|
||||
|
||||
def read_manifest(path):
|
||||
with zipfile.ZipFile(path) as archive:
|
||||
return json.loads(archive.read("manifest.json").decode("utf-8"))
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser(description="Export a SteamBase snapshot")
|
||||
ap.add_argument("--db", default=db.DEFAULT_DB)
|
||||
ap.add_argument("--out", default="snapshot.zip")
|
||||
ap.add_argument("--handle", default=os.environ.get("STEAMBASE_SERVER_HANDLE"))
|
||||
ap.add_argument("--steamid")
|
||||
ap.add_argument("--no-notes", action="store_true", help="do not include personal notes")
|
||||
ap.add_argument("--no-translations", action="store_true", help="do not include translations")
|
||||
ap.add_argument("--include-dlc", action="store_true",
|
||||
help="include DLC, soundtracks and tools in the catalog")
|
||||
ap.add_argument("--mode", choices=("replace", "merge"), default="replace")
|
||||
ap.add_argument("--format-version", type=int, default=FORMAT_VERSION)
|
||||
ap.add_argument("--dry-run", action="store_true")
|
||||
args = ap.parse_args()
|
||||
|
||||
if args.format_version != FORMAT_VERSION:
|
||||
print(f"Unsupported format version: {args.format_version}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
con = db.connect(args.db)
|
||||
try:
|
||||
options = {
|
||||
"handle": args.handle,
|
||||
"steamid": args.steamid,
|
||||
"notes": not args.no_notes,
|
||||
"translations": not args.no_translations,
|
||||
"include_dlc": args.include_dlc,
|
||||
"mode": args.mode,
|
||||
}
|
||||
if args.dry_run:
|
||||
manifest, _ = collect(con, **options)
|
||||
print(json.dumps(manifest, ensure_ascii=False, indent=2))
|
||||
return 0
|
||||
manifest = write_snapshot(con, args.out, **options)
|
||||
size = os.path.getsize(args.out)
|
||||
print(f"Snapshot: {args.out}")
|
||||
print(f"Size: {size} bytes")
|
||||
print(f"Catalog: {manifest['counts']['catalog']} | "
|
||||
f"Library: {manifest['counts']['library']} | "
|
||||
f"Attributes: {manifest['counts']['attributes']} | "
|
||||
f"Feedback: {manifest['counts']['feedback']} | "
|
||||
f"Moods: {manifest['counts']['moods']}")
|
||||
print(f"Checksum: sha256={manifest['checksum_sha256']}")
|
||||
return 0
|
||||
finally:
|
||||
con.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -0,0 +1,215 @@
|
||||
"""Export and upload a SteamBase snapshot to SteamBaseServer.
|
||||
|
||||
python tools/upload_snapshot.py --url https://steambase.strsv.ru --token ...
|
||||
python tools/upload_snapshot.py --file snapshot.zip
|
||||
|
||||
Configuration precedence: CLI > environment > data/server.json.
|
||||
The token is never printed or written to logs.
|
||||
|
||||
Environment:
|
||||
STEAMBASE_SERVER_URL
|
||||
STEAMBASE_UPLOAD_TOKEN
|
||||
STEAMBASE_SERVER_HANDLE
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
import uuid
|
||||
|
||||
for stream in (sys.stdout, sys.stderr):
|
||||
try:
|
||||
stream.reconfigure(encoding="utf-8")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
import db
|
||||
import export_snapshot as exporter
|
||||
|
||||
CONFIG_FILE = os.path.join(BASE_DIR, "data", "server.json")
|
||||
DEFAULT_TIMEOUT = 60
|
||||
DEFAULT_POLL_INTERVAL = 2
|
||||
DEFAULT_POLL_TIMEOUT = 300
|
||||
|
||||
|
||||
class UploadError(RuntimeError):
|
||||
def __init__(self, message, status=None, code=None):
|
||||
super().__init__(message)
|
||||
self.status = status
|
||||
self.code = code
|
||||
|
||||
|
||||
def load_config(path=CONFIG_FILE):
|
||||
try:
|
||||
with open(path, encoding="utf-8") as handle:
|
||||
data = json.load(handle)
|
||||
except (OSError, ValueError):
|
||||
return {}
|
||||
return data if isinstance(data, dict) else {}
|
||||
|
||||
|
||||
def resolve_config(url=None, token=None, handle=None, path=CONFIG_FILE):
|
||||
saved = load_config(path)
|
||||
url = (url or os.environ.get("STEAMBASE_SERVER_URL") or saved.get("url") or "").strip()
|
||||
token = (token or os.environ.get("STEAMBASE_UPLOAD_TOKEN") or saved.get("token") or "").strip()
|
||||
handle = (handle or os.environ.get("STEAMBASE_SERVER_HANDLE") or saved.get("handle") or "").strip()
|
||||
return {"url": url.rstrip("/"), "token": token, "handle": handle}
|
||||
|
||||
|
||||
def _request(url, token, data=None, headers=None, timeout=DEFAULT_TIMEOUT):
|
||||
request_headers = {"Authorization": f"Bearer {token}"}
|
||||
request_headers.update(headers or {})
|
||||
request = urllib.request.Request(url, data=data, headers=request_headers,
|
||||
method="POST" if data is not None else "GET")
|
||||
try:
|
||||
with urllib.request.urlopen(request, timeout=timeout) as response:
|
||||
return json.loads(response.read().decode("utf-8"))
|
||||
except urllib.error.HTTPError as exc:
|
||||
body = exc.read().decode("utf-8", "replace")
|
||||
try:
|
||||
payload = json.loads(body)
|
||||
error = payload.get("error") or {}
|
||||
message = error.get("message") or body or f"HTTP {exc.code}"
|
||||
code = error.get("code")
|
||||
except ValueError:
|
||||
message = body or f"HTTP {exc.code}"
|
||||
code = None
|
||||
if exc.code == 401:
|
||||
message = "токен неверный или отозван"
|
||||
elif exc.code == 403:
|
||||
message = "нет прав на загрузку"
|
||||
elif exc.code == 413:
|
||||
message = "снимок больше лимита сервера"
|
||||
elif exc.code == 429:
|
||||
message = "слишком частые загрузки, попробуйте позже"
|
||||
raise UploadError(message, status=exc.code, code=code) from None
|
||||
except (urllib.error.URLError, TimeoutError, ValueError) as exc:
|
||||
raise UploadError(f"ошибка соединения: {type(exc).__name__}") from None
|
||||
|
||||
|
||||
def upload(url, token, path, timeout=DEFAULT_TIMEOUT, idempotency_key=None):
|
||||
if not url:
|
||||
raise UploadError("не задан URL сервера")
|
||||
if not token:
|
||||
raise UploadError("не задан upload-токен")
|
||||
with open(path, "rb") as handle:
|
||||
body = handle.read()
|
||||
checksum = exporter.snapshot_checksum(path)
|
||||
headers = {
|
||||
"Content-Type": "application/zip",
|
||||
"X-Snapshot-Checksum": f"sha256={checksum}",
|
||||
"Idempotency-Key": idempotency_key or str(uuid.uuid4()),
|
||||
}
|
||||
data = _request(f"{url.rstrip('/')}/api/v1/snapshots", token, body, headers, timeout)
|
||||
snapshot = data.get("snapshot") or data
|
||||
if not isinstance(snapshot, dict) or not snapshot.get("id"):
|
||||
raise UploadError("сервер вернул неожиданный ответ")
|
||||
return snapshot
|
||||
|
||||
|
||||
def status(url, token, snapshot_id, timeout=DEFAULT_TIMEOUT):
|
||||
data = _request(f"{url.rstrip('/')}/api/v1/snapshots/{snapshot_id}", token, timeout=timeout)
|
||||
return data.get("snapshot") or data
|
||||
|
||||
|
||||
def wait(url, token, snapshot_id, interval=DEFAULT_POLL_INTERVAL,
|
||||
timeout=DEFAULT_POLL_TIMEOUT, on_status=None):
|
||||
deadline = time.time() + timeout
|
||||
while True:
|
||||
data = status(url, token, snapshot_id)
|
||||
state = data.get("status")
|
||||
if on_status:
|
||||
on_status(data)
|
||||
if state in ("done", "failed", "cancelled"):
|
||||
return data
|
||||
if time.time() >= deadline:
|
||||
raise UploadError(f"импорт не завершился за {timeout} с")
|
||||
time.sleep(interval)
|
||||
|
||||
|
||||
def _print_status(data):
|
||||
state = data.get("status") or "?"
|
||||
counts = data.get("counts") or {}
|
||||
suffix = ""
|
||||
if counts:
|
||||
suffix = f" | catalog={counts.get('catalog', '?')} library={counts.get('library', '?')}"
|
||||
print(f" snapshot {data.get('id', '?')}: {state}{suffix}")
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser(description="Upload a SteamBase snapshot")
|
||||
ap.add_argument("--url", help="server URL, e.g. https://steambase.strsv.ru")
|
||||
ap.add_argument("--token", help="upload token")
|
||||
ap.add_argument("--handle", help="server handle for the manifest")
|
||||
ap.add_argument("--file", help="existing snapshot.zip (otherwise export now)")
|
||||
ap.add_argument("--db", default=db.DEFAULT_DB)
|
||||
ap.add_argument("--no-notes", action="store_true")
|
||||
ap.add_argument("--no-translations", action="store_true")
|
||||
ap.add_argument("--include-dlc", action="store_true")
|
||||
ap.add_argument("--mode", choices=("replace", "merge"), default="replace")
|
||||
ap.add_argument("--no-poll", action="store_true")
|
||||
ap.add_argument("--timeout", type=float, default=DEFAULT_POLL_TIMEOUT)
|
||||
args = ap.parse_args()
|
||||
|
||||
config = resolve_config(args.url, args.token, args.handle)
|
||||
if not config["url"] or not config["token"]:
|
||||
print("Задайте --url и --token (или data/server.json / env)", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
temp_dir = None
|
||||
path = args.file
|
||||
try:
|
||||
if not path:
|
||||
temp_dir = tempfile.TemporaryDirectory(prefix="steambase-snapshot-")
|
||||
path = os.path.join(temp_dir.name, "snapshot.zip")
|
||||
con = db.connect(args.db)
|
||||
try:
|
||||
manifest = exporter.write_snapshot(
|
||||
con, path,
|
||||
handle=config["handle"],
|
||||
notes=not args.no_notes,
|
||||
translations=not args.no_translations,
|
||||
include_dlc=args.include_dlc,
|
||||
mode=args.mode,
|
||||
)
|
||||
finally:
|
||||
con.close()
|
||||
print(f"Экспортировано: catalog={manifest['counts']['catalog']} "
|
||||
f"library={manifest['counts']['library']} "
|
||||
f"({os.path.getsize(path)} байт)")
|
||||
|
||||
snapshot = upload(config["url"], config["token"], path)
|
||||
print(f"Загружено: snapshot={snapshot['id']} status={snapshot.get('status')}")
|
||||
if args.no_poll:
|
||||
return 0
|
||||
if snapshot.get("status") in ("done", "failed", "cancelled"):
|
||||
_print_status(snapshot)
|
||||
return 0 if snapshot.get("status") == "done" else 1
|
||||
final = wait(config["url"], config["token"], snapshot["id"],
|
||||
timeout=args.timeout, on_status=None)
|
||||
_print_status(final)
|
||||
if final.get("status") == "done":
|
||||
print("Импорт завершён")
|
||||
return 0
|
||||
print(f"Импорт завершился со статусом: {final.get('status')}", file=sys.stderr)
|
||||
if final.get("error"):
|
||||
print(final["error"], file=sys.stderr)
|
||||
return 1
|
||||
except UploadError as exc:
|
||||
print(f"Ошибка: {exc}", file=sys.stderr)
|
||||
return 1
|
||||
finally:
|
||||
if temp_dir is not None:
|
||||
temp_dir.cleanup()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in new issue
Block a user