chore: unify education management naming
This commit is contained in:
@@ -9,13 +9,15 @@ import subprocess
|
||||
|
||||
|
||||
PROJECT_DIR = Path(__file__).resolve().parents[1]
|
||||
LABEL = "com.xsk.records.sync"
|
||||
LABEL = "com.xsk.education-management.sync"
|
||||
OLD_LABEL = "com.xsk.records.sync"
|
||||
PLIST_PATH = Path.home() / "Library" / "LaunchAgents" / f"{LABEL}.plist"
|
||||
LOG_DIR = Path.home() / "Library" / "Logs" / "xsk-records-web"
|
||||
OLD_PLIST_PATH = Path.home() / "Library" / "LaunchAgents" / f"{OLD_LABEL}.plist"
|
||||
LOG_DIR = Path.home() / "Library" / "Logs" / "xsk-education-management"
|
||||
|
||||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
parser = argparse.ArgumentParser(description="安装新时空课程记录同步 LaunchAgent")
|
||||
parser = argparse.ArgumentParser(description="安装新时空教务管理系统同步 LaunchAgent")
|
||||
parser.add_argument("--use-sshpass", action="store_true", default=os.getenv("XSK_USE_SSHPASS", "") == "1")
|
||||
parser.add_argument("--ssh-password", default=os.getenv("XSK_SSH_PASSWORD"))
|
||||
return parser.parse_args()
|
||||
@@ -50,6 +52,8 @@ def main() -> int:
|
||||
with PLIST_PATH.open("wb") as handle:
|
||||
plistlib.dump(plist, handle)
|
||||
|
||||
subprocess.run(["launchctl", "unload", str(OLD_PLIST_PATH)], check=False, capture_output=True)
|
||||
OLD_PLIST_PATH.unlink(missing_ok=True)
|
||||
subprocess.run(["launchctl", "unload", str(PLIST_PATH)], check=False, capture_output=True)
|
||||
subprocess.run(["launchctl", "load", str(PLIST_PATH)], check=True)
|
||||
print(f"已安装并启动 LaunchAgent: {PLIST_PATH}")
|
||||
|
||||
Reference in New Issue
Block a user