summaryrefslogtreecommitdiff
path: root/utils/nwztools/database/gen_db.py
diff options
context:
space:
mode:
authorIgor Skochinsky <skochinsky@gmail.com>2017-04-03 15:13:46 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2017-04-25 11:24:24 +1000
commit03dd4b92be7dcd5c8ab06da3810887060e06abd5 (patch)
treed18b5e7748a08f75891e832e1687154490fd5b36 /utils/nwztools/database/gen_db.py
parentf1c8d63a762acdcb29f30d17617e531fdb555af4 (diff)
downloadrockbox-03dd4b92be7dcd5c8ab06da3810887060e06abd5.tar.gz
rockbox-03dd4b92be7dcd5c8ab06da3810887060e06abd5.zip
nwztools/database: misc improvements
* make gen_db.py work on Windows/Python 2 - use hashlib module instead of md5sum, also don't rely on / for file path matching - don't use 'file' for a variable name * fix parse_nvp_header.sh for older kernels pre-emmc kernel sources use a slightly different #define format; adjust regexp to catch it. * add nwz-x1000 series NVP layout (from icx1087_nvp.h) some new tags have no description, alas the driver doesn't have them :/ * minor fixes to nvp/README fixed typos/wording Change-Id: I77d8c2704be2f2316e32aadcfd362df7102360d4
Diffstat (limited to 'utils/nwztools/database/gen_db.py')
-rwxr-xr-xutils/nwztools/database/gen_db.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/utils/nwztools/database/gen_db.py b/utils/nwztools/database/gen_db.py
index 8b7d1cbaaf..de78d05cab 100755
--- a/utils/nwztools/database/gen_db.py
+++ b/utils/nwztools/database/gen_db.py
@@ -3,6 +3,7 @@ import glob
3import os 3import os
4import re 4import re
5import subprocess 5import subprocess
6import hashlib
6 7
7# parse models.txt 8# parse models.txt
8g_models = [] 9g_models = []
@@ -35,14 +36,14 @@ g_hash_nvp = dict() # hash -> nvp
35g_nvp_hash = dict() # codename -> hash 36g_nvp_hash = dict() # codename -> hash
36HASH_SIZE=6 37HASH_SIZE=6
37map_files = glob.glob('nvp/nw*.txt') 38map_files = glob.glob('nvp/nw*.txt')
38for line in subprocess.run(["md5sum"] + map_files, stdout = subprocess.PIPE).stdout.decode("utf-8").split("\n"): 39for f in map_files:
39 if len(line.rstrip()) == 0: 40 h = hashlib.md5()
40 continue 41 h.update(open(f, "rb").read())
41 hash, file = line.rstrip().split() 42 hash = h.hexdigest()
42 codename = re.search('nvp/(.*)\.txt', file).group(1) 43 codename = re.search('(nw.*)\.txt', f).group(1)
43 # sanity check 44 # sanity check
44 if not (codename in g_series_codename): 45 if not (codename in g_series_codename):
45 print("Warning: file %s does not have a match series in series.txt" % file) 46 print("Warning: file %s does not have a match series in series.txt" % f)
46 hash = hash[:HASH_SIZE] 47 hash = hash[:HASH_SIZE]
47 # only keep one file 48 # only keep one file
48 if not (hash in g_hash_nvp): 49 if not (hash in g_hash_nvp):