1
0
mirror of https://github.com/vladmandic/sdnext.git synced 2026-01-27 15:02:48 +03:00
Files
sdnext/cli/api-history.py
Vladimir Mandic 10fb362bdc server state history
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-04-25 12:25:30 -04:00

34 lines
876 B
Python
Executable File

#!/usr/bin/env python
"""
get list of all history jobs or a specific job
"""
import sys
import logging
import urllib3
import requests
url = "http://127.0.0.1:7860"
user = ""
password = ""
log_format = '%(asctime)s %(levelname)s: %(message)s'
logging.basicConfig(level = logging.INFO, format = log_format)
log = logging.getLogger("sd")
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
log.info('state history')
sys.argv.pop(0)
task_id = sys.argv[0] if len(sys.argv) == 1 else ''
auth = requests.auth.HTTPBasicAuth(user, password) if len(user) > 0 and len(password) > 0 else None
req = requests.get(f'{url}/sdapi/v1/history?id={task_id}', verify=False, auth=auth, timeout=60)
if req.status_code != 200:
log.error({ 'url': req.url, 'request': req.status_code, 'reason': req.reason })
exit(1)
res = req.json()
for item in res:
log.info(item)