huashijie_work/huashijie/util/archivist.py
yzqzss a43d8b6cbe feat: select_best_tracker() before running
feat: read `ARCHIVIST` from env
dependencies: remove legacy `bson`
2024-04-22 16:38:45 +08:00

17 lines
641 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import os
def new_archivist():
print("zh: 第一次运行,请输入可以唯一标识您节点的字符串。(合法字符:字母、数字、-、_")
print("en: First run, please input a string that can uniquely identify your node. (Legal characters: letters, numbers, -, _)")
with open("ARCHIVIST.conf", "w") as f:
f.write(input("ARCHIVIST: "))
return get_archivist()
def get_archivist():
if arch := os.getenv("ARCHIVIST", ""):
return arch
if os.path.exists("ARCHIVIST.conf"):
with open("ARCHIVIST.conf", "r") as f:
return f.read().splitlines()[0].strip()
return ""