standarlize the config path

This commit is contained in:
Dict Xiong 2022-08-08 10:26:31 +08:00
parent 6208adec3f
commit c4c9dd335d

View File

@ -14,14 +14,14 @@ def get_uuid_raw() -> str:
possible_uuid_files = [
"/var/lib/dbus/machine-id",
"/etc/machine-id",
os.path.join(os.path.expanduser('~'), ".config/uuid"),
os.path.join(os.path.expanduser('~'), ".config/dotfiles/uuid"),
]
for i in possible_uuid_files:
if os.path.exists(i):
with open(i, "r") as f:
return f.read().strip()
if not os.path.exists(os.path.dirname(possible_uuid_files[-1])):
os.mkdir(os.path.dirname(possible_uuid_files[-1]))
os.makedirs(os.path.dirname(possible_uuid_files[-1]))
with open(possible_uuid_files[-1], 'w') as f:
ans = str(uuid.uuid4())
f.write(ans)