mirror of
https://github.com/DictXiong/dotfiles.git
synced 2025-04-24 21:46:52 +08:00
standarlize the config path
This commit is contained in:
parent
6208adec3f
commit
c4c9dd335d
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user