Fixed stuff and switched to tar
Signed-off-by: fly <merspieler@airmail.cc>
This commit is contained in:
parent
cc6f79b2ff
commit
1c338a0861
1 changed files with 40 additions and 33 deletions
|
@ -82,11 +82,11 @@ def read_index(fname):
|
|||
index = {}
|
||||
with open(fname) as f:
|
||||
for line in f:
|
||||
match = re.match("(.:.*):(.*)", line)
|
||||
match = re.match("(version|time|path|d:.*):(.*)", line)
|
||||
if match != None:
|
||||
index[match.group(1)] = match.group(2)
|
||||
else:
|
||||
match = re.match("(version|time|path):(.*)", line)
|
||||
match = re.match("(.*:.*):(.*:.*)", line)
|
||||
if match != None:
|
||||
index[match.group(1)] = match.group(2)
|
||||
return index
|
||||
|
@ -96,35 +96,41 @@ def write_index(fname, index):
|
|||
for element in index:
|
||||
f.write(element + ":" + str(index[element]) + "\n")
|
||||
|
||||
|
||||
def update_index(output, name, name_major):
|
||||
if os.path.isfile(output + "/" + name_major + "/.dirindex"):
|
||||
index = read_index(output + "/" + name_major + "/.dirindex")
|
||||
def update_parent_index(base, path, changed_dir):
|
||||
if os.path.isfile(base + "/" + path + "/.dirindex"):
|
||||
index = read_index(base + "/" + path + "/.dirindex")
|
||||
else:
|
||||
index = {}
|
||||
index["version"] = 1
|
||||
index["path"] = name_major
|
||||
|
||||
sha = get_sha1(output + "/" + name_major + "/" + name + ".zip")
|
||||
if sha != None:
|
||||
index["z:" + name + ".zip"] = sha
|
||||
|
||||
write_index(output + "/" + name_major + "/.dirindex", index)
|
||||
|
||||
if os.path.isfile(output + "/.dirindex"):
|
||||
main_index = read_index(output + "/.dirindex")
|
||||
if path != "":
|
||||
index["path"] = "osm2city/" + path
|
||||
else:
|
||||
main_index = {}
|
||||
main_index["version"] = 1
|
||||
main_index["path"] = ""
|
||||
index["path"] = "osm2city"
|
||||
|
||||
sha = get_sha1(output + "/" + name_major + "/.dirindex")
|
||||
if sha != None:
|
||||
main_index["d:" + name_major] = sha
|
||||
sha = get_sha1(base + "/" + path + "/" + changed_dir + "/.dirindex")
|
||||
if sha != None:
|
||||
index["d:" + changed_dir] = sha
|
||||
|
||||
write_index(output + "/.dirindex", main_index)
|
||||
write_index(base + "/" + path + "/.dirindex", index)
|
||||
|
||||
|
||||
def update_index(output, part, name, name_major):
|
||||
if os.path.isfile(output + "/" + part + "/" + name_major + "/.dirindex"):
|
||||
index = read_index(output + "/" + part + "/" + name_major + "/.dirindex")
|
||||
else:
|
||||
index = {}
|
||||
index["version"] = 1
|
||||
index["path"] = "osm2city/" + part + "/" + name_major
|
||||
|
||||
sha = get_sha1(output + "/" + part + "/" + name_major + "/" + name + ".txz")
|
||||
if sha != None:
|
||||
index["t:" + name + ".txz"] = sha + ":" + str(os.path.getsize(output + "/" + part + "/" + name_major + "/" + name + ".txz"))
|
||||
|
||||
write_index(output + "/" + part + "/" + name_major + "/.dirindex", index)
|
||||
|
||||
update_parent_index(output, part, name_major)
|
||||
update_parent_index(output, "", part)
|
||||
|
||||
running = True
|
||||
while running:
|
||||
try:
|
||||
|
@ -153,22 +159,23 @@ while running:
|
|||
|
||||
name_major = ew + norm(ew_val_major, 3) + ns + norm(ns_val_major, 2)
|
||||
|
||||
run("mkdir -p " + output + "/" + name_major, shell=True)
|
||||
|
||||
run("rm -f " + output + "/" + name_major + "/" + name + ".zip", shell=True)
|
||||
|
||||
print("Packaging " + name + "...")
|
||||
|
||||
cmd = "bash -c 'cd projects/worldbuild/scenery && zip -rq " + output + "/" + name_major + "/" + name + ".zip {Details,Pylons,Buildings,Roads}/" + name_major + "/" + name + "/*'"
|
||||
with open(os.devnull, 'w') as fp:
|
||||
package = Popen(cmd , shell=True, start_new_session=True, stdout=fp)
|
||||
for part in ["Buildings", "Details", "Pylons", "Roads"]:
|
||||
run("rm -f " + output + "/" + part + "/" + name_major + "/" + name + ".txz", shell=True)
|
||||
if os.path.exists("projects/worldbuild/scenery/" + part + "/" + name_major + "/" + name):
|
||||
run("mkdir -p " + output + "/" + part + "/" + name_major, shell=True)
|
||||
|
||||
package.wait()
|
||||
cmd = "bash -c 'cd projects/worldbuild/scenery/" + part + "/" + name_major + " && tar -cJf " + output + "/" + part + "/" + name_major + "/" + name + ".txz " + name + "/'"
|
||||
with open(os.devnull, 'w') as fp:
|
||||
package = Popen(cmd , shell=True, start_new_session=True, stdout=fp)
|
||||
|
||||
package.wait()
|
||||
|
||||
update_index(output, part, name, name_major)
|
||||
|
||||
print("Packaging " + name + " done")
|
||||
|
||||
update_index(output, name, name_major)
|
||||
|
||||
send_status(name, "packaged", host, port)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
|
|
Loading…
Reference in a new issue