Changeset 485 for trunk/email2trac.py.in
- Timestamp:
- 10/06/10 15:18:04 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/email2trac.py.in
r484 r485 2066 2066 sys.exit(1) 2067 2067 2068 config = trac_config.Configuration(file) 2069 2070 ## Use given project name else use defaults 2071 # 2068 config = trac_config.Configuration(file) 2069 2070 parentdir = config.get('DEFAULT', 'parentdir') 2071 sections = config.sections() 2072 2073 ## use some trac internals to get the defaults 2074 # 2075 tmp = config.parser.defaults() 2076 project = SaraDict() 2077 2078 for option, value in tmp.items(): 2079 try: 2080 project[option] = int(value) 2081 except ValueError: 2082 project[option] = value 2083 2072 2084 if name: 2073 sections = config.sections() 2074 if not name in sections: 2075 print "Not a valid project name: %s" %name 2076 print "Valid names: %s" %sections 2085 if name in sections: 2086 project = SaraDict() 2087 for option, value in config.options(name): 2088 try: 2089 project[option] = int(value) 2090 except ValueError: 2091 project[option] = value 2092 2093 elif not parentdir: 2094 print "Not a valid project name: %s, valid names are: %s" %(name, sections) 2095 print "or set parentdir in the [DEFAULT] section" 2077 2096 sys.exit(1) 2078 2097 2079 project = SaraDict() 2080 for option, value in config.options(name): 2081 try: 2082 project[option] = int(value) 2083 except ValueError: 2084 project[option] = value 2085 2086 else: 2087 ## use some trac internals to get the defaults 2088 # 2089 tmp = config.parser.defaults() 2090 project = SaraDict() 2091 2092 for option, value in tmp.items(): 2093 try: 2094 project[option] = int(value) 2095 except ValueError: 2096 project[option] = value 2098 ## If parentdir the set project dir to parentdir + name 2099 # 2100 if not project.has_key('project'): 2101 if not parentdir: 2102 print "You must set project or parentdir in your configuration file" 2103 sys.exit(1) 2104 elif not name: 2105 print "You must set project in your configuration file" 2106 else: 2107 project['project'] = os.path.join(parentdir, name) 2097 2108 2098 2109 return project … … 2302 2313 logger.debug('Loading environment %s', settings.project) 2303 2314 2304 env = Environment(settings['project'], create=0) 2315 try: 2316 env = Environment(settings['project'], create=0) 2317 except IOError, detail: 2318 print "Trac project does not exists: %s" %(settings['project']) 2319 sys.exit(1) 2305 2320 2306 2321 tktparser = TicketEmailParser(env, settings, logger, float(version))
Note: See TracChangeset
for help on using the changeset viewer.