OLD | NEW |
1 #!/usr/bin/python2.6 | 1 #!/usr/bin/python2.6 |
2 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # Call on a directory with components_XXX_XXX files, to create | 6 # Call on a directory with components_XXX_XXX files, to create |
7 # bitmaps with the appropriate names and contents. | 7 # bitmaps with the appropriate names and contents. |
8 | 8 |
9 import sys | 9 import sys |
10 import glob | 10 import glob |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 os.system("pushd %s >/dev/null; bmpblk_utility -c %s %s; popd >/dev/null" % ( | 42 os.system("pushd %s >/dev/null; bmpblk_utility -c %s %s; popd >/dev/null" % ( |
43 imagedir, newyamlfile, outputbmp)) | 43 imagedir, newyamlfile, outputbmp)) |
44 os.system("rm -rf %s" % tmpdir) | 44 os.system("rm -rf %s" % tmpdir) |
45 | 45 |
46 def ProcessDir(directory): | 46 def ProcessDir(directory): |
47 """ Find all the components file in this dir. """ | 47 """ Find all the components file in this dir. """ |
48 # Regex to find the values we want. | 48 # Regex to find the values we want. |
49 re_bmp = re.compile(r'\'data_bitmap_fv\': \[\'(?P<bmp>.*)\'\],') | 49 re_bmp = re.compile(r'\'data_bitmap_fv\': \[\'(?P<bmp>.*)\'\],') |
50 re_hwid = re.compile(r'\'part_id_hwqual\': \[\'(?P<hwid>.*)\'\],') | 50 re_hwid = re.compile(r'\'part_id_hwqual\': \[\'(?P<hwid>.*)\'\],') |
51 re_geom = re.compile(r'\'data_display_geometry\': \[\'(?P<geom>.*)\'\],') | 51 re_geom = re.compile(r'\'data_display_geometry\': \[\'(?P<geom>.*)\'\],') |
| 52 # Old bitmap style |
| 53 re_fv = re.compile(r'.*\.fv') |
52 | 54 |
53 # Find the components files. | 55 # Find the components files. |
54 files = glob.glob(os.path.join(directory, "data_*/components_*")) | 56 files = glob.glob(os.path.join(directory, "data_*/components_*")) |
55 for file in files: | 57 for file in files: |
56 # Scan for the values. | 58 # Scan for the values. |
57 f = open(file, "r") | 59 f = open(file, "r") |
58 bmp = None | 60 bmp = None |
59 hwid = None | 61 hwid = None |
60 geom = None | 62 geom = None |
61 for line in f.readlines(): | 63 for line in f.readlines(): |
62 m = re_bmp.search(line) | 64 m = re_bmp.search(line) |
63 if m: | 65 if m: |
64 bmp = m.group('bmp') | 66 bmp = m.group('bmp') |
65 | 67 |
66 m = re_hwid.search(line) | 68 m = re_hwid.search(line) |
67 if m: | 69 if m: |
68 hwid = m.group('hwid') | 70 hwid = m.group('hwid') |
69 | 71 |
70 m = re_geom.search(line) | 72 m = re_geom.search(line) |
71 if m: | 73 if m: |
72 geom = m.group('geom') | 74 geom = m.group('geom') |
73 f.close() | 75 f.close() |
74 if not ( bmp and hwid and geom): | 76 if not ( bmp and hwid and geom): |
75 print "Corrupt HWID configuration" | 77 print "Corrupt HWID configuration" |
76 sys.exit(1) | 78 sys.exit(1) |
77 print "HWID: %s, %s, %s" % (hwid, geom, bmp) | 79 if re_fv.match(bmp): |
78 MakeBmp(hwid, geom, bmp, directory) | 80 print "HWID: %s, %s, %s (skipping old style bitmap)" % (hwid, geom, bmp) |
| 81 else: |
| 82 print "HWID: %s, %s, %s" % (hwid, geom, bmp) |
| 83 MakeBmp(hwid, geom, bmp, directory) |
79 | 84 |
80 def main(): | 85 def main(): |
81 directory = os.path.abspath(sys.argv[1]) | 86 directory = os.path.abspath(sys.argv[1]) |
82 print "Generating HWID bmp based on %s" % directory | 87 print "Generating HWID bmp based on %s" % directory |
83 ProcessDir(directory) | 88 ProcessDir(directory) |
84 | 89 |
85 if __name__ == '__main__': | 90 if __name__ == '__main__': |
86 main() | 91 main() |
OLD | NEW |