Skip to content

Commit d1380bf

Browse files
committed
improve logging, remove unused code
Signed-off-by: Zen <[email protected]>
1 parent a344404 commit d1380bf

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/ugrd/initramfs_dict.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = "desultory"
2-
__version__ = "2.2.0"
2+
__version__ = "2.2.1"
33

44
from tomllib import load, TOMLDecodeError
55
from pathlib import Path
@@ -133,7 +133,6 @@ def _process_custom_parameters(self, parameter_name: str, parameter_type: type)
133133
Sets the initial value of the parameter based on the type.
134134
"""
135135
from pycpio import PyCPIO
136-
from .initramfs_generator import InitramfsGenerator # import here for eval'ing
137136

138137
self['custom_parameters'][parameter_name] = eval(parameter_type)
139138
self.logger.debug("Registered custom parameter '%s' with type: %s" % (parameter_name, parameter_type))

src/ugrd/initramfs_generator.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
@loggify
1111
class InitramfsGenerator(GeneratorHelpers):
1212
def __init__(self, config='/etc/ugrd/config.toml', *args, **kwargs):
13-
self.config_dict = InitramfsConfigDict(NO_BASE=kwargs.pop('NO_BASE', False), logger=self.logger)
13+
self.config_dict = InitramfsConfigDict(NO_BASE=kwargs.pop('NO_BASE', False), logger=self.logger, _log_init=False)
1414

1515
# Used for functions that are added to the bash source file
1616
self.included_functions = {}
@@ -71,8 +71,10 @@ def __getattr__(self, item):
7171

7272
def build(self) -> None:
7373
""" Builds the initramfs image. """
74+
from importlib.metadata import version
75+
self._log_run(f"Running ugrd v{version('ugrd')}")
7476
self.run_build()
75-
self.config_dict.validate()
77+
self.config_dict.validate() # Validate the config after the build tasks have been run
7678

7779
self.generate_init()
7880
self.pack_build()
@@ -201,12 +203,14 @@ def generate_init(self) -> None:
201203

202204
def run_build(self) -> None:
203205
""" Runs all build tasks. """
206+
self._log_run("Running build tasks")
204207
for task in self.build_tasks:
205208
self.logger.debug("Running build task: %s" % task)
206209
self.run_hook(task, force_exclude=True)
207210

208211
def pack_build(self) -> None:
209212
""" Packs the initramfs based on self['imports']['pack']."""
213+
self._log_run("Packing build")
210214
if self['imports'].get('pack'):
211215
self.run_hook('pack')
212216
else:
@@ -224,8 +228,8 @@ def run_init_hook(self, level: str) -> list[str]:
224228

225229
def run_checks(self) -> None:
226230
""" Runs checks if defined in self['imports']['checks']. """
231+
self._log_run("Running checks")
227232
if check_output := self.run_hook('checks'):
228-
self.logger.info("Completed checks.")
229233
for check in check_output:
230234
self.logger.debug(check)
231235
else:
@@ -234,10 +238,14 @@ def run_checks(self) -> None:
234238
def run_tests(self) -> None:
235239
""" Runs tests if defined in self['imports']['tests']. """
236240
if test_output := self.run_hook('tests'):
241+
self._log_run("Running tests")
237242
self.logger.info("Completed tests:\n%s", test_output)
238243
else:
239244
self.logger.debug("No tests executed.")
240245

246+
def _log_run(self, logline) -> None:
247+
self.logger.info(f"== | {logline}")
248+
241249
def __str__(self) -> str:
242250
return str(self.config_dict)
243251

0 commit comments

Comments
 (0)