Closed GP3D84 closed 3 weeks ago
hey, thanks for the contribution. next time please add some spaces.
Hi, Done :)
also, please add a fallback and a default value to the function in case the file cant be read. best is to try and catch it. and please check if the split works before sending it
def ratos_version():
"""
Get current version of RatOS distro.
"""
with open("/etc/ratos-release") as f:
return f.read().split()[1]
and please put the function under the helper category
When I tried to put it into the class, version not load correctly Honestly, I haven't investigated much, I'll try again when I'm at home
When I tried to put it into the class, version not load correctly Honestly, I haven't investigated much, I'll try again when I'm at home
this is how it works
def get_ratos_version(self):
"""
Get current version of RatOS distro.
"""
try:
with open("/etc/ratos-release") as f:
return f.read().split()[1]
except Exception as exc:
self.debug_echo("get_ratos_version", "Something went wrong. " + str(exc))
return "v2.1"
you call it then like this
RatOS ' + self.get_ratos_version() + '</p>
put it here
@HelgeKeck done and thank you for your help
now please fix the double empty line and you are done
only one emtpy line
after that im ok with it
Maybe it would be useful to save as register_command for use elsewhere? eg. https://github.com/GP3D84/RatOS-configuration/blob/development/macros/calibration.cfg#L65
Maybe it would be useful to save as register_command for use elsewhere? eg. https://github.com/GP3D84/RatOS-configuration/blob/development/macros/calibration.cfg#L65
i think i will jsut remoce the version tags from such messages, no need to worry now
Thank you!
hey, thanks for the contribution. next time please add some spaces.
instead this here:
RatOS '+ ratos_version() +'</p>
please do this
RatOS ' + ratos_version() + '</p>