diff -r 7685cec9fd3c -r f2ddfa555b0f doc/api/python/flash_config-pysrc.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/api/python/flash_config-pysrc.html Fri Sep 11 11:54:49 2009 +0100
@@ -0,0 +1,506 @@
+
+
+
+
+ flash_config
+
+
+
+
+
+
+
+
+
+
+
+ Module flash_config
+
+
+
+
+
+
+
+
+
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20 """ This modules implements flash configuration writer.
+ 21 """
+ 22 import logging
+ 23 import os
+ 24 import re
+ 25 import rom
+ 26 import types
+ 27 import imaker
+ 28
+ 29
+ 30
+ 31
+ 32 logger = logging . getLogger ( "flash_config" )
+ 33
+
35 """ Local storage of image type
+
36 """
+
37
+
39 """ init from config
+
40 """
+
41 config [ 'image.type' ] = '${image.type.temp}'
+
42 self . _type = type
+
43 self . _id = config [ type + '.id' ]
+
44 self . _image_name = config [ type + '.image.name' ]
+
45 self . _image_path = config [ type + '.image.path' ]
+
46
+
48 """ Set the image type in a config
+
49 """
+
50 config [ self . _type + '.id' ] = self . _id
+
51 config [ self . _type + '.image.name' ] = self . _image_name
+
52 config [ self . _type + '.image.path' ] = self . _image_path
+
53
+
55 """ String representation the class
+
56 """
+
57 return self . _id + " " + self . _image_name + " " + self . _image_path
+
58
+
60 """ Builder that creates the flash configuration files
+
61 """
+
63 """ FlashConfigurationWriter init
+
64 """
+
65 self . _configs = configs
+
66 self . _product = product
+
67 self . _all_languagepacks = { }
+
68 self . _all_udas = { }
+
69 self . _all_mms = { }
+
70 self . _all_mcs = { }
+
71
+
73 """ Collect all language packs and store them internally
+
74 """
+
75 self . _all_languagepacks = { }
+
76 for config in self . _configs . getConfigurations ( self . _product ) :
+
77 if ( config . type == "languagepack" ) :
+
78 lp = ImagePack ( config , 'languagepack' )
+
79 self . _all_languagepacks [ lp . _id ] = lp
+
80
+
82 """ Get language packs compatible with a customer variant
+
83 """
+
84 languagepack_list = [ ]
+
85 if config . has_key ( 'compatible.languagepack' ) :
+
86 lp_list = config [ 'compatible.languagepack' ]
+
87 if not isinstance ( lp_list , types . ListType ) :
+
88 lp_list = [ lp_list ]
+
89 for lp_id in lp_list :
+
90 if self . _all_languagepacks . has_key ( lp_id ) :
+
91 languagepack_list . append ( self . _all_languagepacks [ lp_id ] )
+
92 else :
+
93 print "Compatible languagepack " + str ( lp_id ) + " does not exists"
+
94 else :
+
95 languagepack_list = self . _all_languagepacks . values ( )
+
96
+
97 return languagepack_list
+
98
+
100 """ Collect all udas and store them internally
+
101 """
+
102 self . _all_udas = { }
+
103 for config in self . _configs . getConfigurations ( self . _product ) :
+
104 if ( config . type == "uda" ) :
+
105 lp = ImagePack ( config , 'uda' )
+
106 self . _all_udas [ lp . _id ] = lp
+
107
+
109 """ Collect all mm's and store them internally
+
110 """
+
111 self . _all_mms = { }
+
112 for config in self . _configs . getConfigurations ( self . _product ) :
+
113 if ( config . type == "massmemory" ) :
+
114 lp = ImagePack ( config , 'massmemory' )
+
115 self . _all_mms [ lp . _id ] = lp
+
116
+
118 """ Collect all mc's and store them internally
+
119 """
+
120 self . _all_mcs = { }
+
121 for config in self . _configs . getConfigurations ( self . _product ) :
+
122 if ( config . type == "memorycard" ) :
+
123 lp = ImagePack ( config , 'memorycard' )
+
124 self . _all_mcs [ lp . _id ] = lp
+
125
+
127 """ Get uda's compatible with a customer variant
+
128 """
+
129 uda_list = [ ]
+
130 if config . has_key ( 'compatible.uda' ) :
+
131 lp_list = config [ 'compatible.uda' ]
+
132 if not isinstance ( lp_list , types . ListType ) :
+
133 lp_list = [ lp_list ]
+
134 for lp_id in lp_list :
+
135 if self . _all_udas . has_key ( lp_id ) :
+
136 uda_list . append ( self . _all_udas [ lp_id ] )
+
137 else :
+
138 print "Compatible uda " + str ( lp_id ) + " does not exists"
+
139 else :
+
140 return None
+
141
+
142 return uda_list
+
143
+
145 """ Get mm's compatible with a customer variant
+
146 """
+
147 mm_list = [ ]
+
148 if config . has_key ( 'compatible.massmemory' ) :
+
149 lp_list = config [ 'compatible.massmemory' ]
+
150
+
151 if not isinstance ( lp_list , types . ListType ) :
+
152 lp_list = [ lp_list ]
+
153 for lp_id in lp_list :
+
154 if self . _all_mms . has_key ( lp_id ) :
+
155 mm_list . append ( self . _all_mms [ lp_id ] )
+
156 else :
+
157 print "Compatible massmemory " + str ( lp_id ) + " does not exists"
+
158 else :
+
159 return None
+
160
+
161 return mm_list
+
162
+
164 """ Get mc's compatible with a customer variant
+
165 """
+
166 mc_list = [ ]
+
167 if config . has_key ( 'compatible.memorycard' ) :
+
168 lp_list = config [ 'compatible.memorycard' ]
+
169 if not isinstance ( lp_list , types . ListType ) :
+
170 lp_list = [ lp_list ]
+
171 for lp_id in lp_list :
+
172 if self . _all_mcs . has_key ( lp_id ) :
+
173 mc_list . append ( self . _all_mcs [ lp_id ] )
+
174 else :
+
175 print "Compatible memorycard " + str ( lp_id ) + " does not exists"
+
176 else :
+
177 return None
+
178
+
179 return mc_list
+
180
+
181 - def _write_file ( self , config , romtype , uda , mm , mc ) :
+
182 """ Write an xml flash configuration file
+
183 """
+
184
+
185
+
186 template = rom . read_file_content ( config [ 'flash.config.template' ] )
+
187
+
188 if not uda :
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200 template = re . sub ( r".*<image type=\"uda\".*/>\n" , '' , template )
+
201
+
202 if not mm :
+
203 template = re . sub ( r".*<image type=\"massmemory\".*/>\n" , '' , template )
+
204 if not mc :
+
205 template = re . sub ( r".*<image type=\"memorycard\".*/>\n" , '' , template )
+
206
+
207 if not os . path . exists ( config [ 'flash.config.publish.dir' ] ) :
+
208 print "Creating " + config [ 'flash.config.publish.dir' ]
+
209 os . makedirs ( config [ 'flash.config.publish.dir' ] )
+
210
+
211 fp = open ( os . path . join ( config [ 'flash.config.publish.dir' ] , config [ 'flash.config.name' ] ) , 'w' )
+
212 print "Writing file " + fp . name
+
213 fp . write ( rom . escape_string ( template , config ) )
+
214 fp . close ( )
+
215
+
221
+
223 """ Go throught the config and creates the flash configuration files
+
224 """
+
225
+
226
+
227 self . _get_all_languagepacks ( )
+
228 self . _get_all_udas ( )
+
229 self . _get_all_mcs ( )
+
230 self . _get_all_mms ( )
+
231 self . _makefile_content = ""
+
232 self . _targets = "flash_config: "
+
233
+
234
+
235 for config in self . _configs . getConfigurations ( self . _product ) :
+
236 if ( config . type == "customer" ) or ( config . type == "operator" ) :
+
237 image_types = config [ 'image.type' ]
+
238 if not isinstance ( config [ 'image.type' ] , types . ListType ) :
+
239 image_types = [ config [ 'image.type' ] ]
+
240
+
241 for lp in self . _get_compatible_languagepacks ( config ) :
+
242 lp . set_config ( config )
+
243 config [ 'image.type.temp' ] = '${image.type}'
+
244
+
245 enable_uda = True
+
246 enable_mm = True
+
247 enable_mc = True
+
248 compatible_uda = self . _get_compatible_udas ( config )
+
249 compatible_mm = self . _get_compatible_mms ( config )
+
250 compatible_mc = self . _get_compatible_mcs ( config )
+
251
+
252 if compatible_uda == None :
+
253 enable_uda = False
+
254 compatible_uda = [ None ]
+
255 if compatible_mm == None :
+
256 enable_mm = False
+
257 compatible_mm = [ None ]
+
258 if compatible_mc == None :
+
259 enable_mc = False
+
260 compatible_mc = [ None ]
+
261
+
262 for uda in compatible_uda :
+
263 if uda :
+
264 uda . set_config ( config )
+
265 for mm in compatible_mm :
+
266 if mm :
+
267 mm . set_config ( config )
+
268 for mc in compatible_mc :
+
269 if mc :
+
270 mc . set_config ( config )
+
271 for romtype in image_types :
+
272 config [ 'image.type' ] = romtype
+
273 self . _write_file ( config , romtype , enable_uda , enable_mm , enable_mc )
+
274 self . _append_to_makefile ( config , romtype )
+
275
+
276 if self . _makefile_content == "" :
+
277 logger . warning ( "No customer's or operator's found in rom config" )
+
278
+
279
+
280 makefile_filename = "%s/mc_flash_config.mk" % imaker . get_product_dir ( self . _product )
+
281 print "Writing makfile " + makefile_filename
+
282 fp = open ( makefile_filename , 'w' )
+
283 fp . write ( "include $(E32ROMCFG)/helium_features.mk\n" )
+
284 fp . write ( self . _makefile_content )
+
285 fp . write ( self . _targets )
+
286 fp . close ( )
+
287
+
+
+
+
+
+
+
+
+
+