Delete script draft - Klientas dalyvauja apskaitoje skolose
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
@@ -11,10 +12,17 @@ SCRIPTS = [
|
||||
]
|
||||
|
||||
|
||||
def _run_script(script_path: Path, sutarties_kodas: str) -> None:
|
||||
def _run_script(script_path: Path, user_id: str, sutarties_kodas: str) -> None:
|
||||
result = subprocess.run(
|
||||
[sys.executable, str(script_path)],
|
||||
input=f"{sutarties_kodas}\n",
|
||||
[
|
||||
sys.executable,
|
||||
str(script_path),
|
||||
"--user-id",
|
||||
user_id,
|
||||
"--sutartis-id",
|
||||
sutarties_kodas,
|
||||
],
|
||||
input="",
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
@@ -22,16 +30,33 @@ def _run_script(script_path: Path, sutarties_kodas: str) -> None:
|
||||
|
||||
|
||||
def main() -> None:
|
||||
sutarties_kodas = input("Sutarties kodas: ").strip()
|
||||
if not sutarties_kodas:
|
||||
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 script_name in SCRIPTS:
|
||||
script_path = base_dir / script_name
|
||||
print(f"Running {script_name}...")
|
||||
_run_script(script_path, sutarties_kodas)
|
||||
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__":
|
||||
|
||||
Reference in New Issue
Block a user