Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: scripts/newbitmaps/make_bmp_from_components.py

Issue 6623008: Don't modify fv old-style bitmaps (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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:
Jay Kim 2011/03/06 23:49:56 Adding a condition to check if it is old style bit
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()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698