34 lines
798 B
Python
34 lines
798 B
Python
import zipfile
|
|
import hashlib
|
|
import uuid
|
|
import json
|
|
|
|
SERVER_URL = "http://localhost:8080/api/devicefingerprinting"
|
|
packs = []
|
|
|
|
def file_sha1(path):
|
|
h = hashlib.sha1()
|
|
with open(path, "rb") as f:
|
|
for chunk in iter(lambda: f.read(8192), b""):
|
|
h.update(chunk)
|
|
return h.hexdigest()
|
|
|
|
for i in range(0, 24):
|
|
path = f"packs/{i}"
|
|
|
|
with zipfile.ZipFile(path, mode="w") as zf:
|
|
zf.writestr(
|
|
"pack.mcmeta",
|
|
'{"pack":{"pack_format":22,"supported_formats":[22,1000],"description":"pack ' + str(i) + '"}}',
|
|
)
|
|
|
|
hash = file_sha1(path)
|
|
packs.append({
|
|
"url": f"{SERVER_URL}/packs/{i}",
|
|
"uuid": str(uuid.uuid4()),
|
|
"hash": hash
|
|
})
|
|
|
|
with open("packs.json", "w") as f:
|
|
json.dump(packs, f, indent=4)
|