diff --git a/evering/config.py b/evering/config.py index 0c4c785..23492e8 100644 --- a/evering/config.py +++ b/evering/config.py @@ -152,6 +152,16 @@ DEFAULT_CONFIG.add( "Location the file is currently being compiled for, as a Path. Set during compilation", has_constant_value=False) +DEFAULT_CONFIG.add( + "user", + "Current username. Set during compilation", + has_constant_value=False) + +DEFAULT_CONFIG.add( + "host", + "Name of the current computer. Set during compilation", + has_constant_value=False) + class Config: @staticmethod def load_config_file(path: Optional[Path]) -> "Config": @@ -361,3 +371,19 @@ class Config: @target.setter def target(self, path: Path) -> None: self._set("target", path) + + @property + def user(self) -> str: + return self._get("user", str) + + @target.setter + def user(self, user: str) -> None: + self._set("user", user) + + @property + def host(self) -> str: + return self._get("host", str) + + @target.setter + def host(self, host: str) -> None: + self._set("host", host) diff --git a/evering/process.py b/evering/process.py index 275596b..fa6213c 100644 --- a/evering/process.py +++ b/evering/process.py @@ -82,8 +82,12 @@ class Processor: def _process_binary(self, path: Path, config: Config) -> None: logger.debug(f"Processing as a binary file") + if not config.targets: + logger.info(" (no targets)") + return + for target in config.targets: - logger.info(f" -> {style_path(str(target))}") + logger.info(f" -> {style_path(target)}") if not self._justify_target(target): logger.info("Skipping this target") @@ -114,7 +118,7 @@ class Processor: return for target in config.targets: - logger.info(f" -> {style_path(str(target))}") + logger.info(f" -> {style_path(target)}") if not self._justify_target(target): logger.info("Skipping this target") @@ -122,6 +126,8 @@ class Processor: config_copy = config.copy() config_copy.target = target + config_copy.user = get_user() + config_copy.host = get_host() try: parser = Parser( diff --git a/evering/util.py b/evering/util.py index 1602990..252a652 100644 --- a/evering/util.py +++ b/evering/util.py @@ -1,10 +1,13 @@ import copy +import getpass +import socket import types from pathlib import Path from typing import Any, Dict __all__ = [ "copy_local_variables", + "get_user", "get_host", "ExecuteException", "safer_exec", "safer_eval", "ReadFileException", "read_file", "WriteFileException", "write_file", @@ -30,6 +33,12 @@ def copy_local_variables(local: Dict[str, Any]) -> Dict[str, Any]: return local_copy +def get_user() -> str: + return getpass.getuser() + +def get_host() -> str: + return socket.gethostname() + class ExecuteException(Exception): pass