equal
deleted
inserted
replaced
517 try: |
517 try: |
518 return sys.getwindowsversion()[3] == 1 |
518 return sys.getwindowsversion()[3] == 1 |
519 except AttributeError: |
519 except AttributeError: |
520 return os.name == 'nt' and 'command' in os.environ.get('comspec', '') |
520 return os.name == 'nt' and 'command' in os.environ.get('comspec', '') |
521 |
521 |
|
522 def username(uid=None): |
|
523 """Return the name of the user with the given uid. |
|
524 |
|
525 If uid is None, return the name of the current user.""" |
|
526 try: |
|
527 import pwd |
|
528 if uid is None: |
|
529 uid = os.getuid() |
|
530 try: |
|
531 return pwd.getpwuid(uid)[0] |
|
532 except KeyError: |
|
533 return str(uid) |
|
534 except ImportError: |
|
535 return None |
|
536 |
|
537 def groupname(gid=None): |
|
538 """Return the name of the group with the given gid. |
|
539 |
|
540 If gid is None, return the name of the current group.""" |
|
541 try: |
|
542 import grp |
|
543 if gid is None: |
|
544 gid = os.getgid() |
|
545 try: |
|
546 return grp.getgrgid(gid)[0] |
|
547 except KeyError: |
|
548 return str(gid) |
|
549 except ImportError: |
|
550 return None |
|
551 |
522 # Platform specific variants |
552 # Platform specific variants |
523 if os.name == 'nt': |
553 if os.name == 'nt': |
524 demandload(globals(), "msvcrt") |
554 demandload(globals(), "msvcrt") |
525 nulldev = 'NUL:' |
555 nulldev = 'NUL:' |
526 |
556 |