Changeset 18 for emailtotracscript/trunk
- Timestamp:
- 01/10/06 23:09:17 (17 years ago)
- Location:
- emailtotracscript/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
emailtotracscript/trunk/ChangeLog
r16 r18 1 2006-01-10 Bas van der Vlies <basv@sara.nl>: 2 * Removed project_root from source and config file 3 * Adjust code so we can use mulitple stanza's in config file, eg: 4 [bas] 5 project: /data/trac/bas 6 spam_level: 3 7 8 use option "-p|--project bas" to select the stanza 9 1 10 2006-01-04 Bas van der Vlies <basv@sara.nl>: 2 11 -
emailtotracscript/trunk/email2trac.conf
r7 r18 10 10 email_header: 1 11 11 trac_version: 0.9 12 13 [bas] 14 project: /data/trac/bas 15 spam_level: 1 -
emailtotracscript/trunk/email2trac.py
r10 r18 47 47 ---------- 48 48 * Create an config file: 49 [DEFAULT] # REQUIRED 50 project: /data/trac/test # REQUIRED 51 debug: 1 # OPTIONAL, if set print some DEBUG info 52 spam_level: 4 # OPTIONAL, if set check for SPAM mail 53 reply_address: 1 # OPTIONAL, if set then fill in ticket CC field 54 umask: 022 # OPTIONAL, if set then use this umask for creation of the attachments 55 mailto_link: 1 # OPTIONAL, if set then [mailto:<CC>] in description 56 trac_version: 0.8 # OPTIONAL, default is 0.9 49 [DEFAULT] # REQUIRED 50 project : /data/trac/test # REQUIRED 51 debug : 1 # OPTIONAL, if set print some DEBUG info 52 spam_level : 4 # OPTIONAL, if set check for SPAM mail 53 reply_address: 1 # OPTIONAL, if set then fill in ticket CC field 54 umask : 022 # OPTIONAL, if set then use this umask for creation of the attachments 55 mailto_link : 1 # OPTIONAL, if set then [mailto:<CC>] in description 56 trac_version : 0.8 # OPTIONAL, default is 0.9 57 58 [jouvin] # OPTIONAL project declaration, if set both fields necessary 59 project : /data/trac/jouvin # use -p|--project jouvin. 57 60 58 61 * default config file is : /etc/email2trac.conf … … 449 452 450 453 451 def ReadConfig(file ):454 def ReadConfig(file, name): 452 455 """ 453 456 Parse the config file … … 459 462 460 463 config = ConfigParser.ConfigParser() 461 462 464 try: 463 465 config.read(file) 464 466 except ConfigParser.MissingSectionHeaderError,detail: 465 print detail 466 sys.exit(1) 467 468 defaults = config.defaults() 469 if not defaults.has_key('project') and not defaults.has_key('project_root'): 470 print 'You have to define the location of your trac project' 471 print 'or the root of your projects, eg:' 472 print '\t project: /var/trac/<projectname>' 473 print '\t project_root: /var/trac' 474 sys.exit(1) 475 476 return defaults 477 467 print detail 468 sys.exit(1) 469 470 471 # Use given project name else use defaults 472 # 473 if name: 474 if not config.has_section(name): 475 print "Not an valid project name: %s" %name 476 print "Valid names: %s" %config.sections() 477 sys.exit(1) 478 479 project = dict() 480 for option in config.options(name): 481 project[option] = config.get(name, option) 482 483 else: 484 project = config.defaults() 485 486 return project 478 487 479 488 if __name__ == '__main__': … … 481 490 # 482 491 configfile = '/etc/email2trac.conf' 492 configfile = './email2trac.conf' 483 493 project = '' 484 494 component = '' … … 491 501 sys.exit(1) 492 502 503 project_name = None 493 504 for opt,value in opts: 494 505 if opt in [ '-h', '--help']: … … 500 511 configfile = value 501 512 elif opt in ['-p', '--project']: 502 project = value 503 504 settings = ReadConfig(configfile) 505 506 if not settings.has_key('project') and not project: 507 print 'You must specify a project either in configuration file' 508 print 'or with option --project' 513 project_name = value 514 515 settings = ReadConfig(configfile, project_name) 516 if not settings.has_key('project'): 517 print __doc__ 518 print 'No project defined in config file, eg:\n\t project: /data/trac/bas' 509 519 sys.exit(1) 510 511 if project:512 if settings.has_key('project_root') :513 settings['project'] = os.path.join(settings['project_root'], project)514 else:515 print 'You must specify a project root in configuration file'516 print 'in order to use option --project'517 sys.exit(1)518 else:519 if not re.search("/",settings['project']):520 if settings.has_key('project_root') :521 settings['project'] = os.path.join(settings['project_root'], settings['project'])522 else:523 print 'You must specify a project root in configuration file'524 print 'or specify the project full path'525 sys.exit(1)526 520 527 521 if component: … … 532 526 else: 533 527 version = trac_default_version 528 529 #debug HvB 530 #print settings 534 531 535 532 if version > 0.8:
Note: See TracChangeset
for help on using the changeset viewer.