16 lines
500 B
Python
16 lines
500 B
Python
"""SSH 密码:环境变量 FL_SSH_PASS,否则读 gps 目录下 fl_ssh_pass.txt / .fl_ssh_pass(单行)。"""
|
||
|
||
import os
|
||
|
||
|
||
def ssh_password(gps_root: str) -> str:
|
||
p = os.environ.get("FL_SSH_PASS", "").strip()
|
||
if p:
|
||
return p
|
||
for name in ("fl_ssh_pass.txt", ".fl_ssh_pass"):
|
||
path = os.path.join(gps_root, name)
|
||
if os.path.isfile(path):
|
||
with open(path, encoding="utf-8", errors="replace") as f:
|
||
return f.read().strip()
|
||
return ""
|