mirror of
https://github.com/akuker/RASCSI.git
synced 2024-11-23 08:31:05 +00:00
Indicator of a running macproxy daemon in the webapp (#436)
* Support for downloading properties files * Show extra message when unzipping properties file * Add logic to unzip method * Move unzipped properties into CFG_DIR * Better status message * Cleanup * Generic process introspection method * Show macproxy status in the webapp
This commit is contained in:
parent
08e7531bb6
commit
c8b6ac409b
@ -51,15 +51,16 @@ def running_env():
|
||||
return {"git": ra_git_version, "env": pi_version}
|
||||
|
||||
|
||||
def running_netatalk():
|
||||
def running_proc(daemon):
|
||||
"""
|
||||
Returns (int) afpd, which is the number of afpd processes currently running
|
||||
Takes (str) daemon
|
||||
Returns (int) proc, which is the number of processes currently running
|
||||
"""
|
||||
process = subprocess.run(["ps", "aux"], capture_output=True)
|
||||
output = process.stdout.decode("utf-8")
|
||||
from re import findall
|
||||
afpd = findall("afpd", output)
|
||||
return len(afpd)
|
||||
proc = findall(daemon, output)
|
||||
return len(proc)
|
||||
|
||||
|
||||
def is_bridge_setup():
|
||||
@ -82,6 +83,24 @@ def disk_space():
|
||||
total, used, free = disk_usage(__file__)
|
||||
return {"total": total, "used": used, "free": free}
|
||||
|
||||
|
||||
def get_ip_address():
|
||||
"""
|
||||
Use a mock socket connection to identify the Pi's IP address
|
||||
"""
|
||||
from socket import socket, AF_INET, SOCK_DGRAM
|
||||
sock = socket(AF_INET, SOCK_DGRAM)
|
||||
try:
|
||||
# mock ip address; doesn't have to be reachable
|
||||
sock.connect(('10.255.255.255', 1))
|
||||
ip_addr = sock.getsockname()[0]
|
||||
except Exception:
|
||||
ip_addr = '127.0.0.1'
|
||||
finally:
|
||||
sock.close()
|
||||
return ip_addr
|
||||
|
||||
|
||||
def introspect_file(file_path, re_term):
|
||||
"""
|
||||
Takes a (str) file_path and (str) re_term in regex format
|
||||
@ -96,4 +115,4 @@ def introspect_file(file_path, re_term):
|
||||
for line in ifile:
|
||||
if match(re_term, line):
|
||||
return True
|
||||
return False
|
||||
return False
|
@ -317,6 +317,11 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{% if macproxy_configured %}
|
||||
<p><small>macproxy is running at {{ ip_addr }} port 5000</small></p>
|
||||
{% else %}
|
||||
<p><small>Install <a href="https://github.com/akuker/RASCSI/wiki/Vintage-Web-Proxy#macproxy">macproxy</a> to browse the Web with your vintage browser.</small></p>
|
||||
{% endif %}
|
||||
|
||||
<hr/>
|
||||
<details>
|
||||
|
@ -36,9 +36,10 @@ from pi_cmds import (
|
||||
reboot_pi,
|
||||
running_env,
|
||||
systemd_service,
|
||||
running_netatalk,
|
||||
running_proc,
|
||||
is_bridge_setup,
|
||||
disk_space,
|
||||
get_ip_address,
|
||||
introspect_file,
|
||||
)
|
||||
from ractl_cmds import (
|
||||
@ -112,7 +113,9 @@ def index():
|
||||
return render_template(
|
||||
"index.html",
|
||||
bridge_configured=is_bridge_setup(),
|
||||
netatalk_configured=running_netatalk(),
|
||||
netatalk_configured=running_proc("afpd"),
|
||||
macproxy_configured=running_proc("macproxy"),
|
||||
ip_addr=get_ip_address(),
|
||||
devices=formatted_devices,
|
||||
files=sorted_image_files,
|
||||
config_files=sorted_config_files,
|
||||
|
Loading…
Reference in New Issue
Block a user