stream_layered_image: Add main method
This commit is contained in:
parent
307804d97d
commit
26402290bf
@ -181,19 +181,18 @@ def add_bytes(tar, path, content, mtime):
|
||||
tar.addfile(ti, io.BytesIO(content))
|
||||
|
||||
|
||||
# Main
|
||||
|
||||
with open(sys.argv[1], "r") as f:
|
||||
def main():
|
||||
with open(sys.argv[1], "r") as f:
|
||||
conf = json.load(f)
|
||||
|
||||
created = (
|
||||
created = (
|
||||
datetime.now(tz=datetime.timezone.utc)
|
||||
if conf["created"] == "now"
|
||||
else datetime.fromisoformat(conf["created"])
|
||||
)
|
||||
mtime = int(created.timestamp())
|
||||
)
|
||||
mtime = int(created.timestamp())
|
||||
|
||||
with tarfile.open(mode="w|", fileobj=sys.stdout.buffer) as tar:
|
||||
with tarfile.open(mode="w|", fileobj=sys.stdout.buffer) as tar:
|
||||
layers = []
|
||||
for num, store_layer in enumerate(conf["store_layers"]):
|
||||
print(
|
||||
@ -248,3 +247,7 @@ with tarfile.open(mode="w|", fileobj=sys.stdout.buffer) as tar:
|
||||
add_bytes(tar, "manifest.json", manifest_json, mtime=mtime)
|
||||
|
||||
print("Done.", file=sys.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user