modules: explicit encodings for open()
This commit is contained in:
parent
38d2ab685c
commit
b07aca5d86
89 changed files with 144 additions and 144 deletions
|
|
@ -112,7 +112,7 @@ MEDIA_TYPES = {
|
|||
def sha256sum(path: str) -> str:
|
||||
ret = subprocess.run(["sha256sum", path],
|
||||
stdout=subprocess.PIPE,
|
||||
encoding="utf-8",
|
||||
encoding="utf8",
|
||||
check=True)
|
||||
|
||||
return ret.stdout.strip().split(" ")[0]
|
||||
|
|
@ -135,7 +135,7 @@ def blobs_add_file(blobs: str, path: str, mtype: str):
|
|||
|
||||
def blobs_add_json(blobs: str, js: str, mtype: str):
|
||||
js_file = os.path.join(blobs, "temporary.js")
|
||||
with open(js_file, "w") as f:
|
||||
with open(js_file, "w", encoding="utf8") as f:
|
||||
json.dump(js, f)
|
||||
|
||||
return blobs_add_file(blobs, js_file, mtype)
|
||||
|
|
@ -246,11 +246,11 @@ def create_oci_dir(tree, output_dir, options):
|
|||
|
||||
# index
|
||||
print("writing index")
|
||||
with open(os.path.join(output_dir, "index.json"), "w") as f:
|
||||
with open(os.path.join(output_dir, "index.json"), "w", encoding="utf8") as f:
|
||||
json.dump(index, f)
|
||||
|
||||
# oci-layout tag
|
||||
with open(os.path.join(output_dir, "oci-layout"), "w") as f:
|
||||
with open(os.path.join(output_dir, "oci-layout"), "w", encoding="utf8") as f:
|
||||
json.dump({"imageLayoutVersion": "1.0.0"}, f)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ def main(tree, output_dir, options, meta):
|
|||
stdout=sys.stderr,
|
||||
check=True)
|
||||
|
||||
with open(os.path.join(output_dir, "compose.json"), "r") as f:
|
||||
with open(os.path.join(output_dir, "compose.json"), "r", encoding="utf8") as f:
|
||||
compose = json.load(f)
|
||||
|
||||
api.metadata({"compose": compose})
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ def mkfs_ext4(device, uuid, label):
|
|||
if label:
|
||||
opts = ["-L", label]
|
||||
subprocess.run(["mkfs.ext4", "-U", uuid] + opts + [device],
|
||||
input="y", encoding='utf-8', check=True)
|
||||
input="y", encoding='utf8', check=True)
|
||||
|
||||
|
||||
def mkfs_xfs(device, uuid, label):
|
||||
|
|
@ -179,7 +179,7 @@ def mkfs_xfs(device, uuid, label):
|
|||
if label:
|
||||
opts = ["-L", label]
|
||||
subprocess.run(["mkfs.xfs", "-m", f"uuid={uuid}"] + opts + [device],
|
||||
encoding='utf-8', check=True)
|
||||
encoding='utf8', check=True)
|
||||
|
||||
|
||||
def mkfs_btrfs(device, uuid, label):
|
||||
|
|
@ -187,7 +187,7 @@ def mkfs_btrfs(device, uuid, label):
|
|||
if label:
|
||||
opts = ["-L", label]
|
||||
subprocess.run(["mkfs.btrfs", "-U", uuid] + opts + [device],
|
||||
encoding='utf-8', check=True)
|
||||
encoding='utf8', check=True)
|
||||
|
||||
|
||||
def mkfs_vfat(device, uuid, label):
|
||||
|
|
@ -195,7 +195,7 @@ def mkfs_vfat(device, uuid, label):
|
|||
opts = []
|
||||
if label:
|
||||
opts = ["-n", label]
|
||||
subprocess.run(["mkfs.vfat", "-i", volid] + opts + [device], encoding='utf-8', check=True)
|
||||
subprocess.run(["mkfs.vfat", "-i", volid] + opts + [device], encoding='utf8', check=True)
|
||||
|
||||
|
||||
class Filesystem:
|
||||
|
|
@ -336,7 +336,7 @@ class PartitionTable:
|
|||
|
||||
subprocess.run(["sfdisk", "-q", target],
|
||||
input=command,
|
||||
encoding='utf-8',
|
||||
encoding='utf8',
|
||||
check=True)
|
||||
|
||||
if sync:
|
||||
|
|
@ -346,7 +346,7 @@ class PartitionTable:
|
|||
"""Update and fill in missing information from disk"""
|
||||
r = subprocess.run(["sfdisk", "--json", target],
|
||||
stdout=subprocess.PIPE,
|
||||
encoding='utf-8',
|
||||
encoding='utf8',
|
||||
check=True)
|
||||
disk_table = json.loads(r.stdout)["partitiontable"]
|
||||
disk_parts = disk_table["partitions"]
|
||||
|
|
@ -596,7 +596,7 @@ def install_grub2(image: str, pt: PartitionTable, options):
|
|||
|
||||
def parse_blsfile(blsfile):
|
||||
params = {}
|
||||
with open(blsfile, "r") as bls:
|
||||
with open(blsfile, "r", encoding="utf8") as bls:
|
||||
for line in bls:
|
||||
key, value = line.split(' ', 1)
|
||||
params[key] = value.strip()
|
||||
|
|
@ -698,7 +698,7 @@ def main(tree, output_dir, options, loop_client):
|
|||
if fmt == "raw":
|
||||
subprocess.run(["cp", image, f"{output_dir}/{filename}"], check=True)
|
||||
elif fmt == "raw.xz":
|
||||
with open(f"{output_dir}/{filename}", "w") as f:
|
||||
with open(f"{output_dir}/{filename}", "w", encoding="utf8") as f:
|
||||
subprocess.run(
|
||||
["xz", "--keep", "--stdout", "-0", image],
|
||||
stdout=f,
|
||||
|
|
|
|||
|
|
@ -68,15 +68,15 @@ def mount(source, dest, *options):
|
|||
|
||||
|
||||
def mkfs_ext4(device, uuid):
|
||||
subprocess.run(["mkfs.ext4", "-U", uuid, device], input="y", encoding='utf-8', check=True)
|
||||
subprocess.run(["mkfs.ext4", "-U", uuid, device], input="y", encoding='utf8', check=True)
|
||||
|
||||
|
||||
def mkfs_xfs(device, uuid):
|
||||
subprocess.run(["mkfs.xfs", "-m", f"uuid={uuid}", device], encoding='utf-8', check=True)
|
||||
subprocess.run(["mkfs.xfs", "-m", f"uuid={uuid}", device], encoding='utf8', check=True)
|
||||
|
||||
|
||||
def mkfs_btrfs(device, uuid):
|
||||
subprocess.run(["mkfs.btrfs", "-U", uuid, device], encoding='utf-8', check=True)
|
||||
subprocess.run(["mkfs.btrfs", "-U", uuid, device], encoding='utf8', check=True)
|
||||
|
||||
|
||||
def main(tree, output_dir, options, loop_client):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue