Skip to content
Merged
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
5 changes: 4 additions & 1 deletion mig/shared/configuration.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,8 @@
#
# 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.
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
#
# -- END_HEADER ---
#
Expand All @@ -31,12 +32,12 @@
from __future__ import print_function
from future import standard_library
from builtins import range
from builtins import object

Check failure on line 35 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused import 'object' (90% confidence)

Check failure on line 35 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused import 'object' (90% confidence)

import base64
import copy
import datetime
import functools

Check failure on line 40 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused import 'functools' (90% confidence)

Check failure on line 40 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused import 'functools' (90% confidence)
import inspect
import os
import pwd
Expand Down Expand Up @@ -69,7 +70,7 @@
valid_filter_methods, default_twofactor_auth_apps, \
mig_conf_section_dirname
from mig.shared.logger import Logger, SYSLOG_GDP
from mig.shared.htmlgen import menu_items, vgrid_items

Check failure on line 73 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused import 'vgrid_items' (90% confidence)

Check failure on line 73 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused import 'vgrid_items' (90% confidence)
from mig.shared.fileio import read_file, load_json, write_file
except ImportError as ioe:
print("could not import migrid modules")
Expand Down Expand Up @@ -142,7 +143,7 @@
return val
# logger.debug("expand any ENV and FILE content in %r" % val)
env_pattern = "[a-zA-Z][a-zA-Z0-9_]+"
cache_pattern = file_pattern = "[^ ]+"

Check failure on line 146 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused variable 'cache_pattern' (60% confidence)

Check failure on line 146 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused variable 'cache_pattern' (60% confidence)
expanded = val
expand_pairs = [(keyword_env, env_pattern), (keyword_file, file_pattern)]
for (key, pattern) in expand_pairs:
Expand Down Expand Up @@ -170,7 +171,7 @@
# "reading conf content from file in %r" % cache)
content = read_file(path, logger)
if cache and content:
# logger.debug("caching conf content salt in %r" % cache)

Check warning on line 174 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)

Check warning on line 174 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)
write_file(content, cache, logger)
if not content:
logger.warning("salt file not found or empty: %s" % path)
Expand All @@ -191,7 +192,7 @@
return expanded


def fix_missing(config_file, verbose=True):

Check failure on line 195 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'fix_missing' (60% confidence)

Check failure on line 195 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'fix_missing' (60% confidence)
"""Add missing configuration options - used by checkconf script"""

config = ConfigParser()
Expand Down Expand Up @@ -244,7 +245,7 @@
'server_home': '~/state/server_home/',
'webserver_home': '~/state/webserver_home/',
'sessid_to_mrsl_link_home': '~/state/sessid_to_mrsl_link_home/',
'sessid_to_jupyter_mount_link_home': '~/state/sessid_to_jupyter_mount_link_home/',

Check warning on line 248 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (90 > 80 characters)

Check warning on line 248 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (90 > 80 characters)
'mig_system_files': '~/state/mig_system_files/',
'mig_system_storage': '~/state/mig_system_storage',
'mig_system_run': '~/state/mig_system_run/',
Expand Down Expand Up @@ -379,7 +380,7 @@
'architectures': 'X86 AMD64 IA64 SPARC SPARC64 ITANIUM SUN4U SPARC-T1',
'scriptlanguages': 'sh python java',
'jobtypes': 'batch bulk all',
'lrmstypes': 'Native Native-execution-leader Batch Batch-execution-leader',

Check warning on line 383 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (83 > 80 characters)

Check warning on line 383 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (83 > 80 characters)
}
scheduler_section = {'algorithm': 'FairFit',
'expire_after': '99999999999',
Expand Down Expand Up @@ -421,7 +422,7 @@
'ACCOUNTING': accounting_section,
}
for section in defaults:
if not section in config.sections():

Check warning on line 425 in mig/shared/configuration.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 425 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

test for membership should be 'not in'
config.add_section(section)

modified = False
Expand All @@ -435,7 +436,7 @@
modified = True
if modified:
backup_path = '%s.%d' % (config_file, time.time())
print('Backing up existing configuration to %s as update removes all comments'

Check warning on line 439 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (86 > 80 characters)

Check warning on line 439 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (86 > 80 characters)
% backup_path)
fd = open(config_file, 'r')
backup_fd = open(backup_path, 'w')
Expand Down Expand Up @@ -727,7 +728,7 @@
'VERIFYFILES', 'VGRID'],
'job_cond_yellow': ['DISK', 'MEMORY', 'CPUTIME'],
'job_cond_orange': ['CPUCOUNT', 'NODECOUNT'],
'job_cond_red': ['EXECUTABLES', 'INPUTFILES', 'REGISTERED', 'SEEN_WITHIN_X'],

Check warning on line 731 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)

Check warning on line 731 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)
'enable_suggest': False,
'suggest_threshold': 'GREEN',

Expand Down Expand Up @@ -768,12 +769,14 @@
def __init__(self, config_file, verbose=False, skip_log=False,
disable_auth_log=False):
self.config_file = config_file
self.mig_server_id = None

Check failure on line 772 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused attribute 'mig_server_id' (60% confidence)

Check failure on line 772 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused attribute 'mig_server_id' (60% confidence)
# Explicitly init a few helpers hot-plugged and used in ways where it's
# less obvious if they are always guaranteed to already be initialized.
self.default_page = None
self.auth_logger_obj = None
self.gdp_logger_obj = None
self.logger_obj = None
self.logger = None

configuration_properties = copy.deepcopy(_CONFIGURATION_PROPERTIES)

Expand Down Expand Up @@ -804,7 +807,7 @@
try:
if self.logger:
self.logger.info('reloading configuration and reopening log')
except:

Check warning on line 810 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

do not use bare 'except'

Check warning on line 810 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

do not use bare 'except'
pass

try:
Expand Down Expand Up @@ -839,7 +842,7 @@
self.log_dir = config.get('GLOBAL', 'log_dir')
self.logfile = config.get('GLOBAL', 'logfile')
self.loglevel = config.get('GLOBAL', 'loglevel')
except:

Check warning on line 845 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

do not use bare 'except'

Check warning on line 845 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

do not use bare 'except'

# Fall back to file in current dir

Expand Down Expand Up @@ -949,9 +952,9 @@
# Mandatory options first

try:
self.mig_server_id = config.get('GLOBAL', 'mig_server_id')

Check failure on line 955 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused attribute 'mig_server_id' (60% confidence)

Check failure on line 955 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused attribute 'mig_server_id' (60% confidence)
self.mrsl_files_dir = config.get('GLOBAL', 'mrsl_files_dir')

Check failure on line 956 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused attribute 'mrsl_files_dir' (60% confidence)

Check failure on line 956 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused attribute 'mrsl_files_dir' (60% confidence)
self.re_files_dir = config.get('GLOBAL', 're_files_dir')

Check failure on line 957 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused attribute 're_files_dir' (60% confidence)

Check failure on line 957 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused attribute 're_files_dir' (60% confidence)
self.re_pending_dir = config.get('GLOBAL', 're_pending_dir')
self.re_home = config.get('GLOBAL', 're_home')
self.grid_stdin = config.get('GLOBAL', 'grid_stdin')
Expand Down Expand Up @@ -989,7 +992,7 @@
self.jobtypes = config.get('GLOBAL', 'jobtypes').split()
self.lrmstypes = config.get('GLOBAL', 'lrmstypes').split()
self.sessid_to_mrsl_link_home = config.get('GLOBAL',
'sessid_to_mrsl_link_home')

Check warning on line 995 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (82 > 80 characters)

Check warning on line 995 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (82 > 80 characters)
self.mig_system_files = config.get('GLOBAL',
'mig_system_files')
self.mig_system_storage = config.get('GLOBAL',
Expand Down Expand Up @@ -1017,7 +1020,7 @@
except Exception as err:
try:
self.logger.error('Error in reloading configuration: %s' % err)
except:

Check warning on line 1023 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

do not use bare 'except'

Check warning on line 1023 in mig/shared/configuration.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

do not use bare 'except'
pass
raise Exception('Failed to parse configuration: %s' % err)

Expand Down
Loading