Changeset 69 for emailtotracscript/trunk
- Timestamp:
- 05/16/06 11:45:16 (18 years ago)
- Location:
- emailtotracscript/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
emailtotracscript/trunk/ChangeLog
r68 r69 11 11 - Some modules are changed for version 0.10, Added and made some 12 12 minor changes: Patch supplied by: Markus Tacker 13 - Ported delete_spam.py to version 0.9 and higher: 14 Reported by: Nathaniel Irons 13 15 14 16 -
emailtotracscript/trunk/debian/changelog
r66 r69 1 email2trac (0.6.0-1) stable; urgency=low 2 3 * New Version 0.6 4 5 -- root <bas@sara.nl> Tue, 16 May 2006 11:14:11 +0200 6 1 7 email2trac (0.5.7-1) stable; urgency=low 2 8 -
emailtotracscript/trunk/delete_spam.py.in
r55 r69 26 26 27 27 Usage : 28 delete_spam [ -f <configfile>]28 delete_spam [ -f/--file <configfile> -p/--project <name>] 29 29 30 30 defaults: … … 34 34 $Id$ 35 35 """ 36 from trac import Environment, Ticket37 36 38 37 import os … … 42 41 import ConfigParser 43 42 44 def ReadConfig(file): 43 trac_default_version = 0.9 44 45 def ReadConfig(file, name): 45 46 """ 46 47 Parse the config file … … 52 53 53 54 config = ConfigParser.ConfigParser() 55 try: 56 config.read(file) 57 except ConfigParser.MissingSectionHeaderError,detail: 58 print detail 59 sys.exit(1) 54 60 55 try: 56 config.read(file) 57 except ConfigParser.MissingSectionHeaderError,detail: 58 print detail 59 sys.exit(1) 61 # Use given project name else use defaults 62 # 63 if name: 64 if not config.has_section(name): 65 print "Not an valid project name: %s" %name 66 print "Valid names: %s" %config.sections() 67 sys.exit(1) 60 68 61 defaults = config.defaults() 62 if not defaults.has_key('project'): 63 print 'You have define the location of your trac project, eg:' 64 print '\t project: /var/trac/<projectname>' 65 sys.exit(1) 66 67 return defaults 69 project = dict() 70 for option in config.options(name): 71 project[option] = config.get(name, option) 68 72 73 else: 74 project = config.defaults() 75 76 return project 69 77 70 78 def delete_spam(project, debug): 71 env = Environment .Environment(project, create=0)79 env = Environment(project, create=0) 72 80 db = env.get_db_cnx() 73 81 … … 98 106 # Default config file 99 107 # 100 configfile = ' /etc/email2trac.conf'108 configfile = '@email2trac_conf@' 101 109 102 110 try: 103 opts, args = getopt.getopt(sys.argv[1:], 'hf: ', ['help', 'file='])111 opts, args = getopt.getopt(sys.argv[1:], 'hf:p:', ['help', 'file=', 'project=']) 104 112 except getopt.error,detail: 105 113 print __doc__ … … 107 115 sys.exit(1) 108 116 117 project_name = None 109 118 for opt,value in opts: 110 119 if opt in [ '-h', '--help']: … … 113 122 elif opt in ['-f', '--file']: 114 123 configfile = value 124 elif opt in ['-p', '--project']: 125 project_name = value 115 126 116 settings = ReadConfig(configfile) 127 settings = ReadConfig(configfile, project_name) 128 if not settings.has_key('project'): 129 print __doc__ 130 print 'No project defined in config file, eg:\n\t project: /data/trac/bas' 131 sys.exit(1) 132 133 if settings.has_key('trac_version'): 134 version = float(settings['trac_version']) 135 else: 136 version = trac_default_version 137 138 139 if version == 0.8: 140 from trac.Environment import Environment 141 else: 142 from trac.env import Environment 143 117 144 delete_spam(settings['project'], int(settings['debug'])) 118 145 print 'Spam is deleted succesfully..'
Note: See TracChangeset
for help on using the changeset viewer.