Changeset 632


Ignore:
Timestamp:
07/12/13 13:41:24 (11 years ago)
Author:
bas
Message:

Added virtual env support for delete_spam

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r623 r632  
     12.X.X
     2  * Also made delete_spam virtual env aware
     3    Fixed by: Bas van der Vlies
     4
    152.7.0
    26  * use self.env.get_read_db for trac version > 0.11. self.env.get_db_cnx is obsolete. TRAC
  • trunk/delete_spam.py.in

    r628 r632  
    4242import shutil
    4343import ConfigParser
    44 
    45 from trac import __version__ as trac_version
    4644
    4745def ReadConfig(file, name):
     
    122120    #
    123121    configfile = '@email2trac_conf@'
     122    virtualenv = '@virtualenv@'
     123
    124124
    125125
     
    148148            VERBOSE = True
    149149
     150
     151    if virtualenv and os.path.exists(virtualenv):
     152        activate_this = os.path.join(virtualenv, 'bin/activate_this.py')
     153        if os.path.exists(activate_this):
     154            execfile(activate_this, dict(__file__=activate_this))
     155
     156
     157    try:
     158        from trac import __version__ as trac_version
     159        from trac import config as trac_config
     160        from trac.env import Environment
     161        from trac.ticket import Ticket
     162        from trac import util
     163
     164    except ImportError, detail:
     165        print "Can not find a a valid trac installation, solutions could be:"
     166        print "\tset PYTHONPATH"
     167        print "\tuse the --virtualenv <dir> option"
     168        sys.exit(1)
     169
    150170    # Determine major trac version used to be in email2trac.conf
    151171    # Quick hack for 0.12
    152172    #
    153     version = '0.%s' %(trac_version.split('.')[1])
    154     if version.startswith('0.12'):
    155         version = '0.12'
     173    l = trac_version.split('.')
     174    version = '.'.join(l[0:2])
    156175
    157176    if VERBOSE:
     
    160179    ## We only support versions 0.11 and 0.12
    161180    #
    162     if not version in ['0.11', '0.12']:
     181    if not version in ['0.11', '0.12', '1.0', '1,1']:
    163182        print 'Trac version %s is not suported' %(version)
    164183
     
    172191    settings['VERBOSE'] = VERBOSE
    173192
    174     from trac.env import Environment
    175     from trac.ticket import Ticket
    176     from trac import util
    177 
    178 
    179 
    180193    new_delete_spam(settings)
    181194
Note: See TracChangeset for help on using the changeset viewer.