• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Open-MSS / MSS / 10653123390

01 Sep 2024 10:12AM UTC coverage: 69.967% (-0.07%) from 70.037%
10653123390

Pull #2495

github

web-flow
Merge d3a10b8f0 into 0b95679f6
Pull Request #2495: remove the conda/mamba based updater.

24 of 41 new or added lines in 5 files covered. (58.54%)

92 existing lines in 6 files now uncovered.

13843 of 19785 relevant lines covered (69.97%)

0.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.5
/mslib/mscolab/app/__init__.py
1
# -*- coding: utf-8 -*-
2
"""
3

4
    mslib.mscolab.app
5
    ~~~~~~~~~~~~~~~~~
6

7
    app module of mscolab
8

9
    This file is part of MSS.
10

11
    :copyright: Copyright 2016-2024 by the MSS team, see AUTHORS.
12
    :license: APACHE-2.0, see LICENSE for details.
13

14
    Licensed under the Apache License, Version 2.0 (the "License");
15
    you may not use this file except in compliance with the License.
16
    You may obtain a copy of the License at
17

18
       http://www.apache.org/licenses/LICENSE-2.0
19

20
    Unless required by applicable law or agreed to in writing, software
21
    distributed under the License is distributed on an "AS IS" BASIS,
22
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
    See the License for the specific language governing permissions and
24
    limitations under the License.
25
"""
26

27
import os
1✔
28
import logging
1✔
29
import sqlalchemy
1✔
30

31
from flask_migrate import Migrate
1✔
32

33
import mslib
1✔
34

35
from flask import Flask, url_for
1✔
36
from mslib.mscolab.conf import mscolab_settings
1✔
37
from flask_sqlalchemy import SQLAlchemy
1✔
38
from mslib.utils import prefix_route, release_info
1✔
39

40
message, update = release_info.check_for_new_release()
1✔
41
if update:
1✔
NEW
42
    logging.warning(message)
×
43

44

45
DOCS_SERVER_PATH = os.path.dirname(os.path.abspath(mslib.__file__))
1✔
46
# This can be used to set a location by SCRIPT_NAME for testing. e.g. export SCRIPT_NAME=/demo/
47
SCRIPT_NAME = os.environ.get('SCRIPT_NAME', '/')
1✔
48

49
# in memory database for testing
50
# app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'
51
APP = Flask(__name__, template_folder=os.path.join(DOCS_SERVER_PATH, 'static', 'templates'))
1✔
52
APP.config.from_object(__name__)
1✔
53
APP.route = prefix_route(APP.route, SCRIPT_NAME)
1✔
54

55
APP.config['MSCOLAB_DATA_DIR'] = mscolab_settings.MSCOLAB_DATA_DIR
1✔
56
APP.config['SQLALCHEMY_DATABASE_URI'] = mscolab_settings.SQLALCHEMY_DB_URI
1✔
57
APP.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
1✔
58
APP.config['SQLALCHEMY_ECHO'] = mscolab_settings.SQLALCHEMY_ECHO
1✔
59
APP.config['UPLOAD_FOLDER'] = mscolab_settings.UPLOAD_FOLDER
1✔
60
APP.config['MAX_CONTENT_LENGTH'] = mscolab_settings.MAX_UPLOAD_SIZE
1✔
61
APP.config['SECRET_KEY'] = mscolab_settings.SECRET_KEY
1✔
62
APP.config['SECURITY_PASSWORD_SALT'] = getattr(mscolab_settings, "SECURITY_PASSWORD_SALT", None)
1✔
63
APP.config['MAIL_DEFAULT_SENDER'] = getattr(mscolab_settings, "MAIL_DEFAULT_SENDER", None)
1✔
64
APP.config['MAIL_SERVER'] = getattr(mscolab_settings, "MAIL_SERVER", None)
1✔
65
APP.config['MAIL_PORT'] = getattr(mscolab_settings, "MAIL_PORT", None)
1✔
66
APP.config['MAIL_USERNAME'] = getattr(mscolab_settings, "MAIL_USERNAME", None)
1✔
67
APP.config['MAIL_PASSWORD'] = getattr(mscolab_settings, "MAIL_PASSWORD", None)
1✔
68
APP.config['MAIL_USE_TLS'] = getattr(mscolab_settings, "MAIL_USE_TLS", None)
1✔
69
APP.config['MAIL_USE_SSL'] = getattr(mscolab_settings, "MAIL_USE_SSL", None)
1✔
70

71
db = SQLAlchemy(
1✔
72
    metadata=sqlalchemy.MetaData(
73
        naming_convention={
74
            # For reference: https://alembic.sqlalchemy.org/en/latest/naming.html#the-importance-of-naming-constraints
75
            "ix": "ix_%(column_0_label)s",
76
            "uq": "uq_%(table_name)s_%(column_0_name)s",
77
            "ck": "ck_%(table_name)s_`%(constraint_name)s`",
78
            "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
79
            "pk": "pk_%(table_name)s",
80
        },
81
    ),
82
)
83
db.init_app(APP)
1✔
84
import mslib.mscolab.models
1✔
85

86
migrate = Migrate(render_as_batch=True, user_module_prefix="cu.")
1✔
87
migrate.init_app(APP, db)
1✔
88

89

90
def get_topmenu():
1✔
91
    menu = [
1✔
92
        (url_for('index'), 'Mission Support System',
93
         ((url_for('about'), 'About'),
94
          (url_for('install'), 'Install'),
95
          (url_for('help'), 'Help'),
96
          )),
97
    ]
98
    return menu
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc