mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-23 06:30:04 +00:00
Resolve pylint warnings (#488)
* Suppress the import outside toplevel pylint rule -- I think we want to save memory * Resolve pylint warnings
This commit is contained in:
parent
fff0a748b3
commit
7818552ca9
@ -133,7 +133,8 @@ disable=print-statement,
|
||||
xreadlines-attribute,
|
||||
deprecated-sys-function,
|
||||
exception-escape,
|
||||
comprehension-escape
|
||||
comprehension-escape,
|
||||
import-outside-toplevel
|
||||
|
||||
# Enable the message, report, category or checker with the given id(s). You can
|
||||
# either give multiple identifier separated by comma (,) or put this option
|
||||
|
@ -239,7 +239,9 @@ def download_file_to_iso(url):
|
||||
return {"status": False, "msg": req_proc["msg"]}
|
||||
|
||||
iso_proc = run(
|
||||
["genisoimage", "-hfs", "-o", iso_filename, tmp_full_path], capture_output=True
|
||||
["genisoimage", "-hfs", "-o", iso_filename, tmp_full_path],
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
if iso_proc.returncode != 0:
|
||||
return {"status": False, "msg": iso_proc.stderr.decode("utf-8")}
|
||||
|
@ -40,12 +40,20 @@ def running_env():
|
||||
env is the various system information where this app is running
|
||||
"""
|
||||
ra_git_version = (
|
||||
subprocess.run(["git", "rev-parse", "HEAD"], capture_output=True)
|
||||
subprocess.run(
|
||||
["git", "rev-parse", "HEAD"],
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
.stdout.decode("utf-8")
|
||||
.strip()
|
||||
)
|
||||
pi_version = (
|
||||
subprocess.run(["uname", "-a"], capture_output=True)
|
||||
subprocess.run(
|
||||
["uname", "-a"],
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
.stdout.decode("utf-8")
|
||||
.strip()
|
||||
)
|
||||
@ -57,7 +65,11 @@ def running_proc(daemon):
|
||||
Takes (str) daemon
|
||||
Returns (int) proc, which is the number of processes currently running
|
||||
"""
|
||||
process = subprocess.run(["ps", "aux"], capture_output=True)
|
||||
process = subprocess.run(
|
||||
["ps", "aux"],
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
output = process.stdout.decode("utf-8")
|
||||
from re import findall
|
||||
proc = findall(daemon, output)
|
||||
@ -68,7 +80,11 @@ def is_bridge_setup():
|
||||
"""
|
||||
Returns (bool) True if the rascsi_bridge network interface exists
|
||||
"""
|
||||
process = subprocess.run(["brctl", "show"], capture_output=True)
|
||||
process = subprocess.run(
|
||||
["brctl", "show"],
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
output = process.stdout.decode("utf-8")
|
||||
if "rascsi_bridge" in output:
|
||||
return True
|
||||
@ -156,4 +172,4 @@ def auth_active():
|
||||
"status": True,
|
||||
"msg": "You must log in to use this function!",
|
||||
}
|
||||
return {"status": False, "msg": ""}
|
||||
return {"status": False, "msg": ""}
|
||||
|
@ -3,6 +3,7 @@ Module for sending and receiving data over a socket connection with the RaSCSI b
|
||||
"""
|
||||
|
||||
import logging
|
||||
from flask import abort
|
||||
|
||||
def send_pb_command(payload):
|
||||
"""
|
||||
@ -32,7 +33,6 @@ def send_pb_command(payload):
|
||||
logging.error(error_msg)
|
||||
|
||||
# After failing all attempts, throw a 404 error
|
||||
from flask import abort
|
||||
abort(404, "The RaSCSI Web Interface failed to connect to RaSCSI at " + str(host) + \
|
||||
":" + str(port) + " with error: " + error_msg + \
|
||||
". The RaSCSI service is not running or may have crashed.")
|
||||
@ -64,7 +64,6 @@ def send_over_socket(sock, payload):
|
||||
while bytes_recvd < response_length:
|
||||
chunk = sock.recv(min(response_length - bytes_recvd, 2048))
|
||||
if chunk == b'':
|
||||
from flask import abort
|
||||
logging.error(
|
||||
"Read an empty chunk from the socket. "
|
||||
"Socket connection has dropped unexpectedly. "
|
||||
@ -80,7 +79,6 @@ def send_over_socket(sock, payload):
|
||||
response_message = b''.join(chunks)
|
||||
return response_message
|
||||
|
||||
from flask import abort
|
||||
logging.error(
|
||||
"The response from RaSCSI did not contain a protobuf header. "
|
||||
"RaSCSI may have crashed."
|
||||
|
@ -401,9 +401,17 @@ def show_logs():
|
||||
|
||||
from subprocess import run
|
||||
if scope != "default":
|
||||
process = run(["journalctl", "-n", lines, "-u", scope], capture_output=True)
|
||||
process = run(
|
||||
["journalctl", "-n", lines, "-u", scope],
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
else:
|
||||
process = run(["journalctl", "-n", lines], capture_output=True)
|
||||
process = run(
|
||||
["journalctl", "-n", lines],
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
|
||||
if process.returncode == 0:
|
||||
headers = {"content-type": "text/plain"}
|
||||
@ -455,18 +463,18 @@ def daynaport_attach():
|
||||
"https://github.com/akuker/RASCSI/wiki/Dayna-Port-SCSI-Link")
|
||||
|
||||
if interface.startswith("wlan"):
|
||||
if not introspect_file("/etc/sysctl.conf", "^net\.ipv4\.ip_forward=1$"):
|
||||
if not introspect_file("/etc/sysctl.conf", r"^net\.ipv4\.ip_forward=1$"):
|
||||
flash("IPv4 forwarding is not enabled. " + error_msg, "error")
|
||||
return redirect(url_for("index"))
|
||||
if not Path("/etc/iptables/rules.v4").is_file():
|
||||
flash("NAT has not been configured. " + error_msg, "error")
|
||||
return redirect(url_for("index"))
|
||||
else:
|
||||
if not introspect_file("/etc/dhcpcd.conf", "^denyinterfaces " + interface + "$"):
|
||||
if not introspect_file("/etc/dhcpcd.conf", r"^denyinterfaces " + interface + r"$"):
|
||||
flash("The network bridge hasn't been configured. " + error_msg, "error")
|
||||
return redirect(url_for("index"))
|
||||
if not Path("/etc/network/interfaces.d/rascsi_bridge").is_file():
|
||||
flash(f"The network bridge hasn't been configured. " + error_msg, "error")
|
||||
flash("The network bridge hasn't been configured. " + error_msg, "error")
|
||||
return redirect(url_for("index"))
|
||||
|
||||
kwargs = {"device_type": "SCDP"}
|
||||
@ -976,10 +984,10 @@ if __name__ == "__main__":
|
||||
read_config(DEFAULT_CONFIG)
|
||||
|
||||
if len(argv) > 1:
|
||||
port = int(argv[1])
|
||||
PORT = int(argv[1])
|
||||
else:
|
||||
port = 8080
|
||||
PORT = 8080
|
||||
|
||||
import bjoern
|
||||
print("Serving rascsi-web...")
|
||||
bjoern.run(APP, "0.0.0.0", port)
|
||||
bjoern.run(APP, "0.0.0.0", PORT)
|
||||
|
Loading…
Reference in New Issue
Block a user