forked from tiny-pilot/tinypilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlauncher.py
More file actions
39 lines (25 loc) · 979 Bytes
/
launcher.py
File metadata and controls
39 lines (25 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import logging
import subprocess
import update.result_store
import update.status
logger = logging.getLogger(__name__)
class Error(Exception):
pass
class AlreadyInProgressError(Error):
pass
UPDATE_SCRIPT_PATH = '/opt/tinypilot-privileged/scripts/update'
def start_async():
"""Launches the update service asynchronously.
Launches the tinypilot-update systemd service in the background. If the
service is already running, raises an exception.
Raises:
AlreadyInProgressError if the update process is already running.
"""
current_state, _ = update.status.get()
if current_state == update.status.Status.IN_PROGRESS:
raise AlreadyInProgressError('An update is already in progress')
update.result_store.clear()
# Ignore pylint since we're not managing the child process.
# pylint: disable=consider-using-with
subprocess.Popen(
('/usr/bin/sudo', '/usr/sbin/service', 'tinypilot-updater', 'start'))