mirror of
https://github.com/DictXiong/dotfiles.git
synced 2025-04-25 04:56:53 +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 = [
|
possible_uuid_files = [
|
||||||
"/var/lib/dbus/machine-id",
|
"/var/lib/dbus/machine-id",
|
||||||
"/etc/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:
|
for i in possible_uuid_files:
|
||||||
if os.path.exists(i):
|
if os.path.exists(i):
|
||||||
with open(i, "r") as f:
|
with open(i, "r") as f:
|
||||||
return f.read().strip()
|
return f.read().strip()
|
||||||
if not os.path.exists(os.path.dirname(possible_uuid_files[-1])):
|
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:
|
with open(possible_uuid_files[-1], 'w') as f:
|
||||||
ans = str(uuid.uuid4())
|
ans = str(uuid.uuid4())
|
||||||
f.write(ans)
|
f.write(ans)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user