Skip to content

Commit 5e88bc1

Browse files
committed
getting there on multi-process
1 parent 9693af9 commit 5e88bc1

File tree

3 files changed

+175
-82
lines changed

3 files changed

+175
-82
lines changed

Manifests/UIXR.manifest

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13443,7 +13443,7 @@ a71972244e3508bf48db2adff59e7f63,UIX/UIX FILES/Data Files/Textures/_daedric_foun
1344313443
e2cb298a2dfb707708eeb077b46d4f8d,UIX/UIX FILES/Data Files/Textures/_daedric002_nm.dds, ,
1344413444
3c01a23d6c7752e276f4c507655e1eab,UIX/UIX FILES/Data Files/Textures/_daedric002.dds, ,
1344513445
8b74c0698ec4c59d9ee2000b1db5022a,UIX/UIX FILES/Data Files/Textures/_daedric01.dds, ,
13446-
ec283abf2103eff15154d11e6a2bb20d,UIX/UIX FILES/Data Files/Textures/_Dni_D?cor004.dds,by Star Boi,cc-by
13446+
ec283abf2103eff15154d11e6a2bb20d,UIX/UIX FILES/Data Files/Textures/_Dni_Décor004.dds,by Star Boi,cc-by
1344713447
39d23e5fdb050b3770567079d70fb52b,UIX/UIX FILES/Data Files/Textures/_Dni_Roche004.dds,by Star Boi,cc-by
1344813448
3279c14593981d004cf98b8beda1594b,UIX/UIX FILES/Data Files/Textures/_Dni_Verre004.dds,by Star Boi,cc-by
1344913449
e4121e69e34223217581730960bf20c9,UIX/UIX FILES/Data Files/Textures/_flarecoin.dds, ,
@@ -17638,7 +17638,7 @@ d121ba1a1f28b0be5eadfda2127ac7cb,UIX/UIX FILES/Data Files/Textures/ecsf2r0124.tg
1763817638
d121ba1a1f28b0be5eadfda2127ac7cb,UIX/UIX FILES/Data Files/Textures/ecsf2r0125.tga, ,
1763917639
37165ba2e8709b5cd4262e3467551350,UIX/UIX FILES/Data Files/Textures/ecsf4s2a0012.tga, ,
1764017640
678e0dbe520081ff6b753adc46b6190f,UIX/UIX FILES/Data Files/Textures/electriclines.dds, ,
17641-
38aae7676b71e8651d20c90b64c6ad9d,UIX/UIX FILES/Data Files/Textures/elephant_meat.tga, ,
17641+
38aae7676b71e8651d20c90b64c6ad9d,UIX/UIX FILES/Data Files/Textures/elephant_meat.tga,by Cait,cc-by
1764217642
29f13bd31fa2391198f4f2796da81363,UIX/UIX FILES/Data Files/Textures/env_map1.dds,by Star Boi,cc-by
1764317643
ba3b7c266809c3925cf10283a2e87da5,UIX/UIX FILES/Data Files/Textures/env_map2.dds,by Star Boi,cc-by
1764417644
9ca7a30f71890e65fe10c449b5202095,UIX/UIX FILES/Data Files/Textures/enviro 01.dds, ,
@@ -18663,7 +18663,7 @@ e0d7898cf9ac9d5f71b4a9592403c00d,UIX/UIX FILES/Data Files/Textures/re901-3.dds,
1866318663
7e3d2293ce99819b6d8b897761f38965,UIX/UIX FILES/Data Files/Textures/reflection03.dds, ,
1866418664
427bf3cad67e96839e9b90d0623ad4a4,UIX/UIX FILES/Data Files/Textures/reflection04.dds, ,
1866518665
bf3d5e07c4ccccf1d3a59aa110d58632,UIX/UIX FILES/Data Files/Textures/rgfcr3.dds, ,
18666-
67988351e4e6729c56f8d76794ba43f4,UIX/UIX FILES/Data Files/Textures/Rgn_Ayse_bamboo.tga, ,
18666+
67988351e4e6729c56f8d76794ba43f4,UIX/UIX FILES/Data Files/Textures/Rgn_Ayse_bamboo.tga,by ayse,cc-by
1866718667
7847c19721cbf0e82419a3fd181391fe,UIX/UIX FILES/Data Files/Textures/rivets01.dds,by Spyder,CC0
1866818668
0907f43329535814100991264b43c766,UIX/UIX FILES/Data Files/Textures/RMoonGAni01.dds,by Spyder,CC0
1866918669
21a1bcda5d8a7de3ca9269625a671ee7,UIX/UIX FILES/Data Files/Textures/RMoonGAni02.dds,by Spyder,CC0
@@ -19477,7 +19477,7 @@ cefdb2afaff56af711bca2aafbcb0ec5,UIX/UIX FILES/Data Files/Textures/TOEa/Det_lava
1947719477
8a7ca893bc7f0af3f8a36a7b6617dd10,UIX/UIX FILES/Data Files/Textures/TOEa/grass.tga, ,
1947819478
86b4f5404d3e27cae0d2103d99888f78,UIX/UIX FILES/Data Files/Textures/TOEa/jd_treeleav3.dds,"by Jesse ""jdooby"" Wilson, retextured by ayse",cc-by-nc
1947919479
86b4f5404d3e27cae0d2103d99888f78,UIX/UIX FILES/Data Files/Textures/TOEa/jd_treeleavestex001.dds,"by Jesse ""jdooby"" Wilson, retextured by ayse",cc-by-nc
19480-
660268def562edabf6f401c3ce084b52,UIX/UIX FILES/Data Files/Textures/TOEa/jfern.tga, ,
19480+
660268def562edabf6f401c3ce084b52,UIX/UIX FILES/Data Files/Textures/TOEa/jfern.tga,"by Jesse ""jdooby"" Wilson, retextured by ayse",cc-by-nc
1948119481
ae0afa85ec2273f1dab825339472cc50,UIX/UIX FILES/Data Files/Textures/TOEa/palmleaf9.tga, ,
1948219482
c2ba2617dbfbd0fb7aa21e2da64d8b38,UIX/UIX FILES/Data Files/Textures/TOEa/palmtrunk1.tga, ,
1948319483
c46991ab2f93153f36e78bb338a3946c,UIX/UIX FILES/Data Files/Textures/TOEa/Thumbs.db, ,
@@ -19824,7 +19824,7 @@ bbabb7bde5cc50704bb66a2899305941,UIX/UIX FILES/Data Files/Textures/tx_stone_mid2
1982419824
99e58c1f4b4b3a5a1182f1101a5968f2,UIX/UIX FILES/Data Files/Textures/Tx_tbM_contain_dev1.bmp,by Star Boi,cc-by
1982519825
1460040af94bd89ddcdda52aab7b396d,UIX/UIX FILES/Data Files/Textures/Tx_tbM_contain_dev2.bmp,by Star Boi,cc-by
1982619826
dbb939b8004b74b95fb3f988f41a9ddd,UIX/UIX FILES/Data Files/Textures/Tx_tbM_contain_dev3.bmp,by Star Boi,cc-by
19827-
abcb5503e2911e8128d83badec513c11,UIX/UIX FILES/Data Files/Textures/Tx_thatch_01.dds, ,
19827+
abcb5503e2911e8128d83badec513c11,UIX/UIX FILES/Data Files/Textures/Tx_thatch_01.dds,by Spyder,cc0
1982819828
771c70b7f0e51842dbacb81371325496,UIX/UIX FILES/Data Files/Textures/Tx_thatch_03.dds, ,
1982919829
440ea20cb8ff0cd1fdf405f3b6073566,UIX/UIX FILES/Data Files/Textures/TX_V_NEW_W_01.tga, ,
1983019830
109d91f81a9c9e1340b276555e8924ff,UIX/UIX FILES/Data Files/Textures/Tx_w_Silver_R.dds, ,
@@ -19838,7 +19838,7 @@ e119acd0a4773a73f355cc1deafc3f46,UIX/UIX FILES/Data Files/Textures/TX_Wall_Stucc
1983819838
2f3ffa53e1beec16b8f26e8a606e9570,UIX/UIX FILES/Data Files/Textures/tx_wood_6th_redtrim_01_alpha.dds, ,
1983919839
bbb4cc700aed8cb538bce72b542b466b,UIX/UIX FILES/Data Files/Textures/Tx_wood_barnacle_01.dds, ,
1984019840
ab638839d0d8a1329822c0b0ea780bfc,UIX/UIX FILES/Data Files/Textures/Tx_wood_barnacle_02.dds, ,
19841-
51ddb94a63da47b6bfe595df8e9f375f,UIX/UIX FILES/Data Files/Textures/Tx_wood_brown_posts_02.dds, ,
19841+
51ddb94a63da47b6bfe595df8e9f375f,UIX/UIX FILES/Data Files/Textures/Tx_wood_brown_posts_02.dds,by Spyder,CC0
1984219842
6379665d183889c3a8e9f15706ea9808,UIX/UIX FILES/Data Files/Textures/Tx_wood_brown_posts_03.dds, ,
1984319843
cff163b519375462fcb42793c191cf19,UIX/UIX FILES/Data Files/Textures/Tx_wood_brown_posts_04.dds, ,
1984419844
4f83b70cbf107e1b3ca35307be1d6fad,UIX/UIX FILES/Data Files/Textures/Tx_wood_brown_rings_01.dds, ,

make_release.py

Lines changed: 138 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/env python3
22
import csv
33
import glob
4+
from multiprocessing import Process, Queue, current_process
45
from nif_walker import walk_nif
56
import os
67
import sys
@@ -36,79 +37,140 @@ def find_match(ap, rap):
3637
return False
3738

3839

39-
with open("Manifests/UIXR.manifest") as f:
40-
uixr_data = csv.DictReader(f)
41-
tar_ball = tarfile.open(RELEASE_PATH, "w:")
40+
def retrieve_assets_from_nif(nif_path):
41+
# check that we have all related assets
42+
assets = []
43+
nif_assets = walk_nif(nif_path=nif_path, use_stdout=False)
44+
for asset_string in nif_assets:
45+
for asset_name in asset_string.split(', '):
46+
assets.append(get_filename(asset_name).lower())
47+
return assets
48+
49+
50+
def worker(work_queue, done_queue):
4251
spinner = spinning_cursor()
43-
manifest = []
44-
additional_assets = []
45-
print("Gathering assets: ")
46-
for row in uixr_data:
47-
row_license = row.get('license').lower()
48-
if row_license == 'cc0' or row_license == 'cc-by' or row_license == 'cc-by-nc':
49-
sys.stdout.write("\033[K")
50-
sys.stdout.write(next(spinner))
51-
sys.stdout.write(" [{0}]".format(row.get('asset')))
52-
sys.stdout.flush()
53-
sys.stdout.write('\r\b')
54-
file_path = os.path.join(ASSET_PATH, row.get('asset'))
55-
if not os.path.exists(file_path):
56-
print("WARNING: asset not found -> {0}".format(row.get('asset')))
57-
continue
58-
59-
manifest.append(row.get('asset'))
60-
tar_ball.add(file_path, row.get('asset'))
61-
62-
# check that we have all related assets
63-
nif_assets = walk_nif(nif_path=file_path, use_stdout=False)
64-
for asset_string in nif_assets:
65-
for asset in asset_string.split(', '):
66-
additional_assets.append(get_filename(asset).lower())
67-
68-
# remove duplicates
69-
additional_assets = set(additional_assets)
70-
71-
# remove blank entry in set
72-
if '' in additional_assets:
73-
additional_assets.remove('')
74-
75-
# remove files listed in manifest, we already have them
76-
for asset in manifest:
77-
filename = os.path.basename(asset).lower()
78-
if filename in additional_assets:
79-
additional_assets.remove(filename)
80-
81-
print("Gathering sub-assets: ")
82-
# iterate through all sub assets
83-
for nif_asset in additional_assets:
84-
found = False
85-
na_filename, _ = os.path.splitext(nif_asset.lower())
86-
na_filename += '.*'
87-
glob_path = os.path.join(ASSET_PATH, "UIX", "**", na_filename)
88-
for asset_path in insensitive_glob(glob_path, True):
89-
found = True
90-
relative_asset_path = os.path.relpath(os.path.realpath(asset_path), ASSET_PATH)
91-
if relative_asset_path in tar_ball.getnames():
92-
break # file already exists, skip
93-
sys.stdout.write("\033[K")
94-
sys.stdout.write(next(spinner))
95-
sys.stdout.write(" [{0}]".format(relative_asset_path))
96-
sys.stdout.flush()
97-
sys.stdout.write('\r\b')
98-
f.seek(0) # reset to beginning of csv file
99-
for row in uixr_data:
100-
if find_match(row.get('asset'), relative_asset_path):
101-
row_license = row.get('license').lower()
102-
if row_license == 'cc0':
103-
break # good to go, break
104-
elif row_license == 'cc-by':
105-
break # good to go, break
106-
elif row_license == 'cc-by-nc':
107-
break # good to go, break
108-
else:
109-
print("WARNING: Non-CC license asset -> {0}".format(relative_asset_path))
110-
found = False
111-
tar_ball.add(asset_path, relative_asset_path)
112-
if not found:
113-
print("WARNING: sub-asset not found -> {0}".format(nif_asset))
114-
tar_ball.close()
52+
p = current_process()
53+
for nif_path in iter(work_queue.get, 'STOP'):
54+
sys.stdout.write("\033[K")
55+
sys.stdout.write(next(spinner))
56+
sys.stdout.write(" [{0}][{1}][{2}]".format(work_queue.qsize(), p.name, nif_path))
57+
sys.stdout.flush()
58+
sys.stdout.write('\r\b')
59+
assets = []
60+
try:
61+
# assets.append('DEADBEEF')
62+
assets = retrieve_assets_from_nif(nif_path)
63+
except Exception:
64+
pass
65+
done_queue.put((p.name, nif_path, assets))
66+
done_queue.put('STOP')
67+
print("{} finished.".format(p.name))
68+
return True
69+
70+
71+
def main():
72+
with open("Manifests/UIXR.manifest") as f:
73+
uixr_data = csv.DictReader(f)
74+
tar_ball = tarfile.open(RELEASE_PATH, "w:")
75+
spinner = spinning_cursor()
76+
manifest = []
77+
additional_assets = []
78+
79+
# setup multi-processing job
80+
workers = 8
81+
processes = []
82+
work_queue = Queue()
83+
done_queue = Queue()
84+
85+
print("Gathering assets: ")
86+
for row in uixr_data:
87+
row_license = row.get('license').lower()
88+
if row_license == 'cc0' or row_license == 'cc-by' or row_license == 'cc-by-nc':
89+
sys.stdout.write("\033[K")
90+
sys.stdout.write(next(spinner))
91+
sys.stdout.write(" [{0}]".format(row.get('asset')))
92+
sys.stdout.flush()
93+
sys.stdout.write('\r\b')
94+
file_path = os.path.join(ASSET_PATH, row.get('asset'))
95+
if not os.path.exists(file_path):
96+
print("WARNING: asset not found -> {0}".format(row.get('asset')))
97+
continue
98+
manifest.append(row.get('asset'))
99+
tar_ball.add(file_path, row.get('asset'))
100+
101+
work_queue.put(file_path)
102+
103+
# let multiprocessing parse the nifs
104+
print("Parsing NIFs for additional sub-assets: ")
105+
for i in range(workers):
106+
p = Process(target=worker, args=(work_queue, done_queue))
107+
processes.append(p)
108+
work_queue.put('STOP')
109+
p.start()
110+
111+
print("Building assets to validate.")
112+
stops = 0
113+
while True:
114+
item = done_queue.get()
115+
if isinstance(item, str) and item == 'STOP':
116+
stops += 1
117+
if stops == workers:
118+
break
119+
else:
120+
# for worker_name, nif_name, nif_assets in iter(done_queue.get, 'STOP'):
121+
_, _, nif_assets = item
122+
additional_assets += nif_assets
123+
124+
print("Filtering assets.")
125+
# remove duplicates
126+
additional_assets = set(additional_assets)
127+
128+
# remove blank entry in set
129+
if '' in additional_assets:
130+
additional_assets.remove('')
131+
132+
# remove files listed in manifest, we already have them
133+
for asset in manifest:
134+
filename = os.path.basename(asset).lower()
135+
if filename in additional_assets:
136+
additional_assets.remove(filename)
137+
138+
print("Gathering sub-assets: ")
139+
# iterate through all sub assets
140+
for nif_asset in additional_assets:
141+
found = False
142+
na_filename, _ = os.path.splitext(nif_asset.lower())
143+
na_filename += '.*'
144+
glob_path = os.path.join(ASSET_PATH, "UIX", "**", na_filename)
145+
for asset_path in insensitive_glob(glob_path, True):
146+
found = True
147+
relative_asset_path = os.path.relpath(os.path.realpath(asset_path), ASSET_PATH)
148+
if relative_asset_path in tar_ball.getnames():
149+
break # file already exists, skip
150+
sys.stdout.write("\033[K")
151+
sys.stdout.write(next(spinner))
152+
sys.stdout.write(" [{0}]".format(relative_asset_path))
153+
sys.stdout.flush()
154+
sys.stdout.write('\r\b')
155+
f.seek(0) # reset to beginning of csv file
156+
for row in uixr_data:
157+
if find_match(row.get('asset'), relative_asset_path):
158+
row_license = row.get('license').lower()
159+
if row_license == 'cc0':
160+
break # good to go, break
161+
elif row_license == 'cc-by':
162+
break # good to go, break
163+
elif row_license == 'cc-by-nc':
164+
break # good to go, break
165+
else:
166+
print("WARNING: Non-CC license asset -> {0}".format(relative_asset_path))
167+
found = False
168+
tar_ball.add(asset_path, relative_asset_path)
169+
if not found:
170+
print("WARNING: sub-asset not found -> {0}".format(nif_asset))
171+
172+
tar_ball.close()
173+
174+
175+
if __name__ == "__main__":
176+
main()

utils.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
# create screnshots of NIFs with nifskope
4+
find . -iname "*.nif" | while read f;
5+
do
6+
echo ${f};
7+
DIR=album/$(dirname "${f}")
8+
echo ${DIR}
9+
mkdir -p "$DIR" # create directories
10+
nifskope "${f}"& sleep 3; # open nifskope with NIF
11+
wmctrl -c nifskope; sleep 2; # close the PNG ICCC warning window
12+
wmctrl -a nifskope; # raise nifskope to top
13+
gnome-screenshot -w -d 1 -f "album/${f}.png" # screenshot top window
14+
wmctrl -c nifskope; wmctrl -c nifskope; # close any open nifskope windows
15+
done
16+
17+
# find any screenshots that are incorrect and try to retake them
18+
find ./album -name '*.png' -exec file {} \; | sed 's/\(.*png\): .* \([0-9]* x [0-9]*\).*/\2 \1/' | awk 'int($1) == 1202 {print}' | while read f;
19+
do
20+
f=${f:19:-4}
21+
echo ${f};
22+
DIR=album/$(dirname "${f}")
23+
echo ${DIR}
24+
mkdir -p "$DIR"
25+
nifskope "${f}"& sleep 3;
26+
wmctrl -c nifskope; sleep 2;
27+
wmctrl -a nifskope;
28+
gnome-screenshot -w -d 1 -f "album/${f}.png"
29+
wmctrl -c nifskope; wmctrl -c nifskope;
30+
done
31+

0 commit comments

Comments
 (0)