global: fix PEP-8 formatting
This patch was generated by running `autopep8 --diff` on the source tree and then applying the diff.
This commit is contained in:
parent
bb644cdd07
commit
f05078f66e
20 changed files with 36 additions and 28 deletions
|
|
@ -230,7 +230,7 @@ def create_oci_dir(tree, output_dir, options):
|
|||
config["rootfs"]["diff_ids"] = [digest]
|
||||
manifest["layers"].append(info)
|
||||
|
||||
## write config
|
||||
# write config
|
||||
info = blobs_add_json(blobs, config, "config")
|
||||
manifest["config"] = info
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ SCHEMA = """
|
|||
}
|
||||
"""
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def mount(source, dest, *options):
|
||||
os.makedirs(dest, 0o755, True)
|
||||
|
|
|
|||
|
|
@ -373,7 +373,7 @@ class Manifest:
|
|||
|
||||
def add_pipeline(
|
||||
self, name: str, runner: Optional[str], build: Optional[str] = None, source_epoch: Optional[int] = None
|
||||
) -> Pipeline:
|
||||
) -> Pipeline:
|
||||
pipeline = Pipeline(name, runner, build, source_epoch)
|
||||
if name in self.pipelines:
|
||||
raise ValueError(f"Name {name} already exists")
|
||||
|
|
|
|||
|
|
@ -175,12 +175,13 @@ class PasswdLike:
|
|||
class can parse the the list, manipulate it, and export it to file
|
||||
again.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
"""Initialize an empty PasswdLike object"""
|
||||
self.db = dict()
|
||||
|
||||
@classmethod
|
||||
def from_file(cls, path: PathLike, allow_missing_file: bool=False):
|
||||
def from_file(cls, path: PathLike, allow_missing_file: bool = False):
|
||||
"""Initialize a PasswdLike object from an existing file"""
|
||||
ret = cls()
|
||||
if allow_missing_file:
|
||||
|
|
@ -191,7 +192,7 @@ class PasswdLike:
|
|||
ret.db = cls._passwd_lines_to_dict(p.readlines())
|
||||
return ret
|
||||
|
||||
def merge_with_file(self, path: PathLike, allow_missing_file: bool=False):
|
||||
def merge_with_file(self, path: PathLike, allow_missing_file: bool = False):
|
||||
"""Extend the database with entries from another file"""
|
||||
if allow_missing_file:
|
||||
if not os.path.isfile(path):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
"""Path handling utility functions"""
|
||||
import os
|
||||
|
||||
|
||||
def in_tree(path: str, tree: str, must_exist: bool = False) -> bool:
|
||||
"""Return whether the canonical location of 'path' is under 'tree'.
|
||||
If 'must_exist' is True, the file must also exist for the check to succeed.
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ def python_alternatives():
|
|||
except FileExistsError:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
with osbuild.api.exception_handler():
|
||||
ldconfig()
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ def make_efi(efi, info, root, loop_client):
|
|||
efidir = os.path.join(root, "EFI", "BOOT")
|
||||
os.makedirs(efidir)
|
||||
|
||||
#arch related data
|
||||
# arch related data
|
||||
for arch in arches:
|
||||
arch = arch.lower()
|
||||
targets = [
|
||||
|
|
@ -382,7 +382,7 @@ def main(inputs, root, options, workdir, loop_client):
|
|||
"cmdline": cmdline
|
||||
}
|
||||
|
||||
#install the kernel
|
||||
# install the kernel
|
||||
kerneldir = pxedir
|
||||
kernel_input = inputs.get("kernel", inputs["rootfs"])
|
||||
kernel_tree = kernel_input["path"]
|
||||
|
|
|
|||
|
|
@ -88,10 +88,10 @@ def main(tree, options):
|
|||
subprocess.run(["chroot",
|
||||
tree,
|
||||
"firewall-offline-cmd"] +
|
||||
list(map(lambda x: f"--port={x}", ports)) +
|
||||
list(map(lambda x: f"--service={x}", enabled_services)) +
|
||||
list(map(lambda x: f"--remove-service={x}", disabled_services)),
|
||||
check=True)
|
||||
list(map(lambda x: f"--port={x}", ports)) +
|
||||
list(map(lambda x: f"--service={x}", enabled_services)) +
|
||||
list(map(lambda x: f"--remove-service={x}", disabled_services)),
|
||||
check=True)
|
||||
|
||||
return 0
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ SCHEMA = """
|
|||
}
|
||||
"""
|
||||
|
||||
|
||||
def main(tree, options):
|
||||
language = options["language"]
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ SCHEMA_2 = r"""
|
|||
}
|
||||
"""
|
||||
|
||||
|
||||
def main(tree, options):
|
||||
path = options.get("path", "etc/nginx/nginx.conf").lstrip("/")
|
||||
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ SCHEMA = """
|
|||
XML_RESULTS = "eval_remediate_results.xml"
|
||||
HTML_REPORT = "eval_remediate_report.html"
|
||||
|
||||
|
||||
def main(tree, options):
|
||||
# required vars
|
||||
config = options["config"]
|
||||
|
|
@ -108,9 +109,9 @@ def main(tree, options):
|
|||
|
||||
# run openscap in chroot on the image tree
|
||||
cmd = [
|
||||
"/usr/sbin/chroot", tree,
|
||||
"/usr/bin/oscap", "xccdf", "eval",
|
||||
"--remediate", "--profile", profile
|
||||
"/usr/sbin/chroot", tree,
|
||||
"/usr/bin/oscap", "xccdf", "eval",
|
||||
"--remediate", "--profile", profile
|
||||
]
|
||||
|
||||
if data_dir is not None:
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ def configure_network_scripts_ifcfg(tree, network_scripts_ifcfg_options):
|
|||
else:
|
||||
# schema does not currently allow any additional properties but it may at some point
|
||||
raise ValueError(f"Error: unknown property {option} specified for sysconfig network-scripts/ifcfg "
|
||||
"config.")
|
||||
"config.")
|
||||
|
||||
if lines:
|
||||
with open(f"{tree}/etc/sysconfig/network-scripts/ifcfg-{ifname}", 'w') as ifcfg_file:
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ class TunedProfilesDB:
|
|||
Class for loading available TuneD profiles from the given filesystem tree
|
||||
and checking if a profile with particular name exists.
|
||||
"""
|
||||
|
||||
def __init__(self, tree):
|
||||
self._available_profiles = self._load_available_profiles(tree)
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ from osbuild.util import jsoncomm
|
|||
|
||||
class APITester(osbuild.api.BaseAPI):
|
||||
"""Records the number of messages and if it got cleaned up"""
|
||||
|
||||
def __init__(self, sockaddr):
|
||||
super().__init__(sockaddr)
|
||||
self.clean = False
|
||||
|
|
@ -33,6 +34,7 @@ class APITester(osbuild.api.BaseAPI):
|
|||
|
||||
class TestAPI(unittest.TestCase):
|
||||
"""Check API infrastructure"""
|
||||
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
|
||||
|
|
|
|||
|
|
@ -160,7 +160,6 @@ class TestFormatV1(unittest.TestCase):
|
|||
self.assertEqual(pl.runner, runner)
|
||||
check_stage(have, want)
|
||||
|
||||
|
||||
def test_describe(self):
|
||||
index = osbuild.meta.Index(os.curdir)
|
||||
|
||||
|
|
@ -412,9 +411,9 @@ class TestFormatV1(unittest.TestCase):
|
|||
self.assertEqual(res.valid, False)
|
||||
self.assertEqual(len(res), 2)
|
||||
lst = res[".pipeline.stages[0].options"]
|
||||
self.assertEqual(len(lst), 1) # missing rootfs
|
||||
self.assertEqual(len(lst), 1) # missing rootfs
|
||||
lst = res[".pipeline.stages[0].options.uefi"]
|
||||
self.assertEqual(len(lst), 1) # missing "osname"
|
||||
self.assertEqual(len(lst), 1) # missing "osname"
|
||||
|
||||
assembler_check = {
|
||||
"pipeline": {
|
||||
|
|
@ -431,6 +430,6 @@ class TestFormatV1(unittest.TestCase):
|
|||
self.assertEqual(res.valid, False)
|
||||
self.assertEqual(len(res), 2)
|
||||
lst = res[".pipeline.assembler.options"]
|
||||
self.assertEqual(len(lst), 1) # missing "filename"
|
||||
self.assertEqual(len(lst), 1) # missing "filename"
|
||||
lst = res[".pipeline.assembler.options.compression"]
|
||||
self.assertEqual(len(lst), 1) # wrong compression method
|
||||
self.assertEqual(len(lst), 1) # wrong compression method
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ class TestObjectStore(unittest.TestCase):
|
|||
with object_store.new() as tree:
|
||||
path = tree.write()
|
||||
with tree.write() as path, \
|
||||
open(os.path.join(path, "data"), "w") as f:
|
||||
open(os.path.join(path, "data"), "w") as f:
|
||||
f.write(data)
|
||||
st = os.fstat(f.fileno())
|
||||
data_inode = st.st_ino
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ class TestUtilLorax(test.TestBase):
|
|||
if not os.path.exists(target):
|
||||
self.fail(f"Path {target} does not exists")
|
||||
|
||||
|
||||
def test_script(self):
|
||||
with tempfile.TemporaryDirectory(dir="/var/tmp") as tmp:
|
||||
root = os.path.join(tmp, "root")
|
||||
|
|
@ -81,7 +80,6 @@ class TestUtilLorax(test.TestBase):
|
|||
data = f.read().strip()
|
||||
self.assertEqual(data, "osbuild-42")
|
||||
|
||||
|
||||
def test_script_errors(self):
|
||||
with tempfile.TemporaryDirectory(dir="/var/tmp") as tmp:
|
||||
root = os.path.join(tmp, "root")
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import os
|
|||
|
||||
from osbuild.util import path
|
||||
|
||||
|
||||
def test_in_tree():
|
||||
cases = {
|
||||
("/tmp/file", "/tmp", False): True, # Simple, non-existent
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from io import StringIO
|
|||
|
||||
from osbuild.util.rhsm import Subscriptions
|
||||
|
||||
REPO_FILE="""[jpp]
|
||||
REPO_FILE = """[jpp]
|
||||
name = Red Hat JBoss Portal
|
||||
baseurl = https://cdn.redhat.com/1.0/$basearch/os
|
||||
enabled = 0
|
||||
|
|
@ -66,7 +66,7 @@ def test_from_host_system():
|
|||
|
||||
raise e
|
||||
|
||||
assert test_case["success"] # Verify this test case should pass
|
||||
assert test_case["success"] # Verify this test case should pass
|
||||
assert secrets["ssl_ca_cert"] == "/etc/rhsm/ca/redhat-uep.pem"
|
||||
assert secrets["ssl_client_key"] == f'/etc/pki/entitlement/{test_case["key"]}-key.pem'
|
||||
assert secrets["ssl_client_cert"] == f'/etc/pki/entitlement/{test_case["key"]}.pem'
|
||||
|
|
|
|||
|
|
@ -314,8 +314,8 @@ class TestStages(test.TestBase):
|
|||
for image_name, test_data in checks.items():
|
||||
with self.osbuild as osb, tempfile.TemporaryDirectory(dir="/var/tmp") as outdir:
|
||||
osb.compile_file(os.path.join(testdir, "qemu.json"),
|
||||
exports=[image_name],
|
||||
output_dir=outdir)
|
||||
exports=[image_name],
|
||||
output_dir=outdir)
|
||||
|
||||
tree = os.path.join(outdir, image_name)
|
||||
ip = os.path.join(tree, image_name)
|
||||
|
|
@ -331,8 +331,8 @@ class TestStages(test.TestBase):
|
|||
|
||||
qemu_img_out = json.loads(qemu_img_run.stdout)
|
||||
self.assertTrue(mapping_is_subset(test_data, qemu_img_out),
|
||||
f"Test data is not a subset of the qemu-img output: {test_data} not <= {qemu_img_run.stdout}"
|
||||
)
|
||||
("Test data is not a subset of the qemu-img output: "
|
||||
f"{test_data} not <= {qemu_img_run.stdout}"))
|
||||
|
||||
# cache the downloaded data for the files source
|
||||
osb.copy_source_data(self.store, "org.osbuild.files")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue