Skip to content

Commit a5afd71

Browse files
committed
fix: user getpass.getuser() to get user login name
`pwd` module is Unix-specific
1 parent 379f436 commit a5afd71

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

nipype/pipeline/plugins/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from copy import deepcopy
77
from glob import glob
88
import os
9-
import pwd
9+
import getpass
1010
import shutil
1111
from socket import gethostname
1212
import sys
@@ -52,7 +52,7 @@ def report_crash(node, traceback=None, hostname=None):
5252
exc_value,
5353
exc_traceback)
5454
timeofcrash = strftime('%Y%m%d-%H%M%S')
55-
login_name = pwd.getpwuid(os.geteuid())[0]
55+
login_name = getpass.getuser()
5656
crashfile = 'crash-%s-%s-%s.pklz' % (timeofcrash,
5757
login_name,
5858
name)

nipype/utils/provenance.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from cPickle import dumps
22
import json
33
import os
4-
import pwd
4+
import getpass
55
from socket import getfqdn
66
from uuid import uuid1
77
from nipype.external import six
@@ -363,9 +363,8 @@ def add_results(self, results):
363363

364364
# create agents
365365
user_attr = {pm.PROV["type"]: pm.PROV["Person"],
366-
pm.PROV["label"]: pwd.getpwuid(os.geteuid()).pw_name,
367-
foaf["name"]:
368-
safe_encode(pwd.getpwuid(os.geteuid()).pw_name)}
366+
pm.PROV["label"]: getpass.getuser(),
367+
foaf["name"]: safe_encode(getpass.getuser())}
369368
user_agent = self.g.agent(get_attr_id(user_attr), user_attr)
370369
agent_attr = {pm.PROV["type"]: pm.PROV["SoftwareAgent"],
371370
pm.PROV["label"]: "Nipype",

0 commit comments

Comments
 (0)