| 1 | #!/usr/bin/env python
|
|---|
| 2 | # -*- coding: utf-8 -*-
|
|---|
| 3 | #
|
|---|
| 4 | # (c) Copyright 2003-2015 HP Development Company, L.P.
|
|---|
| 5 | #
|
|---|
| 6 | # This program is free software; you can redistribute it and/or modify
|
|---|
| 7 | # it under the terms of the GNU General Public License as published by
|
|---|
| 8 | # the Free Software Foundation; either version 2 of the License, or
|
|---|
| 9 | # (at your option) any later version.
|
|---|
| 10 | #
|
|---|
| 11 | # This program is distributed in the hope that it will be useful,
|
|---|
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 14 | # GNU General Public License for more details.
|
|---|
| 15 | #
|
|---|
| 16 | # You should have received a copy of the GNU General Public License
|
|---|
| 17 | # along with this program; if not, write to the Free Software
|
|---|
| 18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 19 | #
|
|---|
| 20 | # Author: Don Welch
|
|---|
| 21 | #
|
|---|
| 22 | # NOTE: This module is safe for 'from g import *'
|
|---|
| 23 | #
|
|---|
| 24 |
|
|---|
| 25 | # Std Lib
|
|---|
| 26 | import sys
|
|---|
| 27 | import os
|
|---|
| 28 | import os.path
|
|---|
| 29 | import locale
|
|---|
| 30 | import pwd
|
|---|
| 31 | import stat
|
|---|
| 32 | import re
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 | if os.name == 'os2':
|
|---|
| 36 | try:
|
|---|
| 37 | username = pwd.getpwuid(os.getuid())[0]
|
|---|
| 38 | pdb = pwd.getpwnam(username)
|
|---|
| 39 | userhome = pdb[5]
|
|---|
| 40 | if userhome == '/nonexistent':
|
|---|
| 41 | userhome = os.getenv("HOME")
|
|---|
| 42 | except:
|
|---|
| 43 | username = os.getenv("USER")
|
|---|
| 44 | userhome = os.getenv("HOME")
|
|---|
| 45 | else:
|
|---|
| 46 | username = pwd.getpwuid(os.getuid())[0]
|
|---|
| 47 | pdb = pwd.getpwnam(username)
|
|---|
| 48 | userhome = pdb[5]
|
|---|
| 49 |
|
|---|
| 50 | print("username %s, userhome %s %s") % (username, userhome, os.name)
|
|---|