mirror of https://github.com/akuker/RASCSI.git
Web UI: Warn when working dirs are missing
This commit is contained in:
parent
342ab56735
commit
66545e2643
|
@ -24,6 +24,7 @@
|
|||
</ul>
|
||||
</details>
|
||||
|
||||
{% if env["cfg_dir_exists"] %}
|
||||
<p>
|
||||
<form action="/config/action" method="post" id="config-actions">
|
||||
<label for="config_load_name">{{ _("File Name:") }}</label>
|
||||
|
@ -54,6 +55,13 @@
|
|||
<input type="submit" value="{{ _("Save") }}">
|
||||
</form>
|
||||
</p>
|
||||
{% else %}
|
||||
|
||||
<div class="notice">
|
||||
{{ _("Please create the PiSCSI configuration dir to use configurations:")}} {{ CFG_DIR }}
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
|
||||
<table id="attached-devices" border="black" cellpadding="3" summary="List of attached devices">
|
||||
<tbody>
|
||||
|
@ -342,12 +350,8 @@
|
|||
</ul>
|
||||
</details>
|
||||
|
||||
{% if not files|length: %}
|
||||
<div class="notice">
|
||||
{{ _("The images directory is currently empty.") }}
|
||||
</div>
|
||||
{% else %}
|
||||
|
||||
{% if not env["image_dir_exists"] %}
|
||||
{% if files|length %}
|
||||
<div>
|
||||
{% for subdir, group in formatted_image_files.items() %}
|
||||
|
||||
|
@ -502,10 +506,24 @@
|
|||
</details>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
|
||||
<div class="notice">
|
||||
{{ _("The images directory is currently empty.") }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<p><small>{{ _("%(disk_space)s MiB disk space remaining for images", disk_space=env["free_disk_space"]) }}</small></p>
|
||||
</section>
|
||||
|
||||
{% else %}
|
||||
|
||||
<div class="notice">
|
||||
{{ _("Please create the PiSCSI images dir to work with disk images:")}} {{ env["image_dir"] }}
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
|
||||
<hr/>
|
||||
|
||||
<section id="download-url">
|
||||
|
|
|
@ -46,7 +46,6 @@ from return_code_mapper import ReturnCodeMapper
|
|||
from socket_cmds_flask import SocketCmdsFlask
|
||||
|
||||
from web_utils import (
|
||||
working_dirs_exist,
|
||||
sort_and_format_devices,
|
||||
get_valid_scsi_ids,
|
||||
map_device_types_and_names,
|
||||
|
@ -125,6 +124,8 @@ def get_env_info():
|
|||
"image_dir": server_info["image_dir"],
|
||||
"image_root_dir": Path(server_info["image_dir"]).name,
|
||||
"shared_root_dir": Path(FILE_SERVER_DIR).name,
|
||||
"image_dir_exists": Path(server_info["image_dir"]).exists(),
|
||||
"cfg_dir_exists": Path(CFG_DIR).exists(),
|
||||
"hd_suffixes": tuple(server_info["schd"]),
|
||||
"cd_suffixes": tuple(server_info["sccd"]),
|
||||
"rm_suffixes": tuple(server_info["scrm"]),
|
||||
|
@ -220,7 +221,6 @@ def index():
|
|||
Sets up data structures for and renders the index page
|
||||
"""
|
||||
server_info = piscsi_cmd.get_server_info()
|
||||
working_dirs_exist((server_info["image_dir"], CFG_DIR))
|
||||
|
||||
devices = piscsi_cmd.list_devices()
|
||||
device_types = map_device_types_and_names(piscsi_cmd.get_device_types()["device_types"])
|
||||
|
@ -306,7 +306,6 @@ def drive_list():
|
|||
Sets up the data structures and kicks off the rendering of the drive list page
|
||||
"""
|
||||
server_info = piscsi_cmd.get_server_info()
|
||||
working_dirs_exist((server_info["image_dir"], CFG_DIR))
|
||||
|
||||
return response(
|
||||
template="drives.html",
|
||||
|
@ -343,7 +342,6 @@ def upload_page():
|
|||
Sets up the data structures and kicks off the rendering of the file uploading page
|
||||
"""
|
||||
server_info = piscsi_cmd.get_server_info()
|
||||
working_dirs_exist((server_info["image_dir"], CFG_DIR))
|
||||
|
||||
return response(
|
||||
template="upload.html",
|
||||
|
@ -545,7 +543,6 @@ def show_diskinfo():
|
|||
if not safe_path["status"]:
|
||||
return response(error=True, message=safe_path["msg"])
|
||||
server_info = piscsi_cmd.get_server_info()
|
||||
working_dirs_exist((server_info["image_dir"], CFG_DIR))
|
||||
returncode, diskinfo = sys_cmd.get_diskinfo(Path(server_info["image_dir"]) / file_name)
|
||||
if returncode == 0:
|
||||
return response(
|
||||
|
|
|
@ -8,26 +8,13 @@ from pathlib import Path
|
|||
from ua_parser import user_agent_parser
|
||||
from re import findall
|
||||
|
||||
from flask import request, abort
|
||||
from flask import request
|
||||
from flask_babel import _
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
from piscsi.sys_cmds import SysCmds
|
||||
|
||||
|
||||
def working_dirs_exist(working_dirs):
|
||||
"""
|
||||
Method for validating that working dirs exist.
|
||||
Takes (tuple) of (str) working_dirs with paths to required dirs.
|
||||
"""
|
||||
for dir_path in working_dirs:
|
||||
if not Path(dir_path).exists():
|
||||
abort(
|
||||
503,
|
||||
_(f"Please create directory: {dir_path}"),
|
||||
)
|
||||
|
||||
|
||||
def get_valid_scsi_ids(devices, reserved_ids):
|
||||
"""
|
||||
Takes a list of (dict)s devices, and list of (int)s reserved_ids.
|
||||
|
|
Loading…
Reference in New Issue