Changeset 27fb3d6 in mainline
- Timestamp:
- 2009-01-21T15:23:36Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- be8b5d6
- Parents:
- 9a0367f
- Location:
- tools
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/config.py
r9a0367f r27fb3d6 35 35 import re 36 36 import commands 37 import snack37 import xtui 38 38 39 39 INPUT = sys.argv[1] … … 179 179 return ' ' 180 180 181 def subchoice(screen, name, choices ):181 def subchoice(screen, name, choices, default): 182 182 "Return choice of choices" 183 183 184 max len= 0185 for choicein choices:186 length = len( choice[0])187 if (length > max len):188 max len= length184 maxkey = 0 185 for key, val in choices: 186 length = len(key) 187 if (length > maxkey): 188 maxkey = length 189 189 190 190 options = [] 191 for choice in choices: 192 options.append(" %-*s %s " % (maxlen, choice[0], choice[1])) 193 194 retval = snack.ListboxChoiceWindow(screen, name, 'Choose value', options) 195 196 if (retval[0] == 'cancel'): 191 position = None 192 cnt = 0 193 for key, val in choices: 194 if ((default) and (key == default)): 195 position = cnt 196 197 options.append(" %-*s %s " % (maxkey, key, val)) 198 cnt += 1 199 200 (button, value) = xtui.choice_window(screen, name, 'Choose value', options, position) 201 202 if (button == 'cancel'): 197 203 return None 198 204 199 return choices[ retval[1]][0]205 return choices[value][0] 200 206 201 207 def check_choices(defaults, ask_names): 202 208 "Check whether all accessible variables have a default" 203 209 204 for row in ask_names: 205 varname = row[0] 206 cond = row[4] 207 210 for varname, vartype, name, choices, cond in ask_names: 208 211 if ((cond) and (not check_condition(cond, defaults, ask_names))): 209 212 continue … … 223 226 outf.write('#########################################\n\n') 224 227 225 for row in ask_names: 226 varname = row[0] 227 name = row[2] 228 cond = row[4] 229 228 for varname, vartype, name, choices, cond in ask_names: 230 229 if ((cond) and (not check_condition(cond, defaults, ask_names))): 231 230 continue … … 259 258 return 0 260 259 261 screen = snack.SnackScreen()260 screen = xtui.screen_init() 262 261 try: 263 262 selname = None … … 268 267 position = None 269 268 cnt = 0 270 for row in ask_names: 271 272 varname = row[0] 273 vartype = row[1] 274 name = row[2] 275 choices = row[3] 276 cond = row[4] 269 for varname, vartype, name, choices, cond in ask_names: 277 270 278 271 if ((cond) and (not check_condition(cond, defaults, ask_names))): … … 312 305 raise RuntimeError("Unknown variable type: %s" % vartype) 313 306 314 opt2row[cnt] = row307 opt2row[cnt] = (varname, vartype, name, choices) 315 308 316 309 cnt += 1 317 310 318 retval = snack.ListboxChoiceWindow(screen, 'HelenOS configuration', 'Choose configuration option', options, default =position)319 320 if ( retval[0]== 'cancel'):311 (button, value) = xtui.choice_window(screen, 'HelenOS configuration', 'Choose configuration option', options, position) 312 313 if (button == 'cancel'): 321 314 return 'Configuration canceled' 322 315 323 row = opt2row[retval[1]] 324 if (row == None): 325 raise RuntimeError("Error selecting value: %s" % retval[1]) 326 327 selname = row[0] 328 seltype = row[1] 329 name = row[2] 330 choices = row[3] 331 332 if (retval[0] == 'ok'): 316 if (not opt2row.has_key(value)): 317 raise RuntimeError("Error selecting value: %s" % value) 318 319 (selname, seltype, name, choices) = opt2row[value] 320 321 if (not defaults.has_key(selname)): 322 default = None 323 else: 324 default = defaults[selname] 325 326 if (button == 'done'): 333 327 if (check_choices(defaults, ask_names)): 334 328 break 335 329 else: 336 snack.ButtonChoiceWindow(screen, 'Error', 'Some options have still undefined values.', ['Ok']);330 xtui.error_dialog(screen, 'Error', 'Some options have still undefined values.') 337 331 continue 338 332 339 333 if (seltype == 'choice'): 340 defaults[selname] = subchoice(screen, name, choices )334 defaults[selname] = subchoice(screen, name, choices, default) 341 335 elif ((seltype == 'y/n') or (seltype == 'n/y')): 342 336 if (defaults[selname] == 'y'): … … 345 339 defaults[selname] = 'y' 346 340 finally: 347 screen.finish()341 xtui.screen_done(screen) 348 342 349 343 create_output(OUTPUT, defaults, ask_names)
Note:
See TracChangeset
for help on using the changeset viewer.