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
parent
167e3dd79b
commit
a5332059e9
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue