Skip to content

Commit

Permalink
Merge branch 'develop' into py311
Browse files Browse the repository at this point in the history
  • Loading branch information
ReimarBauer authored Oct 19, 2023
2 parents 865259c + f72546b commit e562a18
Show file tree
Hide file tree
Showing 63 changed files with 794 additions and 468 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python-flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: 3.8
python-version: "3.10"
- name: Lint with flake8
run: |
python -m pip install --upgrade pip
Expand Down
3 changes: 3 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ build:
tools:
python: "mambaforge-4.10"

sphinx:
configuration: docs/conf.py

conda:
environment: docs/environment.yml
17 changes: 17 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
Changelog
=========

Version 8.3.1
~~~~~~~~~~~~~

Bug fix release:

All changes:
https://github.com/Open-MSS/MSS/milestone/99?closed=1

Version 8.3.0
~~~~~~~~~~~~~

Bug fix release and minor enhacements:
We improved the KML docking widget feature

All changes:
https://github.com/Open-MSS/MSS/milestone/98

Version 8.2.0
~~~~~~~~~~~~~

Expand Down
10 changes: 6 additions & 4 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ def pytest_generate_tests(metafunc):
# mscolab data directory
MSCOLAB_DATA_DIR = fs.path.join(DATA_DIR, 'filedata')
# In the unit days when Operations get archived because not used
ARCHIVE_THRESHOLD = 30
# To enable logging set to True or pass a logger object to use.
SOCKETIO_LOGGER = True
Expand Down Expand Up @@ -218,9 +221,8 @@ def _load_module(module_name, path):

'''
@pytest.fixture(autouse=True)
def close_open_windows():
"""
Closes all windows after every test
def fail_if_open_message_boxes_left():
"""Fail a test if there are any Qt message boxes left open at the end
"""
# Mock every MessageBox widget in the test suite to avoid unwanted freezes on unhandled error popups etc.
with mock.patch("PyQt5.QtWidgets.QMessageBox.question") as q, \
Expand All @@ -231,7 +233,7 @@ def close_open_windows():
if any(box.call_count > 0 for box in [q, i, c, w]):
summary = "\n".join([f"PyQt5.QtWidgets.QMessageBox.{box()._extract_mock_name()}: {box.mock_calls[:-1]}"
for box in [q, i, c, w] if box.call_count > 0])
warnings.warn(f"An unhandled message box popped up during your test!\n{summary}")
pytest.fail(f"An unhandled message box popped up during your test!\n{summary}")
# Try to close all remaining widgets after each test
Expand Down
12 changes: 4 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def get_tutorial_images():
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = []
extensions = ['sphinx_rtd_theme']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down Expand Up @@ -217,23 +217,19 @@ def get_tutorial_images():

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#html_theme = 'sphinx_rtd_theme'
html_theme = 'sphinx_rtd_theme'

if not on_rtd: # only import and set the theme if we're building docs locally
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
html_style = 'css/mss.css'
else:
htmls_static_path = ['_static']
html_css_files = ['mss.css']
html_context = {
'display_github': False, # Add 'Edit on Bitbucket' link instead of 'View page source'
'last_updated': True,
'commit': False,
'css_files': [
'https://media.readthedocs.org/css/sphinx_rtd_theme.css',
'https://media.readthedocs.org/css/readthedocs-doc-embed.css',
'_static/css/mss.css',
],
}

# Theme options are theme-specific and customize the look and feel of a theme
Expand Down
20 changes: 16 additions & 4 deletions docs/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -449,15 +449,27 @@ As developer you should copy this directory and adjust the source path, build nu
using a local meta.yaml recipe::

$ cd yourlocalbuild
$ conda build .
$ conda create -n mssbuildtest mamba
$ conda activate mssbuildtest
$ mamba install --use-local mss
$ mamba build .
$ mamba create -n mssbuildtest
$ mamba activate mssbuildtest
$ mamba install -c local mss


Take care on removing alpha builds, or increase the build number for a new version.


Alternative local build by boa
------------------------------

`boa <https://boa-build.readthedocs.io/en/latest/>`_ is a new faster option to build conda packages.
We need first to convert the existing description to a recipe.yaml::

$ cd yourlocalbuild
$ boa convert meta.yaml > recipe.yaml
$ boa build .
$ mamba install -c local mss


Creating a new release
----------------------

Expand Down
8 changes: 5 additions & 3 deletions docs/publications.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ Acknowledgement

Please add the following acknowledgement and cite to your publications:


The authors gratefully acknowledge the use of the MSS flight planning
software (Rautenhaus, 2012; MSS development was partially funded by
the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation)
project no. UN 311/3-1)“.
software (Bauer et al, 2022, Rautenhaus et al, 2012;
MSS development was partially funded by the Deutsche Forschungsgemeinschaft
(DFG, German Research Foundation) project no. UN 311/3-1
and project no. SPP 1294 423229456)

Thank you very much.
3 changes: 3 additions & 0 deletions docs/samples/config/mscolab/mscolab_settings.py.sample
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"""
import os

# In the unit days when Operations get archived because not used
ARCHIVE_THRESHOLD = 30

# To enable logging set to True or pass a logger object to use.
SOCKETIO_LOGGER = False

Expand Down
3 changes: 2 additions & 1 deletion localbuild/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ requirements:
- setuptools
- pip
- menuinst # [win]
- future
run:
- python
- defusedxml
Expand Down Expand Up @@ -64,7 +65,7 @@ requirements:
- flask-httpauth
- flask-mail
- flask-migrate
- werkzeug >=2.2.3
- werkzeug >=2.2.3, <3.0.0
- flask-socketio >=5.1.0
- flask-sqlalchemy >=3.0.0
- flask-cors
Expand Down
34 changes: 29 additions & 5 deletions mslib/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,26 @@ def _xstatic(name):
return None


def create_app(name=""):
def file_exists(filepath=None):
try:
return os.path.isfile(filepath)
except TypeError:
return False


def create_app(name="", imprint=None, gdpr=None):
imprint_file = imprint
gdpr_file = gdpr

if "mscolab.server" in name:
from mslib.mscolab.app import APP
else:
from mslib.mswms.app import APP

APP.jinja_env.globals.update(file_exists=file_exists)
APP.jinja_env.globals["imprint"] = imprint_file
APP.jinja_env.globals["gdpr"] = gdpr_file

@APP.route('/xstatic/<name>/', defaults=dict(filename=''))
@APP.route('/xstatic/<name>/<path:filename>')
def files(name, filename):
Expand Down Expand Up @@ -160,7 +174,7 @@ def plots():
"For further info on how to generate it, run the " \
"<b>gallery --help</b> command line parameter of mswms.<br>" \
"An example of the gallery can be seen " \
"<a href=\"https://mss.readthedocs.io/en/latest/gallery/index.html\">here</a>"
"<a href=\"https://mss.readthedocs.io/en/stable/gallery/index.html\">here</a>"
return render_template("/content.html", act="plots", content=content)

@APP.route("/mss/code/<path:filename>")
Expand Down Expand Up @@ -190,9 +204,19 @@ def help():

@APP.route("/mss/imprint")
def imprint():
_file = os.path.join(DOCS_SERVER_PATH, 'static', 'docs', 'imprint.md')
content = get_content(_file)
return render_template("/content.html", act="imprint", content=content)
if file_exists(imprint_file):
content = get_content(imprint_file)
return render_template("/content.html", act="imprint", content=content)
else:
return ""

@APP.route("/mss/gpdr")
def gdpr():
if file_exists(gdpr_file):
content = get_content(gdpr_file)
return render_template("/content.html", act="gdpr", content=content)
else:
return ""

@APP.route('/mss/favicon.ico')
def favicons():
Expand Down
7 changes: 7 additions & 0 deletions mslib/mscolab/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@
"""

import os

from flask_migrate import Migrate

import mslib

from flask import Flask
from mslib.mscolab.conf import mscolab_settings
from flask_sqlalchemy import SQLAlchemy
from mslib.mswms.gallery_builder import STATIC_LOCATION
from mslib.utils import prefix_route

Expand Down Expand Up @@ -58,3 +62,6 @@
APP.config['MAIL_PASSWORD'] = getattr(mscolab_settings, "MAIL_PASSWORD", None)
APP.config['MAIL_USE_TLS'] = getattr(mscolab_settings, "MAIL_USE_TLS", None)
APP.config['MAIL_USE_SSL'] = getattr(mscolab_settings, "MAIL_USE_SSL", None)

db = SQLAlchemy(APP)
migrate = Migrate(APP, db, render_as_batch=True)
24 changes: 24 additions & 0 deletions mslib/mscolab/chat_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
limitations under the License.
"""
import datetime
import os
import time

import fs
from werkzeug.utils import secure_filename

from mslib.mscolab.conf import mscolab_settings
from mslib.mscolab.models import db, Message, MessageType
Expand Down Expand Up @@ -93,3 +96,24 @@ def delete_message(self, message_id):
upload_dir.remove(fs.path.join(str(message.op_id), file_name))
db.session.delete(message)
db.session.commit()

def add_attachment(self, op_id, upload_folder, file, file_token):
with fs.open_fs('/') as home_fs:
file_dir = fs.path.join(upload_folder, str(op_id))
if '\\' not in file_dir:
if not home_fs.exists(file_dir):
home_fs.makedirs(file_dir)
else:
file_dir = file_dir.replace('\\', '/')
if not os.path.exists(file_dir):
os.makedirs(file_dir)
file_name, file_ext = file.filename.rsplit('.', 1)
file_name = f'{file_name}-{time.strftime("%Y%m%dT%H%M%S")}-{file_token}.{file_ext}'
file_name = secure_filename(file_name)
file_path = fs.path.join(file_dir, file_name)
file.save(file_path)
static_dir = fs.path.basename(upload_folder)
static_dir = static_dir.replace('\\', '/')
static_file_path = os.path.join(static_dir, str(op_id), file_name)
if os.path.exists(file_path):
return static_file_path
7 changes: 7 additions & 0 deletions mslib/mscolab/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class default_mscolab_settings:
# expire token in seconds
# EXPIRATION = 86400

# In the unit days when Operations get archived because not used
ARCHIVE_THRESHOLD = 30

# To enable logging set to True or pass a logger object to use.
SOCKETIO_LOGGER = False

Expand Down Expand Up @@ -99,6 +102,10 @@ class default_mscolab_settings:

# mail accounts
# MAIL_DEFAULT_SENDER = 'MSS@localhost'
# filepath to md file with imprint
IMPRINT = None
# filepath to md file with gdpr
GDPR = None


mscolab_settings = default_mscolab_settings()
Expand Down
Loading

0 comments on commit e562a18

Please sign in to comment.