Merge pull request #819 from nucleogenic/docker-dev-environment

Docker environment for development and testing
This commit is contained in:
nucleogenic
2022-09-08 12:57:48 +01:00
committed by GitHub
17 changed files with 439 additions and 38 deletions
+2 -1
View File
@@ -10,6 +10,7 @@ import pathlib
from tempfile import TemporaryDirectory
from re import escape, match
from json import loads, JSONDecodeError
from shutil import move
from util.run import run
FORK_OUTPUT_TYPE_VISIBLE = "visible"
@@ -140,7 +141,7 @@ def extract_archive(file_path, **kwargs):
# The parent dir may not be specified as a member, so ensure it exists
target_path.parent.mkdir(parents=True, exist_ok=True)
logging.debug("Moving temp file: %s -> %s", source_path, target_path)
source_path.rename(target_path)
move(source_path, target_path)
moved.append(member)
return {
+1 -1
View File
@@ -4,7 +4,7 @@ Flask==2.0.1
itsdangerous==2.0.1
Jinja2==3.0.1
MarkupSafe==2.0.1
protobuf==3.17.3
protobuf==3.20.1
requests==2.26.0
simplepam==0.1.5
flask_babel==2.0.0
+16 -2
View File
@@ -1048,6 +1048,11 @@ if __name__ == "__main__":
help="Log level for Web UI. Default: warning",
choices=["debug", "info", "warning", "error", "critical"],
)
parser.add_argument(
"--dev-mode",
action="store_true",
help="Run in development mode"
)
arguments = parser.parse_args()
APP.config["TOKEN"] = arguments.password
@@ -1064,5 +1069,14 @@ if __name__ == "__main__":
format="%(asctime)s %(levelname)s %(filename)s:%(lineno)s %(message)s",
level=arguments.log_level.upper())
print("Serving rascsi-web...")
bjoern.run(APP, "0.0.0.0", arguments.port)
if arguments.dev_mode:
print("Running rascsi-web in development mode ...")
APP.debug = True
from werkzeug.debug import DebuggedApplication
try:
bjoern.run(DebuggedApplication(APP, evalex=False), "0.0.0.0", arguments.port)
except KeyboardInterrupt:
pass
else:
print("Serving rascsi-web...")
bjoern.run(APP, "0.0.0.0", arguments.port)
+10 -1
View File
@@ -110,6 +110,9 @@ while [ "$1" != "" ]; do
-l | --log-level)
ARG_LOG_LEVEL="--log-level $VALUE"
;;
-d | --dev-mode)
ARG_DEV_MODE="--dev-mode"
;;
*)
echo "ERROR: unknown parameter \"$PARAM\""
exit 1
@@ -122,4 +125,10 @@ PYTHON_COMMON_PATH=$(dirname $PWD)/common/src
echo "Starting web server for RaSCSI Web Interface..."
export PYTHONPATH=$PWD/src:${PYTHON_COMMON_PATH}
cd src
python3 web.py ${ARG_PORT} ${ARG_PASSWORD} ${ARG_RASCSI_HOST} ${ARG_RASCSI_PORT} ${ARG_LOG_LEVEL}
if [[ $ARG_DEV_MODE ]]; then
watchmedo auto-restart --directory=../../ --pattern=*.py --recursive -- \
python3 web.py ${ARG_PORT} ${ARG_PASSWORD} ${ARG_RASCSI_HOST} ${ARG_RASCSI_PORT} ${ARG_LOG_LEVEL} ${ARG_DEV_MODE}
else
python3 web.py ${ARG_PORT} ${ARG_PASSWORD} ${ARG_RASCSI_HOST} ${ARG_RASCSI_PORT} ${ARG_LOG_LEVEL} ${ARG_DEV_MODE}
fi