Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
snf-ganeti
Commits
2f8b60b3
Commit
2f8b60b3
authored
Oct 11, 2007
by
Iustin Pop
Browse files
Add small function to read the homedir of a user
This can be used to replace hardcoded "/root/" paths. Reviewed-by: imsnah
parent
16abfbc2
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/utils.py
View file @
2f8b60b3
...
...
@@ -33,6 +33,7 @@ import socket
import
tempfile
import
shutil
import
errno
import
pwd
from
ganeti
import
logger
from
ganeti
import
errors
...
...
@@ -822,3 +823,14 @@ def ListVisibleFiles(path):
"""
return
[
i
for
i
in
os
.
listdir
(
path
)
if
not
i
.
startswith
(
"."
)]
def
GetHomeDir
(
uid
,
default
=
None
):
"""Try to get the homedir of the given user id.
"""
try
:
result
=
pwd
.
getpwuid
(
uid
)
except
KeyError
:
return
default
return
result
.
pw_dir
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment