diff --git a/.ci/install_conda.py b/.ci/install_conda.py index 04580c82..2e33897a 100755 --- a/.ci/install_conda.py +++ b/.ci/install_conda.py @@ -1,13 +1,13 @@ """Deploy the evaluation_system / core.""" + import argparse import logging -from pathlib import Path import shlex -from subprocess import CalledProcessError, PIPE, run import urllib.request +from pathlib import Path +from subprocess import PIPE, CalledProcessError, run from tempfile import TemporaryDirectory - MINICONDA_URL = "https://repo.anaconda.com/miniconda/Miniconda3-latest" logging.basicConfig(format="%(name)s - %(levelname)s - %(message)s", level=logging.INFO) diff --git a/.github/workflows/build_job.yml b/.github/workflows/build_job.yml index f0d568b8..4f7c9998 100644 --- a/.github/workflows/build_job.yml +++ b/.github/workflows/build_job.yml @@ -1,17 +1,18 @@ name: Build and publish the container image -run-name: ${{ github.actor }} is building the container +run-name: ${{ github.actor }} is createing a new release "on": workflow_dispatch: push: tags: - - '*' - branches: - - 'main' + - 'v*.*.*' jobs: + lint: + uses: ./.github/workflows/test_job.yml build-and-push-image: runs-on: ubuntu-latest + needs: lint permissions: contents: read packages: write @@ -26,7 +27,7 @@ jobs: name: Get tag id: repository run: | - echo "tag=v$(cat package.json|jq -r .version)" >> $GITHUB_OUTPUT + echo "tag=$(cat package.json|jq -r .version)" >> $GITHUB_OUTPUT echo "repo=$(echo ${{ github.repository }}|tr 'A-Z' 'a-z')" >> $GITHUB_OUTPUT - @@ -51,7 +52,37 @@ jobs: with: context: . platforms: linux/amd64 + build-args: VERSION=${{steps.repository.outputs.tag}} push: true tags: | ghcr.io/${{ steps.repository.outputs.repo }}:${{ steps.repository.outputs.tag }} ghcr.io/${{ steps.repository.outputs.repo }}:latest + + bump-web-version: + runs-on: ubuntu-latest + needs: [build-and-push-image, lint] + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python 3 + uses: actions/setup-python@v4 + with: + python-version: "3.X" + + - name: Get tag + id: repository + run: | + echo "repo=$(echo ${{ github.repository }}|tr 'A-Z' 'a-z')" >> $GITHUB_OUTPUT + echo "tag=$(cat package.json|jq -r .version)" >> $GITHUB_OUTPUT + + - name: Do the release job + run: make release + env: + GITHUB_TOKEN: ${{secrets.ACCESS_TOKEN}} + REPO_VERSION: ${{ steps.repository.outputs.tag }} diff --git a/.github/workflows/test_job.yml b/.github/workflows/test_job.yml index 7221b3f7..642312bc 100644 --- a/.github/workflows/test_job.yml +++ b/.github/workflows/test_job.yml @@ -1,11 +1,7 @@ name: Tests run-name: ${{ github.actor }} is doing some smoke tests -on: - push: - pull_request: - workflow_dispatch: - +on: [push, pull_request, workflow_call] jobs: Smoke-tests: runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..fb307566 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,23 @@ +# Changelog + +All notable changes to this project will be documented in this file. +## [v2403.0.0] + +### Added +- Change lock file, to keep track of changes. + + +# Template: +## [Unreleased] + +### Added +- New feature X. +- New feature Y. + +### Changed +- Improved performance in component A. +- Updated dependency B to version 2.0.0. + +### Fixed +- Fixed issue causing application crash on startup. +- Fixed bug preventing users from logging in. diff --git a/Dockerfile b/Dockerfile index 5d664ee0..e7629f5e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,30 @@ ARG CONDA_ENV_DIR=/opt/condaenv ARG FREVA_WEB_DIR=/opt/freva_web +ARG VERSION FROM condaforge/mambaforge -LABEL maintainer="DRKZ-CLINT" -LABEL repository="https://github.com/FREVA-CLINT/freva-web" - +LABEL org.opencontainers.image.authors="DRKZ-CLINT" +LABEL org.opencontainers.image.source="https://github.com/FREVA-CLINT/freva-web" +LABEL org.opencontainers.image.version="$VERSION" ARG CONDA_ENV_DIR ARG FREVA_WEB_DIR +RUN set -e && \ + groupadd -r -g 1000 freva && \ + adduser --uid 1000 --gid 1000 --gecos "Freva user" \ + --shell /bin/bash --disabled-password freva --home ${FREVA_WEB_DIR} &&\ + mkdir -p ${CONDA_ENV_DIR} && chown -R freva:freva $CONDA_ENV_DIR WORKDIR ${FREVA_WEB_DIR} COPY . . - ENV PATH=$CONDA_ENV_DIR/bin:$PATH\ DJANGO_SUPERUSER_EMAIL=freva@dkrz.de - -RUN set -e \ - && mamba env create -p ${CONDA_ENV_DIR} -f conda-env.yml \ - && npm install && npm run build-production \ - && mamba clean -afy \ - && rm -rf node_modules \ - && echo "export PATH=${PATH}" >> /root/.bashrc - +RUN set -e && \ + mamba env create -y -p ${CONDA_ENV_DIR} -f conda-env.yml &&\ + mamba clean -afy &&\ + npm install && npm run build-production &&\ + rm -rf node_modules &&\ + echo "export PATH=${PATH}" >> ${FREVA_WEB_DIR}/.bashrc &&\ + chown -R freva:freva ${FREVA_WEB_DIR} +USER freva EXPOSE 8000 - CMD ./init_django.sh diff --git a/Makefile b/Makefile index 17434489..c5c1c1f5 100644 --- a/Makefile +++ b/Makefile @@ -53,10 +53,16 @@ run: runfrontend runserver lint: setup-node npm run lint-format npm run lint - black -t py310 --check . + isort -c --profile black -t py312 . tests: setup-node npm run build-production npm run build rm -rf node_modules pytest -vv $(PWD) tests/ + +release: + pip install git-python requests packaging tomli + curl -H 'Cache-Control: no-cache' -Ls -o bump.py https://raw.githubusercontent.com/FREVA-CLINT/freva-deployment/versions/release.py + python3 bump.py tag django_evaluation -b version + rm bump.py diff --git a/README.md b/README.md index e1dd93a0..e75ceea4 100644 --- a/README.md +++ b/README.md @@ -171,18 +171,12 @@ it to the registry. To do so please follow the following steps. ```json "version": "2023.07.19" ``` -- After you have push the version changes to the main branch you can create - a new tag with the same version: +- After you have pushed the version changes to the main branch you can trigger + the release procedure: ```console - git tag -a vVERSION -m "comment" + make release ``` - for example: - ```console - git tag -a v2023.07.19 -m "Some prettifications." - ``` -- Push the tag to the remote repository: - ```console - git push origin vVERSION - ``` - -These steps trigger the creation of a new container image. +This will check the current version of the `main` branch and trigger +a GitHub continuous integration pipeline to create the new release. The procedure +performs a couple of checks, if theses checks fail please make sure to address +the issues. diff --git a/base/LdapUser.py b/base/LdapUser.py index 726d66c9..411ae49d 100644 --- a/base/LdapUser.py +++ b/base/LdapUser.py @@ -1,10 +1,13 @@ import os +from configparser import ConfigParser as Config +from configparser import ExtendedInterpolation + +from evaluation_system.misc import config from evaluation_system.model.db import UserDB from evaluation_system.model.user import User + from base.exceptions import UserNotFoundError from django_evaluation.ldaptools import get_ldap_object -from configparser import ConfigParser as Config, ExtendedInterpolation -from evaluation_system.misc import config class LdapUser(User): diff --git a/base/admin.py b/base/admin.py index 374103e7..01d8e7a1 100644 --- a/base/admin.py +++ b/base/admin.py @@ -1,8 +1,6 @@ from django.contrib import admin from django.contrib.auth.admin import UserAdmin -from django.contrib.auth.models import User - -from django.contrib.auth.models import Permission +from django.contrib.auth.models import Permission, User from .models import UIMessages diff --git a/base/models.py b/base/models.py index 94d8c85a..372d2ca9 100644 --- a/base/models.py +++ b/base/models.py @@ -1,8 +1,8 @@ -from django.db import models -from django.contrib.auth.models import User - from datetime import datetime +from django.contrib.auth.models import User +from django.db import models + def isGuest(self): groups = self.groups.filter(name="Guest") diff --git a/base/serializers.py b/base/serializers.py index 3784a430..13de182b 100644 --- a/base/serializers.py +++ b/base/serializers.py @@ -1,5 +1,5 @@ -from rest_framework import serializers from django.contrib.auth.models import User +from rest_framework import serializers from django_evaluation.settings.local import HOME_DIRS_AVAILABLE diff --git a/base/urls.py b/base/urls.py index 0a46b3a4..2338fc83 100644 --- a/base/urls.py +++ b/base/urls.py @@ -1,4 +1,5 @@ from django.urls import re_path as url + import base.views urlpatterns = [ diff --git a/base/views.py b/base/views.py index 8a185315..c4d8f6b3 100644 --- a/base/views.py +++ b/base/views.py @@ -1,17 +1,17 @@ import logging -from base.models import UIMessages - -from django.http import HttpResponseRedirect -from django.shortcuts import render import django.contrib.auth as auth -from django.contrib.auth.decorators import login_required, user_passes_test -from django.views.decorators.debug import sensitive_variables, sensitive_post_parameters -from django_evaluation.monitor import _restart from django.conf import settings +from django.contrib.auth.decorators import login_required, user_passes_test +from django.http import HttpResponseRedirect +from django.shortcuts import render from django.urls import reverse -from evaluation_system.misc import config from django.utils.http import url_has_allowed_host_and_scheme +from django.views.decorators.debug import sensitive_post_parameters, sensitive_variables +from evaluation_system.misc import config + +from base.models import UIMessages +from django_evaluation.monitor import _restart @sensitive_variables("passwd") @@ -113,6 +113,7 @@ def contact(request): """ if request.method == "POST": from templated_email import send_templated_mail + from django_evaluation.ldaptools import get_ldap_object user_info = get_ldap_object() diff --git a/base/views_api.py b/base/views_api.py index 089e0277..b935a91f 100644 --- a/base/views_api.py +++ b/base/views_api.py @@ -1,8 +1,9 @@ -from rest_framework.views import APIView from rest_framework.response import Response +from rest_framework.views import APIView -from base.LdapUser import LdapUser from base.exceptions import UserNotFoundError +from base.LdapUser import LdapUser + from .serializers import UserSerializer diff --git a/conda-env.yml b/conda-env.yml index 930c32ab..4d4e8445 100644 --- a/conda-env.yml +++ b/conda-env.yml @@ -30,6 +30,7 @@ dependencies: - pip - pip: - black + - isort - requests_mock - django-auth-ldap - django-datatable-view diff --git a/django_evaluation/ldaptools.py b/django_evaluation/ldaptools.py index 3650a143..33f31b34 100644 --- a/django_evaluation/ldaptools.py +++ b/django_evaluation/ldaptools.py @@ -1,16 +1,18 @@ from __future__ import annotations -from abc import ABCMeta, abstractmethod + +import grp import importlib +import pwd import time +from abc import ABCMeta, abstractmethod from typing import Iterator -from django_evaluation import settings -from django_evaluation.utils import background +import ldap from django.core.cache import cache, caches from django.core.exceptions import ImproperlyConfigured -import ldap -import grp -import pwd + +from django_evaluation import settings +from django_evaluation.utils import background """ FIXME: 28.03.2022 diff --git a/django_evaluation/monitor.py b/django_evaluation/monitor.py index ccb0629a..c599e55f 100644 --- a/django_evaluation/monitor.py +++ b/django_evaluation/monitor.py @@ -2,12 +2,13 @@ This is an example code for restarting after code changes from http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode#Restarting_Daemon_Processes """ + +import atexit import os -import sys +import queue import signal +import sys import threading -import atexit -import queue _interval = 1.0 _times = {} diff --git a/django_evaluation/settings/base.py b/django_evaluation/settings/base.py index e320ce83..8713a8dd 100755 --- a/django_evaluation/settings/base.py +++ b/django_evaluation/settings/base.py @@ -3,15 +3,16 @@ repo. If you need to override a setting locally, use local.py """ -import os import logging +import os from pathlib import Path +import django.utils + # Normally you should not import ANYTHING from Django directly # into your settings, but ImproperlyConfigured is an exception. from django.core.exceptions import ImproperlyConfigured from django.urls import reverse_lazy -import django.utils def get_env_setting(setting): diff --git a/django_evaluation/settings/local.py b/django_evaluation/settings/local.py index 37e6bb33..df3bdaa4 100755 --- a/django_evaluation/settings/local.py +++ b/django_evaluation/settings/local.py @@ -1,17 +1,15 @@ -from pathlib import Path import os +import shutil import sys +from pathlib import Path + import ldap -from django_auth_ldap.config import ( - LDAPSearch, - NestedGroupOfNamesType, - PosixGroupType, -) -import shutil -import toml import requests +import toml from django.urls import reverse_lazy +from django_auth_ldap.config import LDAPSearch, NestedGroupOfNamesType, PosixGroupType from evaluation_system.misc import config + from base.exceptions import UnknownLDAPGroupTypeError freva_share_path = Path(os.environ["EVALUATION_SYSTEM_CONFIG_FILE"]).parent diff --git a/django_evaluation/settings/test.py b/django_evaluation/settings/test.py index 3c127387..11512d26 100644 --- a/django_evaluation/settings/test.py +++ b/django_evaluation/settings/test.py @@ -6,7 +6,6 @@ from .base import * - TEST_RUNNER = "discover_runner.DiscoverRunner" TEST_DISCOVER_TOP_LEVEL = PROJECT_ROOT TEST_DISCOVER_ROOT = PROJECT_ROOT diff --git a/django_evaluation/urls.py b/django_evaluation/urls.py index 70d767c0..74b53764 100644 --- a/django_evaluation/urls.py +++ b/django_evaluation/urls.py @@ -1,19 +1,21 @@ """ Default urlconf for django_evaluation """ from django.conf import settings -from django.urls import include, re_path as url from django.conf.urls import static -from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.contrib import admin +from django.contrib.staticfiles.urls import staticfiles_urlpatterns +from django.urls import include +from django.urls import re_path as url from django.views.generic import RedirectView + from base.views_api import AuthenticatedUser +from history.views_api import ResultFacets, ResultFiles from plugins.views_api import ( - PluginsList, ExportPlugin, PluginDetail, + PluginsList, SendMailToDeveloper, ) -from history.views_api import ResultFacets, ResultFiles from solr.views_api import ncdump admin.autodiscover() diff --git a/django_evaluation/utils.py b/django_evaluation/utils.py index 40c3cb7d..ebc77bbc 100644 --- a/django_evaluation/utils.py +++ b/django_evaluation/utils.py @@ -1,6 +1,7 @@ """Collection of utility functions.""" from __future__ import annotations + import threading from typing import Any, Callable diff --git a/django_evaluation/wsgi.py b/django_evaluation/wsgi.py index 95db6523..6b475cf8 100644 --- a/django_evaluation/wsgi.py +++ b/django_evaluation/wsgi.py @@ -13,9 +13,10 @@ framework. """ + import os -import sys import site +import sys PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__) + "../../") @@ -47,6 +48,7 @@ # file. This includes Django's development server, if the WSGI_APPLICATION # setting points here. from django.core.wsgi import get_wsgi_application + from django_evaluation.ldaptools import get_ldap_object LdapCls = get_ldap_object() diff --git a/docker/solr/ingest_dummy_data.py b/docker/solr/ingest_dummy_data.py index d9feee30..992916fa 100644 --- a/docker/solr/ingest_dummy_data.py +++ b/docker/solr/ingest_dummy_data.py @@ -3,9 +3,8 @@ import logging from pathlib import Path -from evaluation_system.model.solr_core import SolrCore from evaluation_system.misc import config, logger - +from evaluation_system.model.solr_core import SolrCore if __name__ == "__main__": logger.setLevel(logging.INFO) diff --git a/dummy_plugin/dummy.py b/dummy_plugin/dummy.py index dff086c7..885977c0 100644 --- a/dummy_plugin/dummy.py +++ b/dummy_plugin/dummy.py @@ -1,18 +1,17 @@ -import tempfile -import shutil import os +import shutil +import tempfile -from evaluation_system.api.plugin import PluginAbstract from evaluation_system.api.parameters import ( - ParameterDictionary, - Integer, + Directory, Float, + Integer, + ParameterDictionary, String, - Directory, ) - -from evaluation_system.model.user import User +from evaluation_system.api.plugin import PluginAbstract from evaluation_system.model.db import UserDB +from evaluation_system.model.user import User class DummyPlugin(PluginAbstract): diff --git a/history/admin.py b/history/admin.py index 18605b96..54ed5478 100644 --- a/history/admin.py +++ b/history/admin.py @@ -1,8 +1,9 @@ from django.contrib import admin -from history.models import History, Configuration from django.contrib.auth.models import User from django.utils.html import format_html +from history.models import Configuration, History + class HistoryAmdin(admin.ModelAdmin): list_display = ( diff --git a/history/models.py b/history/models.py index 8df194b4..24001803 100644 --- a/history/models.py +++ b/history/models.py @@ -1,7 +1,7 @@ from evaluation_system.model.history.models import ( + Configuration, History, HistoryTag, Result, ResultTag, - Configuration, ) diff --git a/history/templatetags/dialogtags.py b/history/templatetags/dialogtags.py index 556a101c..5016533c 100644 --- a/history/templatetags/dialogtags.py +++ b/history/templatetags/dialogtags.py @@ -1,9 +1,10 @@ +import json + from django import template -from django_evaluation.ldaptools import get_ldap_object from django.utils.safestring import mark_safe -from django_evaluation import settings -import json +from django_evaluation import settings +from django_evaluation.ldaptools import get_ldap_object register = template.Library() diff --git a/history/templatetags/resulttags.py b/history/templatetags/resulttags.py index 66c0cc0e..e65103f3 100644 --- a/history/templatetags/resulttags.py +++ b/history/templatetags/resulttags.py @@ -1,18 +1,17 @@ +import re + from django import template -from django.utils.safestring import mark_safe +from django.template.loader import render_to_string from django.utils.encoding import force_str from django.utils.html import conditional_escape -from django.template.loader import render_to_string -from base.LdapUser import LdapUser +from django.utils.safestring import mark_safe +from evaluation_system.misc.exceptions import PluginManagerException + from base.exceptions import UserNotFoundError +from base.LdapUser import LdapUser from django_evaluation import settings - -from history.utils import FileDict from history.models import HistoryTag - -from evaluation_system.misc.exceptions import PluginManagerException - -import re +from history.utils import FileDict register = template.Library() diff --git a/history/urls.py b/history/urls.py index 80844ee8..8be2049a 100644 --- a/history/urls.py +++ b/history/urls.py @@ -1,10 +1,10 @@ -from django.urls import re_path as url from django.contrib.auth.decorators import login_required +from django.urls import re_path as url from django.views.decorators.cache import never_cache + from history import views from plugins.views_api import ShareResultsByMail - urlpatterns = [ url( r"^$", never_cache(login_required(views.HistoryTable.as_view())), name="history" diff --git a/history/utils.py b/history/utils.py index 645d331d..986168ce 100644 --- a/history/utils.py +++ b/history/utils.py @@ -1,9 +1,9 @@ import os -from evaluation_system.misc import utils +from evaluation_system.misc import config, utils from evaluation_system.model.history.models import History, HistoryTag + from django_evaluation import settings -from evaluation_system.misc import config from django_evaluation.settings.local import SERVER_EMAIL @@ -151,6 +151,7 @@ def sendmail_to_follower(request, history_id, subject, message): :param message: the mesaage """ from django.urls import reverse + from django_evaluation.ldaptools import get_ldap_object follower = HistoryTag.objects.filter(history_id_id=history_id).filter( diff --git a/history/views.py b/history/views.py index 10ae02ea..d5717373 100644 --- a/history/views.py +++ b/history/views.py @@ -3,39 +3,32 @@ import os from pathlib import Path -from django.shortcuts import render -from django.http import HttpResponse -from django.core.exceptions import PermissionDenied, ObjectDoesNotExist +import evaluation_system.api.plugin_manager as pm +from datatableview import Datatable, columns +from datatableview.views import DatatableView from django.contrib.auth.decorators import login_required -from django.views.decorators.debug import sensitive_post_parameters from django.contrib.flatpages.models import FlatPage +from django.core.exceptions import ObjectDoesNotExist, PermissionDenied +from django.db.models import Q +from django.http import HttpResponse +from django.shortcuts import get_object_or_404, render +from django.urls import reverse from django.utils.html import escape -from datatableview import columns -from datatableview import Datatable -from datatableview.views import DatatableView -from django.utils.html import escape - - -import evaluation_system.api.plugin_manager as pm -from evaluation_system.model.db import UserDB +from django.views.decorators.debug import sensitive_post_parameters from evaluation_system.api.workload_manager import get_job_class -from evaluation_system.model.user import User -from evaluation_system.misc.exceptions import PluginManagerException from evaluation_system.misc import config as eval_config +from evaluation_system.misc.exceptions import PluginManagerException +from evaluation_system.model.db import UserDB from evaluation_system.model.history.models import History, ResultTag -from base.LdapUser import LdapUser +from evaluation_system.model.user import User + from base.exceptions import UserNotFoundError +from base.LdapUser import LdapUser from django_evaluation import settings -from plugins.utils import ssh_call, get_scheduler_hosts - -from history.utils import FileDict, sendmail_to_follower - -from django.shortcuts import get_object_or_404 -from django.db.models import Q -from django.urls import reverse - from history.models import HistoryTag from history.templatetags.resulttags import mask_uid +from history.utils import FileDict, sendmail_to_follower +from plugins.utils import get_scheduler_hosts, ssh_call class HistoryDatatable(Datatable): diff --git a/history/views_api.py b/history/views_api.py index 1f6bb356..bb8ba7d8 100644 --- a/history/views_api.py +++ b/history/views_api.py @@ -1,14 +1,14 @@ import json import re + +from django.conf import settings +from django.core.cache import cache from django.db.models import Q +from django.urls import reverse from django.utils.decorators import method_decorator from django.views.decorators.cache import cache_page -from django.conf import settings -from django.urls import reverse -from django.core.cache import cache - -from rest_framework.views import APIView from rest_framework.response import Response +from rest_framework.views import APIView from history.models import History diff --git a/manage.py b/manage.py index bac9edc4..d5b4a8c3 100644 --- a/manage.py +++ b/manage.py @@ -1,5 +1,6 @@ #!/usr/bin/env python -import os, sys +import os +import sys if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_evaluation.settings") diff --git a/package-lock.json b/package-lock.json index 5617bb46..2d622e0e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "evaluation_system_web", - "version": "2023.08.01", + "version": "2403.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "evaluation_system_web", - "version": "2023.08.01", + "version": "2403.0.0", "license": "ISC", "dependencies": { "date-fns": "^2.29", diff --git a/package.json b/package.json index b465d692..f021061b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "evaluation_system_web", - "version": "2023.09.06", + "version": "2403.0.0", "description": "React-bits of the freva-web interface. The react-parts of the web interface include the plugin-selection, the data-browser and the result-browser", "main": "index.js", "engines": { diff --git a/plugins/forms.py b/plugins/forms.py index 7ef3f426..453edcda 100644 --- a/plugins/forms.py +++ b/plugins/forms.py @@ -1,14 +1,16 @@ -from django import forms +from pathlib import Path + import django.contrib.auth as auth +import evaluation_system.api.parameters as parameters +from django import forms +from django.conf import settings from django.core import exceptions from django.forms.widgets import Input, TextInput from django.template import loader -import evaluation_system.api.parameters as parameters from evaluation_system.api import plugin_manager as pm -from pathlib import Path -from plugins.utils import ssh_call from evaluation_system.misc.utils import PrintableList -from django.conf import settings + +from plugins.utils import ssh_call class PluginNotFoundError(Exception): diff --git a/plugins/models.py b/plugins/models.py index 8e093048..f8495dcf 100644 --- a/plugins/models.py +++ b/plugins/models.py @@ -1 +1 @@ -from evaluation_system.model.plugins.models import Version, Parameter +from evaluation_system.model.plugins.models import Parameter, Version diff --git a/plugins/serializers.py b/plugins/serializers.py index 26f9106a..41ce5a9e 100644 --- a/plugins/serializers.py +++ b/plugins/serializers.py @@ -1,5 +1,5 @@ -from rest_framework import serializers from django.contrib.flatpages.models import FlatPage +from rest_framework import serializers class PluginSerializer(serializers.Serializer): diff --git a/plugins/urls.py b/plugins/urls.py index 2422d451..d78ea9a8 100644 --- a/plugins/urls.py +++ b/plugins/urls.py @@ -1,4 +1,6 @@ -from django.urls import re_path as url, include +from django.urls import include +from django.urls import re_path as url + import plugins.views urlpatterns = [ diff --git a/plugins/utils.py b/plugins/utils.py index 6dfbd4ce..f526c096 100644 --- a/plugins/utils.py +++ b/plugins/utils.py @@ -1,11 +1,12 @@ import base64 +import logging + import evaluation_system.api.plugin_manager as pm -from evaluation_system.misc import config -from django.views.decorators.debug import sensitive_variables -from django.http import Http404 -from django.conf import settings import paramiko -import logging +from django.conf import settings +from django.http import Http404 +from django.views.decorators.debug import sensitive_variables +from evaluation_system.misc import config def get_scheduler_hosts(user): diff --git a/plugins/views.py b/plugins/views.py index 815b761f..c73493c0 100644 --- a/plugins/views.py +++ b/plugins/views.py @@ -1,37 +1,31 @@ """ Views for the plugins application """ -from django.shortcuts import render, redirect -from django.http import HttpResponse -from django.http import JsonResponse -from django.contrib.auth.decorators import login_required -from django.conf import settings -from django.views.decorators.debug import ( - sensitive_variables, - sensitive_post_parameters, -) +import json +import logging +import os +import urllib from pathlib import Path import evaluation_system.api.plugin_manager as pm - -from evaluation_system.model.user import User +from django.conf import settings +from django.contrib.auth.decorators import login_required +from django.http import HttpResponse, JsonResponse +from django.shortcuts import redirect, render +from django.views.decorators.debug import sensitive_post_parameters, sensitive_variables from evaluation_system.misc import config -from django_evaluation.settings.local import HOME_DIRS_AVAILABLE +from evaluation_system.model.user import User + from base.exceptions import UserNotFoundError from base.LdapUser import LdapUser - +from django_evaluation.settings.local import HOME_DIRS_AVAILABLE +from history.models import Configuration, History +from plugins.forms import PluginForm, PluginWeb from plugins.utils import ( get_plugin_or_404, + get_scheduler_hosts, is_path_relative_to, ssh_call, - get_scheduler_hosts, ) -from plugins.forms import PluginForm, PluginWeb -from history.models import History, Configuration - -import logging -import urllib -import os -import json @login_required() diff --git a/plugins/views_api.py b/plugins/views_api.py index f8087e3f..2b114d50 100644 --- a/plugins/views_api.py +++ b/plugins/views_api.py @@ -1,17 +1,19 @@ -from rest_framework.views import APIView -from rest_framework.response import Response -from rest_framework.permissions import IsAuthenticated import os import evaluation_system.api.plugin_manager as pm -from evaluation_system.model.user import User +from django.conf import settings from evaluation_system.misc import config -from django_evaluation.ldaptools import get_ldap_object +from evaluation_system.model.user import User +from rest_framework.permissions import IsAuthenticated +from rest_framework.response import Response +from rest_framework.views import APIView + from base.exceptions import UserNotFoundError from base.LdapUser import LdapUser +from django_evaluation.ldaptools import get_ldap_object from plugins.utils import get_plugin_or_404, plugin_metadata_as_dict + from .serializers import PluginSerializer -from django.conf import settings class PluginsList(APIView): diff --git a/solr/admin.py b/solr/admin.py index b9408e17..995796f1 100644 --- a/solr/admin.py +++ b/solr/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin + from solr.models import UserCrawl diff --git a/solr/templatetags/custom_filters.py b/solr/templatetags/custom_filters.py index dc05da2e..2c736783 100644 --- a/solr/templatetags/custom_filters.py +++ b/solr/templatetags/custom_filters.py @@ -1,9 +1,8 @@ -from django import template +import urllib.parse +from django import template from django.utils.safestring import mark_safe -import urllib.parse - register = template.Library() diff --git a/solr/urls.py b/solr/urls.py index 4c735441..07489607 100644 --- a/solr/urls.py +++ b/solr/urls.py @@ -8,10 +8,8 @@ import os from django.urls import re_path as url -from django.urls import path -from django.conf import settings -from .views import databrowser -from .proxyviews import DataBrowserProxy + +import solr.views urlpatterns = [ url(r"^databrowser/$", databrowser, name="data_browser"), diff --git a/solr/views.py b/solr/views.py index f8dad0cb..41fd09c5 100644 --- a/solr/views.py +++ b/solr/views.py @@ -5,13 +5,15 @@ views for the solr application """ + +import json import logging -from django.shortcuts import render +from typing import Union + +from django.conf import settings from django.contrib.auth.decorators import login_required from django.http import JsonResponse -from django.conf import settings -from django.http import QueryDict -import requests +from django.shortcuts import render @login_required() diff --git a/solr/views_api.py b/solr/views_api.py index e8649383..57a56a8f 100644 --- a/solr/views_api.py +++ b/solr/views_api.py @@ -1,13 +1,13 @@ import logging -from rest_framework.decorators import api_view +from django.conf import settings from django.contrib.auth.decorators import login_required -from django.utils.safestring import mark_safe from django.http import JsonResponse -from django.conf import settings +from django.utils.safestring import mark_safe from paramiko import AuthenticationException +from rest_framework.decorators import api_view -from plugins.utils import ssh_call, get_scheduler_hosts +from plugins.utils import get_scheduler_hosts, ssh_call @api_view(["POST"]) diff --git a/tests/conftest.py b/tests/conftest.py index 98f21e4b..e7929fec 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,13 +1,14 @@ -from configparser import ConfigParser, ExtendedInterpolation import os -from pathlib import Path -import pytest -import mock import random import string import sys +from configparser import ConfigParser, ExtendedInterpolation +from pathlib import Path from tempfile import NamedTemporaryFile +import mock +import pytest + def get_config(): from evaluation_system.tests.mocks import TEST_EVAL diff --git a/tests/test_manage.py b/tests/test_manage.py index adcb7978..01dee369 100644 --- a/tests/test_manage.py +++ b/tests/test_manage.py @@ -1,5 +1,5 @@ import shlex -from subprocess import run, PIPE +from subprocess import PIPE, run def test_chek(eval_config): diff --git a/tests/website_unittest.py b/tests/website_unittest.py index c5b94a76..d0837c66 100644 --- a/tests/website_unittest.py +++ b/tests/website_unittest.py @@ -1,8 +1,9 @@ -import unittest import time +import unittest + from selenium import webdriver -from selenium.webdriver.common.keys import Keys from selenium.common.exceptions import NoSuchElementException +from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.select import Select