Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions mig/shared/functionality/viewuser.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# --- BEGIN_HEADER ---
#
# viewuser - Display public details about a user
# Copyright (C) 2003-2023 The MiG Project lead by Brian Vinter
# Copyright (C) 2003-2025 The MiG Project lead by the Science HPC Center at UCPH

Check warning on line 7 in mig/shared/functionality/viewuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)
#
# This file is part of MiG.
#
Expand All @@ -20,12 +20,12 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Check warning on line 23 in mig/shared/functionality/viewuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)
#
# -- END_HEADER ---
#

"""Get info about a user"""

Check warning on line 28 in mig/shared/functionality/viewuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

First line should end with a period (not 'r')

from __future__ import absolute_import

Expand All @@ -42,26 +42,27 @@
from mig.shared.output import html_link
from mig.shared.profilekeywords import get_profile_specs
from mig.shared.settingskeywords import get_settings_specs
from mig.shared.user import user_gravatar_url, inline_image, anon_user_id, \

Check failure on line 45 in mig/shared/functionality/viewuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused import 'anon_user_id' (90% confidence)
anon_to_real_user_map
from mig.shared.vgrid import vgrid_request_and_job_match

Check failure on line 47 in mig/shared/functionality/viewuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused import 'vgrid_request_and_job_match' (90% confidence)
from mig.shared.vgridaccess import user_visible_user_confs, user_vgrid_access, \
CONF


def signature():
"""Signature of the main function"""

Check warning on line 53 in mig/shared/functionality/viewuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

First line should end with a period (not 'n')

Check warning on line 53 in mig/shared/functionality/viewuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

No blank lines allowed after function docstring (found 1)

defaults = {'cert_id': REJECT_UNSET}
defaults = {'cert_id': REJECT_UNSET,
'caching': ['true']}
return ['user_info', defaults]


def build_useritem_object_from_user_dict(configuration, client_id,
visible_user_id, user_home, user_dict,
allow_vgrids):
"""Build a user object based on input user_dict"""

Check warning on line 63 in mig/shared/functionality/viewuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

First line should end with a period (not 't')

Check warning on line 63 in mig/shared/functionality/viewuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

No blank lines allowed after function docstring (found 1)

profile_specs = get_profile_specs()

Check failure on line 65 in mig/shared/functionality/viewuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused variable 'profile_specs' (60% confidence)
user_specs = get_settings_specs()
user_item = {
'object_type': 'user_info',
Expand Down Expand Up @@ -170,10 +171,10 @@
return user_item


def main(client_id, user_arguments_dict):

Check failure on line 174 in mig/shared/functionality/viewuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'main' (60% confidence)
"""Main function used by front end"""

Check warning on line 175 in mig/shared/functionality/viewuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

First line should end with a period (not 'd')

Check warning on line 175 in mig/shared/functionality/viewuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

No blank lines allowed after function docstring (found 1)

(configuration, logger, output_objects, op_name) = \

Check failure on line 177 in mig/shared/functionality/viewuser.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused variable 'op_name' (60% confidence)
initialize_main_variables(client_id, op_header=False)
client_dir = client_id_dir(client_id)
defaults = signature()[1]
Expand Down Expand Up @@ -201,6 +202,7 @@
'text': confirm_html(configuration)})

user_list = accepted['cert_id']
caching = (accepted['caching'][-1].lower() in ('true', 'yes'))

# Please note that base_dir must end in slash to avoid access to other
# user dirs when own name is a prefix of another user name
Expand All @@ -209,13 +211,18 @@
client_dir)) + os.sep
status = returnvalues.OK

if caching:
caching_note = '(cached)'
else:
caching_note = ''

title_entry = find_entry(output_objects, 'title')
title_entry['text'] = 'User details'
output_objects.append({'object_type': 'header', 'text':
'Show user details'})
'Show user details %s' % caching_note})

visible_user = user_visible_user_confs(configuration, client_id)
vgrid_access = user_vgrid_access(configuration, client_id)
visible_user = user_visible_user_confs(configuration, client_id, caching)
vgrid_access = user_vgrid_access(configuration, client_id, caching)
anon_map = anon_to_real_user_map(configuration)

for visible_user_name in user_list:
Expand Down Expand Up @@ -249,4 +256,15 @@
vgrid_access)
output_objects.append(user_item)

output_objects.append({'object_type': 'html_form',
'text': '<div class="vertical-spacer"></div>'})
user_query = '%s' % '&'.join(['cert_id=%s' % i for i in user_list])
output_objects.append(
{'object_type': 'link',
'destination':
'viewuser.py?caching=false&%s' % user_query,
'class': 'refreshlink iconspace',
'title': 'View without caching',
'text': 'View without caching of user data - may take a long time'})

return (output_objects, status)