Python: Add get_version() function

This commit adds add_version() to the helpers class, which can be used
to obtain the running firmware version and build.
library_additions
Marc 2021-07-21 14:34:04 +01:00
parent 167e3dd79b
commit a5332059e9
No known key found for this signature in database
GPG Key ID: 0657563F705ACAAE
1 changed files with 12 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import json
from typing import Tuple
def json_to_bytes(message) -> bytes:
@ -14,3 +15,14 @@ def json_to_bytes(message) -> bytes:
d = json.dumps(message)
return d.encode('utf-8')
def get_version() -> Tuple[str, str]:
"""
Get the system firmware version.
:return: tuple containing version and build number
"""
with open('/etc/pineapple/version', 'r') as f:
vers = [l.strip() for l in f.readlines()]
return vers[0], vers[1]