Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed 'Inappropriate ioctl for device' problem on posix systems #43

Merged
merged 1 commit into from
May 17, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions git/util.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,9 @@
SlidingWindowMapManager,
SlidingWindowMapBuffer
)

# Import the user database on unix based systems
if os.name == "posix":
import pwd


__all__ = ( "stream_copy", "join_path", "to_native_path_windows", "to_native_path_linux",
@@ -144,12 +146,17 @@ def __getslice__(self, start, end):

def get_user_id():
""":return: string identifying the currently active system user as name@node
:note: user can be set with the 'USER' environment variable, usually set on windows"""
ukn = 'UNKNOWN'
username = os.environ.get('USER', os.environ.get('USERNAME', ukn))
if username == ukn and hasattr(os, 'getlogin'):
username = os.getlogin()
# END get username from login
:note: user can be set with the 'USER' environment variable, usually set on windows
:note: on unix based systems you can use the password database
to get the login name of the effective process user"""
if os.name == "posix":
username = pwd.getpwuid(os.geteuid()).pw_name
else:
ukn = 'UNKNOWN'
username = os.environ.get('USER', os.environ.get('USERNAME', ukn))
if username == ukn and hasattr(os, 'getlogin'):
username = os.getlogin()
# END get username from login
return "%s@%s" % (username, platform.node())

def is_git_dir(d):