Changeset 645


Ignore:
Timestamp:
01/09/14 15:42:09 (10 years ago)
Author:
bas
Message:

added bloodhoiund support, thanks to Gary Martin from wandisco, see #331

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/email2trac.py.in

    r644 r645  
    3939                -h,--help
    4040                -A, --agilo
     41                -B, --bloodhound_product
    4142                -d, --debug
    4243                -E, --virtualenv <path>
     
    893894        self.logger.debug("function update_ticket_fields")
    894895
     896        if self.parameters.bh_product:
     897            if 'product' in user_dict:
     898                if user_dict['product'] != ticket.env.product.prefix:
     899                    self.logging.warning("bloodhound products cannot be changed "
     900                                         "- ignoring")
     901                user_dict.pop('product')
     902
    895903        ## Check only permission model on ticket updates
    896904        #
     
    26832691    #
    26842692    agilo = False
     2693    bh_product = None
    26852694    configfile = '@email2trac_conf@'
    26862695    project = ''
     
    26922701    virtualenv = '@virtualenv@'
    26932702
    2694     SHORT_OPT = 'AcdE:hf:np:t:v'
    2695     LONG_OPT  =  ['agilo', 'component=', 'debug', 'dry-run', 'help', 'file=', 'project=', 'ticket_prefix=', 'virtualenv=', 'verbose']
     2703    SHORT_OPT = 'AB:cdE:hf:np:t:v'
     2704    LONG_OPT  =  ['agilo', 'bloodhound_product=', 'component=', 'debug',
     2705                  'dry-run', 'help', 'file=', 'project=', 'ticket_prefix=',
     2706                  'virtualenv=', 'verbose']
    26962707
    26972708    try:
     
    27092720        elif opt in ['-A', '--agilo']:
    27102721            agilo = True
     2722        elif opt in ['-B', '--bloodhound_product']:
     2723            bh_product = value
    27112724        elif opt in ['-c', '--component']:
    27122725            component = value
     
    27492762    settings.verbose = verbose
    27502763
     2764    if bh_product:
     2765        settings.bh_product = bh_product
     2766
    27512767    if not settings.debug and debug_interactive:
    27522768        settings.debug = debug_interactive
     
    28012817            from trac.web.href import Href
    28022818
     2819            try:
     2820                import pkg_resources
     2821                pkg = pkg_resources.get_distribution('BloodhoundMultiProduct')
     2822                bloodhound = pkg.version.split()[:2]
     2823            except pkg_resources.DistributionNotFound:
     2824                # assume no bloodhound
     2825                bloodhound = None
     2826
     2827            if bloodhound:
     2828                from multiproduct.env import Environment, ProductEnvironment
     2829                from multiproduct.ticket.web_ui import (ProductTicketModule
     2830                                                        as TicketModule)
     2831                logger.debug("Found Bloodhound Distribution")
     2832
     2833                if not settings.bh_product:
     2834                    print __doc__
     2835                    print 'No Bloodhound project defined (bh_project) in section:%s email2trac config file.' %(settings.project)
     2836                    sys.exit(1)
     2837
    28032838            if agilo:
    28042839
     
    28372872        try:
    28382873            env = Environment(settings['project'], create=0)
     2874
     2875            if bloodhound:
     2876                ## possibly overkill testing if the multiproduct schema is a
     2877                # new enough version
     2878                #
     2879                from multiproduct.env import MultiProductSystem
     2880                mps = MultiProductSystem(env)
     2881                if mps.get_version() > 4:
     2882                    try:
     2883                        env = ProductEnvironment(env, settings.bh_product, create=0)
     2884                    except LookupError:
     2885                        logger.error('%s is not a valid Bloodhound' %settings.bh_product)
     2886                        sys.exit(0)
     2887               
    28392888        except IOError, detail:
    28402889            logger.error("trac error: %s" %detail)
Note: See TracChangeset for help on using the changeset viewer.