Files
pi-kit/pikit-api.py

46 lines
1.4 KiB
Python

#!/usr/bin/env python3
"""
Pi-Kit API entrypoint
Thin wrapper that defers to the modular `pikit_api` package. The behavior and
CLI flags remain compatible with the previous single-file script:
--apply-update Apply latest release (non-HTTP mode)
--check-update Check for latest release (non-HTTP mode)
--rollback-update Roll back to last backup (non-HTTP mode)
"""
import argparse
import sys
from pikit_api import HOST, PORT
from pikit_api.releases import apply_update, check_for_update
from pikit_api.server import run_server
def parse_args():
parser = argparse.ArgumentParser(description="Pi-Kit API / updater")
parser.add_argument("--apply-update", action="store_true", help="Apply latest release (non-HTTP mode)")
parser.add_argument("--check-update", action="store_true", help="Check for latest release (non-HTTP mode)")
parser.add_argument("--host", default=HOST, help="Bind host (default 127.0.0.1)")
parser.add_argument("--port", type=int, default=PORT, help="Bind port (default 4000)")
return parser.parse_args()
def main():
args = parse_args()
if args.apply_update:
apply_update()
return
if args.check_update:
check_for_update()
return
run_server(host=args.host, port=args.port)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
sys.exit(0)