changes suggested in review

This commit is contained in:
Michael Hudson-Doyle 2020-07-09 10:47:46 +12:00
parent 164c575f2a
commit 57cd4c3e4c
1 changed files with 6 additions and 3 deletions

View File

@ -70,12 +70,15 @@ def get_device_owner():
""" Get device owner, if any """
con = SnapdConnection('', '/run/snapd.socket')
for user in con.get('v2/users').json()['result']:
user = user['email'].split('@')[0]
if os.path.isdir('/home/' + user):
if 'username' not in user:
continue
username = user['username']
homedir = '/home/' + username
if os.path.isdir(homedir):
return {
'username': user,
'realname': get_realname(user),
'homedir': '/home/' + user,
'homedir': homedir,
}
return None