Use attribute accessors for pwd

This commit is contained in:
Stefano Rivera 2010-12-21 00:24:03 +02:00
parent 7229c63dc2
commit 4336f7442a

View File

@ -138,7 +138,7 @@ def ubu_email(name=None, email=None, export=True):
email = os.environ[var].strip() email = os.environ[var].strip()
if not name: if not name:
gecos_name = pwd.getpwuid(os.getuid())[4].split(',')[0].strip() gecos_name = pwd.getpwuid(os.getuid()).pw_gecos.split(',')[0].strip()
if gecos_name: if gecos_name:
name = gecos_name name = gecos_name
@ -146,7 +146,7 @@ def ubu_email(name=None, email=None, export=True):
mailname = socket.getfqdn() mailname = socket.getfqdn()
if os.path.isfile('/etc/mailname'): if os.path.isfile('/etc/mailname'):
mailname = open('/etc/mailname', 'r').read().strip() mailname = open('/etc/mailname', 'r').read().strip()
email = pwd.getpwuid(os.getuid())[0] + '@' + mailname email = pwd.getpwuid(os.getuid()).pw_name + '@' + mailname
if export: if export:
os.environ['DEBFULLNAME'] = name os.environ['DEBFULLNAME'] = name