defaults for ConfigProcessor
This commit is contained in:
parent
73f683533f
commit
7734706157
2 changed files with 13 additions and 7 deletions
|
|
@ -61,11 +61,19 @@ class SnapperCmd:
|
||||||
|
|
||||||
class ConfigProcessor:
|
class ConfigProcessor:
|
||||||
|
|
||||||
def __init__(self, ini_file, parent_cmd, packages, snapshot_type):
|
def __init__(self, ini_file, snapshot_type, parent_cmd=None, packages=None):
|
||||||
"""Set up defaults for snap-pac configuration."""
|
"""Set up defaults for snap-pac configuration."""
|
||||||
|
|
||||||
|
if parent_cmd is None:
|
||||||
|
self.parent_cmd = os.popen(f"ps -p {os.getppid()} -o args=").read().strip()
|
||||||
|
else:
|
||||||
self.parent_cmd = parent_cmd
|
self.parent_cmd = parent_cmd
|
||||||
|
|
||||||
|
if packages is None:
|
||||||
|
self.packages = [line.rstrip("\n") for line in sys.stdin]
|
||||||
|
else:
|
||||||
self.packages = packages
|
self.packages = packages
|
||||||
|
|
||||||
self.snapshot_type = snapshot_type
|
self.snapshot_type = snapshot_type
|
||||||
|
|
||||||
self.config = ConfigParser()
|
self.config = ConfigParser()
|
||||||
|
|
@ -166,9 +174,7 @@ if __name__ == "__main__":
|
||||||
snapper_conf_file = args.snapper_conf_file
|
snapper_conf_file = args.snapper_conf_file
|
||||||
snap_pac_ini = args.snap_pac_ini
|
snap_pac_ini = args.snap_pac_ini
|
||||||
|
|
||||||
parent_cmd = os.popen(f"ps -p {os.getppid()} -o args=").read().strip()
|
config_processor = ConfigProcessor(snap_pac_ini, snapshot_type)
|
||||||
packages = [line.rstrip("\n") for line in sys.stdin]
|
|
||||||
config_processor = ConfigProcessor(snap_pac_ini, parent_cmd, packages, snapshot_type)
|
|
||||||
snapper_configs = get_snapper_configs(snapper_conf_file)
|
snapper_configs = get_snapper_configs(snapper_conf_file)
|
||||||
chroot = os.stat("/") != os.stat("/proc/1/root/.")
|
chroot = os.stat("/") != os.stat("/proc/1/root/.")
|
||||||
tmpdir = Path(tempfile.gettempdir())
|
tmpdir = Path(tempfile.gettempdir())
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ def test_config_processor(section, command, packages, snapshot_type, result):
|
||||||
f.write("important_packages = [\"linux\", \"linux-lts\"]\n")
|
f.write("important_packages = [\"linux\", \"linux-lts\"]\n")
|
||||||
f.write("userdata = [\"foo=bar\", \"requestid=42\"]\n")
|
f.write("userdata = [\"foo=bar\", \"requestid=42\"]\n")
|
||||||
name = f.name
|
name = f.name
|
||||||
config_processor = ConfigProcessor(name, command, packages, snapshot_type)
|
config_processor = ConfigProcessor(name, snapshot_type, command, packages)
|
||||||
assert config_processor(section) == result
|
assert config_processor(section) == result
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue