42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
|
|
from .act_store import AccountingActStore, default_accounting_root
|
|
from .tally_connector import TallyLiveConnector
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description="Phase 1 .act + local TallyPrime smoke test")
|
|
parser.add_argument("--client-id", type=int, required=True)
|
|
parser.add_argument("--client-name", default="")
|
|
parser.add_argument("--tenant-id", type=int)
|
|
parser.add_argument("--storage-root", default="")
|
|
parser.add_argument("--host", default="127.0.0.1")
|
|
parser.add_argument("--port", type=int, default=9000)
|
|
args = parser.parse_args()
|
|
|
|
root = args.storage_root or str(default_accounting_root())
|
|
store = AccountingActStore(root)
|
|
path = store.initialize(
|
|
args.client_id,
|
|
tenant_id=args.tenant_id,
|
|
client_name=args.client_name,
|
|
)
|
|
|
|
connector = TallyLiveConnector(args.host, args.port)
|
|
status = connector.status()
|
|
store.record_tally_status(args.client_id, status)
|
|
|
|
print(json.dumps({
|
|
"act_db": str(path),
|
|
"tally": status,
|
|
"snapshot": store.snapshot(args.client_id),
|
|
}, indent=2, ensure_ascii=False))
|
|
return 0 if status.get("connected") else 2
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|