64 lines
1.7 KiB
Python
64 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
import argparse
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
SCRIPTS = [
|
|
"port_sutartis_to_rivile.py",
|
|
"port_menesine_kaina_to_rivile.py",
|
|
"port_bukle_to_rivile.py",
|
|
]
|
|
|
|
|
|
def _run_script(script_path: Path, user_id: str, sutarties_kodas: str) -> None:
|
|
result = subprocess.run(
|
|
[
|
|
sys.executable,
|
|
str(script_path),
|
|
"--user-id",
|
|
user_id,
|
|
"--sutartis-id",
|
|
sutarties_kodas,
|
|
],
|
|
input="",
|
|
text=True,
|
|
check=True,
|
|
)
|
|
return None
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--user-id", dest="user_id")
|
|
parser.add_argument("--sutartis-id", dest="sutartis_id", nargs="*")
|
|
args = parser.parse_args()
|
|
|
|
user_id = (args.user_id or "").strip()
|
|
if not user_id:
|
|
user_id = input("User ID: ").strip()
|
|
if not user_id:
|
|
print("Missing user id.")
|
|
return
|
|
|
|
sutarties_kodai = [s.strip() for s in (args.sutartis_id or []) if s.strip()]
|
|
if not sutarties_kodai:
|
|
raw = input("Sutarties kodas (comma-separated for multiple): ").strip()
|
|
if raw:
|
|
sutarties_kodai = [s.strip() for s in raw.split(",") if s.strip()]
|
|
if not sutarties_kodai:
|
|
print("Missing sutarties kodas.")
|
|
return
|
|
|
|
base_dir = Path(__file__).resolve().parent
|
|
for sutarties_kodas in sutarties_kodai:
|
|
for script_name in SCRIPTS:
|
|
script_path = base_dir / script_name
|
|
print(f"Running {script_name} for {sutarties_kodas}...")
|
|
_run_script(script_path, user_id, sutarties_kodas)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|