mirror of
https://github.com/akuker/RASCSI.git
synced 2024-11-27 04:49:18 +00:00
Merge pull request #400 from akuker/rdmark_oled_ip
Show ip instead of version on the OLED screen
This commit is contained in:
commit
231f20daff
@ -185,20 +185,18 @@ def device_list():
|
|||||||
|
|
||||||
return device_list
|
return device_list
|
||||||
|
|
||||||
def rascsi_version():
|
def get_ip_and_host():
|
||||||
"""
|
host = socket.gethostname()
|
||||||
Sends a VERSION_INFO command to the server.
|
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
Returns a str containing the version info.
|
try:
|
||||||
"""
|
# mock ip address; doesn't have to be reachable
|
||||||
command = proto.PbCommand()
|
s.connect(('10.255.255.255', 1))
|
||||||
command.operation = proto.PbOperation.VERSION_INFO
|
ip = s.getsockname()[0]
|
||||||
data = send_pb_command(command.SerializeToString())
|
except Exception:
|
||||||
result = proto.PbResult()
|
ip = '127.0.0.1'
|
||||||
result.ParseFromString(data)
|
finally:
|
||||||
version = str(result.version_info.major_version) + "." +\
|
s.close()
|
||||||
str(result.version_info.minor_version) + "." +\
|
return ip, host
|
||||||
str(result.version_info.patch_version)
|
|
||||||
return version
|
|
||||||
|
|
||||||
def send_pb_command(payload):
|
def send_pb_command(payload):
|
||||||
"""
|
"""
|
||||||
@ -289,7 +287,7 @@ def formatted_output():
|
|||||||
else:
|
else:
|
||||||
output.append("No image mounted!")
|
output.append("No image mounted!")
|
||||||
|
|
||||||
output.append(f"~~RaSCSI v{version}~~")
|
output.append(f"IP {ip} - {host}")
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def start_splash():
|
def start_splash():
|
||||||
@ -310,7 +308,7 @@ cwd = getcwd()
|
|||||||
|
|
||||||
start_splash()
|
start_splash()
|
||||||
|
|
||||||
version = rascsi_version()
|
ip, host = get_ip_and_host()
|
||||||
|
|
||||||
with GracefulInterruptHandler() as h:
|
with GracefulInterruptHandler() as h:
|
||||||
while True:
|
while True:
|
||||||
|
Loading…
Reference in New Issue
Block a user