Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions mig/shared/vgrid.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
Expand All @@ -20,7 +20,7 @@
#
# 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/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)

Check warning on line 23 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)
#
# -- END_HEADER ---
#
Expand All @@ -45,7 +45,7 @@
keyword_members, keyword_all, keyword_never, keyword_any, \
keyword_none, csrf_field, default_vgrid_settings_limit, \
vgrid_nest_sep, _dot_vgrid
from mig.shared.fileio import make_symlink, move, check_readonly, check_writable, \

Check warning on line 48 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (83 > 80 characters)

Check warning on line 48 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (83 > 80 characters)
check_write_access, unpickle, acquire_file_lock, release_file_lock, walk, \
slow_walk, remove_rec, move_rec, delete_symlink
from mig.shared.findtype import is_user, is_resource
Expand Down Expand Up @@ -123,7 +123,7 @@
return jobs


def vgrid_add_remove_table(client_id,

Check failure on line 126 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'vgrid_add_remove_table' (60% confidence)

Check failure on line 126 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'vgrid_add_remove_table' (60% confidence)
vgrid_name,
item_string,
script_suffix,
Expand All @@ -147,7 +147,7 @@
_logger = configuration.logger
out = []

if not item_string in ['owner', 'member', 'resource', 'trigger']:

Check warning on line 150 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

test for membership should be 'not in'

Check warning on line 150 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

test for membership should be 'not in'
out.append({'object_type': 'error_text', 'text':
'Internal error: Unknown item type %s.' % item_string
})
Expand Down Expand Up @@ -225,7 +225,7 @@
'csrf_limit': csrf_limit})

# success, so direct and inherit are lists of unique user/res/trigger IDs
extras = [i for i in inherit if not i in direct]

Check warning on line 228 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

test for membership should be 'not in'

Check warning on line 228 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

test for membership should be 'not in'
if extras:
table = '''
<br />
Expand All @@ -246,8 +246,8 @@
val = ' '.join(val)
extra_fields_html += '<td>%s</td>' % val
table += \
""" <tr><td></td><td>%s</td>%s</tr>""" % (elem[id_field],

Check warning on line 249 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (86 > 80 characters)

Check warning on line 249 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (86 > 80 characters)
extra_fields_html)

Check warning on line 250 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (89 > 80 characters)

Check warning on line 250 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (89 > 80 characters)
elif elem:
table += \
" <tr><td></td><td>%s</td></tr>"\
Expand Down Expand Up @@ -407,7 +407,7 @@
if item_string in ["owner", "member"]:
dyn_dict['anon_user_id'] = anon_user_id(elem_id)
vgrid_table += html_link({
'destination': 'viewuser.py?cert_id=%(anon_user_id)s' % dyn_dict,

Check warning on line 410 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (85 > 80 characters)

Check warning on line 410 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (85 > 80 characters)
'class': 'userlink iconspace',
'title': 'View user details for %s' % elem_id,
'text': elem_id})
Expand Down Expand Up @@ -633,7 +633,7 @@
return False


def vgrid_is_setting(vgrid_name, option_id, configuration, recursive=True,

Check failure on line 636 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'vgrid_is_setting' (60% confidence)

Check failure on line 636 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'vgrid_is_setting' (60% confidence)
allow_missing=True):
"""Check if option_id is a setting in vgrid_name. We allow missing
parent pickle to support autonomous multi-frontend systems.
Expand All @@ -644,7 +644,7 @@
allow_missing)


def vgrid_is_sharelink(vgrid_name, option_id, configuration, recursive=True,

Check failure on line 647 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'vgrid_is_sharelink' (60% confidence)

Check failure on line 647 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'vgrid_is_sharelink' (60% confidence)
allow_missing=True):
"""Check if option_id is a sharelink in vgrid_name. We allow missing
parent pickle to support autonomous multi-frontend systems.
Expand Down Expand Up @@ -703,12 +703,12 @@
'', 1)

vgrids_list.append(vgrid_name_without_location)
if include_default and not default_vgrid in vgrids_list:

Check warning on line 706 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

test for membership should be 'not in'

Check warning on line 706 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

test for membership should be 'not in'
vgrids_list.append(default_vgrid)
return (True, vgrids_list)


def init_vgrid_script_add_rem(

Check failure on line 711 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'init_vgrid_script_add_rem' (60% confidence)

Check failure on line 711 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'init_vgrid_script_add_rem' (60% confidence)
vgrid_name,
client_id,
subject,
Expand Down Expand Up @@ -787,7 +787,7 @@
return (True, msg, [])


def init_vgrid_script_list(vgrid_name, client_id, configuration):

Check failure on line 790 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'init_vgrid_script_list' (60% confidence)

Check failure on line 790 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'init_vgrid_script_list' (60% confidence)
"""Helper for vgrid scripts"""

msg = ''
Expand All @@ -803,7 +803,7 @@
configuration):
msg += 'Failure: You must be an owner or member of '\
+ vgrid_name\
+ ' vgrid to get a list of members/owners/resources/triggers/settings/sharelinks'

Check warning on line 806 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (93 > 80 characters)

Check warning on line 806 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (93 > 80 characters)
return (False, msg, None)

return (True, msg, [])
Expand Down Expand Up @@ -833,7 +833,7 @@
if key == 'read_only':
key = 'write_shared_files'
val = not val
if not key in specs_map:

Check warning on line 836 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

test for membership should be 'not in'

Check warning on line 836 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

test for membership should be 'not in'
_logger.warning("unknown settings key %s for %s (%s)"
% (key, vgrid_name, vgrid_dict))
continue
Expand Down Expand Up @@ -1224,7 +1224,7 @@
return True


def user_allowed_vgrids(configuration, client_id, inherited=False):

Check failure on line 1227 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'user_allowed_vgrids' (60% confidence)

Check failure on line 1227 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'user_allowed_vgrids' (60% confidence)
"""Return a list of all VGrids that the user with client_id is allowed to
access. I.e. the VGrids that the user is member or owner of.
The optional inherited argument is used to add any parent vgrids to match
Expand All @@ -1244,7 +1244,7 @@
return allowed


def res_allowed_vgrids(configuration, client_id):

Check failure on line 1247 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'res_allowed_vgrids' (60% confidence)

Check failure on line 1247 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'res_allowed_vgrids' (60% confidence)
"""Return a list of all VGrids that the resource with
client_id is allowed to access. I.e. the VGrids
that the resource is member of.
Expand All @@ -1261,7 +1261,7 @@
return allowed


def vgrid_access_match(configuration, job_owner, job, res_id, res):

Check failure on line 1264 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'vgrid_access_match' (60% confidence)

Check failure on line 1264 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'vgrid_access_match' (60% confidence)
"""Match job and resource vgrids and include access control.
The job_owner and res_id are used directly in vgrid access checks
so it is important that res_id is on the private (not anonymized)
Expand Down Expand Up @@ -1534,7 +1534,7 @@
id_list, None, rank)


def vgrid_add_triggers(configuration, vgrid_name, id_list, update_id=None,

Check failure on line 1537 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'vgrid_add_triggers' (60% confidence)

Check failure on line 1537 in mig/shared/vgrid.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'vgrid_add_triggers' (60% confidence)
rank=None):
"""Append id_list to pickled list of triggers for vgrid_name"""
return vgrid_add_entities(configuration, vgrid_name, 'triggers',
Expand Down Expand Up @@ -2309,9 +2309,9 @@
return (success, msg)


if __name__ == "__main__":
def legacy_main(_exit=sys.exit, _print=print):
from mig.shared.conf import get_configuration_object
conf = get_configuration_object()
conf = get_configuration_object(skip_log=True, disable_auth_log=True)
client_id = '/C=DK/CN=John Doe/emailAddress=john@doe.org'
if sys.argv[1:]:
client_id = sys.argv[1]
Expand Down Expand Up @@ -2432,3 +2432,7 @@
if load_status:
print(vgrid_set_members(conf, dummy_vgrid, orig_members))
print(vgrid_members(dummy_vgrid, conf))


if __name__ == "__main__":
legacy_main()
Loading