mirror of
https://github.com/akuker/RASCSI.git
synced 2025-01-11 09:29:53 +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,
|
xreadlines-attribute,
|
||||||
deprecated-sys-function,
|
deprecated-sys-function,
|
||||||
exception-escape,
|
exception-escape,
|
||||||
comprehension-escape
|
comprehension-escape,
|
||||||
|
import-outside-toplevel
|
||||||
|
|
||||||
# Enable the message, report, category or checker with the given id(s). You can
|
# 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
|
# 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"]}
|
return {"status": False, "msg": req_proc["msg"]}
|
||||||
|
|
||||||
iso_proc = run(
|
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:
|
if iso_proc.returncode != 0:
|
||||||
return {"status": False, "msg": iso_proc.stderr.decode("utf-8")}
|
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
|
env is the various system information where this app is running
|
||||||
"""
|
"""
|
||||||
ra_git_version = (
|
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")
|
.stdout.decode("utf-8")
|
||||||
.strip()
|
.strip()
|
||||||
)
|
)
|
||||||
pi_version = (
|
pi_version = (
|
||||||
subprocess.run(["uname", "-a"], capture_output=True)
|
subprocess.run(
|
||||||
|
["uname", "-a"],
|
||||||
|
capture_output=True,
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
.stdout.decode("utf-8")
|
.stdout.decode("utf-8")
|
||||||
.strip()
|
.strip()
|
||||||
)
|
)
|
||||||
@ -57,7 +65,11 @@ def running_proc(daemon):
|
|||||||
Takes (str) daemon
|
Takes (str) daemon
|
||||||
Returns (int) proc, which is the number of processes currently running
|
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")
|
output = process.stdout.decode("utf-8")
|
||||||
from re import findall
|
from re import findall
|
||||||
proc = findall(daemon, output)
|
proc = findall(daemon, output)
|
||||||
@ -68,7 +80,11 @@ def is_bridge_setup():
|
|||||||
"""
|
"""
|
||||||
Returns (bool) True if the rascsi_bridge network interface exists
|
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")
|
output = process.stdout.decode("utf-8")
|
||||||
if "rascsi_bridge" in output:
|
if "rascsi_bridge" in output:
|
||||||
return True
|
return True
|
||||||
|
@ -3,6 +3,7 @@ Module for sending and receiving data over a socket connection with the RaSCSI b
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
from flask import abort
|
||||||
|
|
||||||
def send_pb_command(payload):
|
def send_pb_command(payload):
|
||||||
"""
|
"""
|
||||||
@ -32,7 +33,6 @@ def send_pb_command(payload):
|
|||||||
logging.error(error_msg)
|
logging.error(error_msg)
|
||||||
|
|
||||||
# After failing all attempts, throw a 404 error
|
# 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) + \
|
abort(404, "The RaSCSI Web Interface failed to connect to RaSCSI at " + str(host) + \
|
||||||
":" + str(port) + " with error: " + error_msg + \
|
":" + str(port) + " with error: " + error_msg + \
|
||||||
". The RaSCSI service is not running or may have crashed.")
|
". 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:
|
while bytes_recvd < response_length:
|
||||||
chunk = sock.recv(min(response_length - bytes_recvd, 2048))
|
chunk = sock.recv(min(response_length - bytes_recvd, 2048))
|
||||||
if chunk == b'':
|
if chunk == b'':
|
||||||
from flask import abort
|
|
||||||
logging.error(
|
logging.error(
|
||||||
"Read an empty chunk from the socket. "
|
"Read an empty chunk from the socket. "
|
||||||
"Socket connection has dropped unexpectedly. "
|
"Socket connection has dropped unexpectedly. "
|
||||||
@ -80,7 +79,6 @@ def send_over_socket(sock, payload):
|
|||||||
response_message = b''.join(chunks)
|
response_message = b''.join(chunks)
|
||||||
return response_message
|
return response_message
|
||||||
|
|
||||||
from flask import abort
|
|
||||||
logging.error(
|
logging.error(
|
||||||
"The response from RaSCSI did not contain a protobuf header. "
|
"The response from RaSCSI did not contain a protobuf header. "
|
||||||
"RaSCSI may have crashed."
|
"RaSCSI may have crashed."
|
||||||
|
@ -401,9 +401,17 @@ def show_logs():
|
|||||||
|
|
||||||
from subprocess import run
|
from subprocess import run
|
||||||
if scope != "default":
|
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:
|
else:
|
||||||
process = run(["journalctl", "-n", lines], capture_output=True)
|
process = run(
|
||||||
|
["journalctl", "-n", lines],
|
||||||
|
capture_output=True,
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
|
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
headers = {"content-type": "text/plain"}
|
headers = {"content-type": "text/plain"}
|
||||||
@ -455,18 +463,18 @@ def daynaport_attach():
|
|||||||
"https://github.com/akuker/RASCSI/wiki/Dayna-Port-SCSI-Link")
|
"https://github.com/akuker/RASCSI/wiki/Dayna-Port-SCSI-Link")
|
||||||
|
|
||||||
if interface.startswith("wlan"):
|
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")
|
flash("IPv4 forwarding is not enabled. " + error_msg, "error")
|
||||||
return redirect(url_for("index"))
|
return redirect(url_for("index"))
|
||||||
if not Path("/etc/iptables/rules.v4").is_file():
|
if not Path("/etc/iptables/rules.v4").is_file():
|
||||||
flash("NAT has not been configured. " + error_msg, "error")
|
flash("NAT has not been configured. " + error_msg, "error")
|
||||||
return redirect(url_for("index"))
|
return redirect(url_for("index"))
|
||||||
else:
|
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")
|
flash("The network bridge hasn't been configured. " + error_msg, "error")
|
||||||
return redirect(url_for("index"))
|
return redirect(url_for("index"))
|
||||||
if not Path("/etc/network/interfaces.d/rascsi_bridge").is_file():
|
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"))
|
return redirect(url_for("index"))
|
||||||
|
|
||||||
kwargs = {"device_type": "SCDP"}
|
kwargs = {"device_type": "SCDP"}
|
||||||
@ -976,10 +984,10 @@ if __name__ == "__main__":
|
|||||||
read_config(DEFAULT_CONFIG)
|
read_config(DEFAULT_CONFIG)
|
||||||
|
|
||||||
if len(argv) > 1:
|
if len(argv) > 1:
|
||||||
port = int(argv[1])
|
PORT = int(argv[1])
|
||||||
else:
|
else:
|
||||||
port = 8080
|
PORT = 8080
|
||||||
|
|
||||||
import bjoern
|
import bjoern
|
||||||
print("Serving rascsi-web...")
|
print("Serving rascsi-web...")
|
||||||
bjoern.run(APP, "0.0.0.0", port)
|
bjoern.run(APP, "0.0.0.0", PORT)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user