fix(load_path): app根从脚本自身位置上溯三级解析(~/pipeline在部署机不存在)
This commit is contained in:
parent
34a13ebf37
commit
a484e5f46c
@ -15,9 +15,19 @@ PATHS_LOGINED = [
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
root = os.path.expanduser("~/pipeline")
|
# app root: 本脚本位于 <app>/pkgs/<mod>/scripts/,上溯三级即 app 根
|
||||||
if not os.path.isfile(os.path.join(root, "set_role_perm.py")):
|
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
print("ERROR: pipeline root not found")
|
candidates = [
|
||||||
|
os.path.dirname(os.path.dirname(os.path.dirname(script_dir))),
|
||||||
|
os.path.expanduser("~/pipeline"),
|
||||||
|
]
|
||||||
|
root = None
|
||||||
|
for c in candidates:
|
||||||
|
if os.path.isfile(os.path.join(c, "set_role_perm.py")):
|
||||||
|
root = c
|
||||||
|
break
|
||||||
|
if not root:
|
||||||
|
print("ERROR: pipeline root not found (set_role_perm.py missing)")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
set_perm = os.path.join(root, "set_role_perm.py")
|
set_perm = os.path.join(root, "set_role_perm.py")
|
||||||
py = sys.executable
|
py = sys.executable
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user