-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopy_config_files.py
31 lines (24 loc) · 1.01 KB
/
copy_config_files.py
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
import logging
from os import system
from typing import Final
from config_file import ConfigFile
from util import copy_resource_to_file
from util import shutdown
class CopyConfigFiles:
def __init__(self,
config_current: ConfigFile,
config_lcd: ConfigFile,
config_hdmi: ConfigFile,
):
self._config_current: Final = config_current
self._config_lcd: Final = config_lcd
self._config_hdmi: Final = config_hdmi
self._log = logging.getLogger(__name__)
def ensure_config_files_exists(self, force: bool = False):
if self._config_lcd.exists and self._config_hdmi.exists and not force:
self._log.info(f'Check all config files already exist.')
return
self._log.info(f'Some config files are missing.')
system('mount -o remount, rw /boot')
for config in [self._config_lcd, self._config_hdmi]:
copy_resource_to_file(f'configs/{config.base_name}', config.file_name)