| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,22 +10,20 @@ | |||
| 10 | 10 | import time | |
| 11 | 11 | import stat | |
| 12 | 12 | import shutil | |
| 13 | - import tempfile | ||
| 14 | 13 | import platform | |
| 14 | + import getpass | ||
| 15 | 15 | ||
| 16 | + # NOTE: Some of the unused imports might be used/imported by others. | ||
| 17 | + # Handle once test-cases are back up and running. | ||
| 16 | 18 | from gitdb.util import ( | |
| 17 | - make_sha, | ||
| 18 | - LockedFD, | ||
| 19 | - file_contents_ro, | ||
| 20 | - LazyMixin, | ||
| 21 | - to_hex_sha, | ||
| 22 | - to_bin_sha | ||
| 23 | - ) | ||
| 24 | - | ||
| 25 | - # Import the user database on unix based systems | ||
| 26 | - if os.name == "posix": | ||
| 27 | - import pwd | ||
| 28 | - | ||
| 19 | + make_sha, | ||
| 20 | + LockedFD, | ||
| 21 | + file_contents_ro, | ||
| 22 | + LazyMixin, | ||
| 23 | + to_hex_sha, | ||
| 24 | + to_bin_sha | ||
| 25 | + ) | ||
| 26 | + | ||
| 29 | 27 | __all__ = ( "stream_copy", "join_path", "to_native_path_windows", "to_native_path_linux", | |
| 30 | 28 | "join_path_native", "Stats", "IndexFileSHA1Writer", "Iterable", "IterableList", | |
| 31 | 29 | "BlockingLockFile", "LockFile", 'Actor', 'get_user_id', 'assure_directory_exists', | |
@@ -116,19 +114,8 @@ def assure_directory_exists(path, is_file=False): | |||
| 116 | 114 | return False | |
| 117 | 115 | ||
| 118 | 116 | def get_user_id(): | |
| 119 | - """:return: string identifying the currently active system user as name@node | ||
| 120 | - :note: user can be set with the 'USER' environment variable, usually set on windows | ||
| 121 | - :note: on unix based systems you can use the password database | ||
| 122 | - to get the login name of the effective process user""" | ||
| 123 | - if os.name == "posix": | ||
| 124 | - username = pwd.getpwuid(os.geteuid()).pw_name | ||
| 125 | - else: | ||
| 126 | - ukn = 'UNKNOWN' | ||
| 127 | - username = os.environ.get('USER', os.environ.get('USERNAME', ukn)) | ||
| 128 | - if username == ukn and hasattr(os, 'getlogin'): | ||
| 129 | - username = os.getlogin() | ||
| 130 | - # END get username from login | ||
| 131 | - return "%s@%s" % (username, platform.node()) | ||
| 117 | + """:return: string identifying the currently active system user as name@node""" | ||
| 118 | + return "%s@%s" % (getpass.getuser(), platform.node()) | ||
| 132 | 119 | ||
| 133 | 120 | #} END utilities | |
| 134 | 121 | ||
@@ -492,7 +479,7 @@ def _obtain_lock_or_raise(self): | |||
| 492 | 479 | try: | |
| 493 | 480 | fd = os.open(lock_file, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0) | |
| 494 | 481 | os.close(fd) | |
| 495 | - except OSError,e: | ||
| 482 | + except OSError as e: | ||
| 496 | 483 | raise IOError(str(e)) | |
| 497 | 484 | ||
| 498 | 485 | self._owns_lock = True | |
@@ -514,7 +501,7 @@ def _release_lock(self): | |||
| 514 | 501 | # on bloody windows, the file needs write permissions to be removable. | |
| 515 | 502 | # Why ... | |
| 516 | 503 | if os.name == 'nt': | |
| 517 | - os.chmod(lfp, 0777) | ||
| 504 | + os.chmod(lfp, int("0777", 8)) | ||
| 518 | 505 | # END handle win32 | |
| 519 | 506 | os.remove(lfp) | |
| 520 | 507 | except OSError: | |
@@ -593,9 +580,6 @@ def __new__(cls, id_attr, prefix=''): | |||
| 593 | 580 | def __init__(self, id_attr, prefix=''): | |
| 594 | 581 | self._id_attr = id_attr | |
| 595 | 582 | self._prefix = prefix | |
| 596 | - if not isinstance(id_attr, basestring): | ||
| 597 | - raise ValueError("First parameter must be a string identifying the name-property. Extend the list after initialization") | ||
| 598 | - # END help debugging ! | ||
| 599 | 583 | ||
| 600 | 584 | def __contains__(self, attr): | |
| 601 | 585 | # first try identy match for performance | |
| Back | FazBrowse Home | New Git URL |
0 commit comments