Changeset 74 for trunk/pxeconfig
- Timestamp:
- 03/27/07 21:50:22 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/pxeconfig
r60 r74 65 65 import getopt 66 66 import socket 67 import ConfigParser 67 68 68 69 # DEBUG … … 83 84 SHORTOPT_LIST='hVd:n:s:e:f:ri' 84 85 LONGOPT_LIST=['help', 'version', 'directory=', 'net=', 'start=', 'end=', 'file=', 'remove', 'debug' , 'interactive' ] 86 87 def ReadConfig(file, name): 88 """ 89 Parse the config file 90 """ 91 if not os.path.isfile(file): 92 print 'File %s does not exist' %file 93 sys.exit(1) 94 95 config = ConfigParser.ConfigParser() 96 try: 97 config.read(file) 98 except ConfigParser.MissingSectionHeaderError,detail: 99 print detail 100 sys.exit(1) 101 102 # Use given project name else use defaults 103 # 104 if name: 105 if not config.has_section(name): 106 print "Not a valid project name: %s" %name 107 print "Valid names: %s" %config.sections() 108 sys.exit(1) 109 110 project = dict() 111 for option in config.options(name): 112 project[option] = config.get(name, option) 113 else: 114 project = config.defaults() 115 116 return project 85 117 86 118 def select_pxe_configfile(): … … 327 359 bootinfo[REMOVE] = 0 328 360 361 project_name = None 362 configfile = 'pxeconfig.conf' 363 settings = ReadConfig(configfile, project_name) 364 print settings 365 sys.exit(1) 329 366 hostnames = check_args(sys.argv, bootinfo) 330 367
Note: See TracChangeset
for help on using the changeset viewer.