Skip to content

Commit

Permalink
Handle device and serial files not found error (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcapona authored Jul 16, 2024
1 parent 6d21a21 commit 004d6e5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions further_link/start_further.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from os import environ, getenv
from os.path import exists
from shlex import split
from subprocess import DEVNULL, Popen

Expand All @@ -16,14 +17,18 @@ def run_command_background(command_str, print_output=False):
)


def _read_from_file(file_path):
if exists(file_path):
with open(file_path, "r") as f:
return f.read().strip()
return None


def get_further_url():
further_url = "https://further.pi-top.com/start"

with open("/run/pt_hub_serial", "r") as f:
serial = f.read().strip()

with open("/run/pt_device_type", "r") as f:
device = f.read().strip()
serial = _read_from_file("/run/pt_serial_number")
device = _read_from_file("/run/pt_device_type")

if serial or device:
further_url += "?"
Expand Down

0 comments on commit 004d6e5

Please sign in to comment.