Changeset 3640

Show
Ignore:
Timestamp:
05/08/08 08:52:18 (8 months ago)
Author:
retracile
Message:

AdvancedTicketWorkflowPlugin: Redesign run_external to be safer and more useful. Bump version to 0.5

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • advancedticketworkflowplugin/0.11/advancedworkflow/controller.py

    r3632 r3640  
    33""" 
    44 
    5 from subprocess import call 
     5import os 
     6from subprocess import check_call, CalledProcessError 
    67from genshi.builder import tag 
    78 
     
    248249    to doing its thing.  If the script exits with a non-zero return code, an 
    249250    error will be logged to the Trac log. 
     251    The plugin will look for a script named <tracenv>/hooks/<someaction>, and 
     252    will pass it 2 parameters: the ticket number, and the user. 
    250253 
    251254    <someaction>.operations = run_external 
    252     <someaction>.run_external = echo "blah blah blah" >> /var/log/blah 
    253     <someaction>.run_external_hint = Clue the user in. 
     255    <someaction>.run_external = Hint for the user 
    254256 
    255257    Don't forget to add the `TicketWorkflowOpRunExternal` to the workflow 
     
    281283        label = actions[action]['name'] 
    282284        hint = self.config.get('ticket-workflow', 
    283                                action + '.run_external_hint').strip() 
     285                               action + '.run_external').strip() 
    284286        if hint is None: 
    285287            hint = "Will run external script." 
     
    292294    def apply_action_side_effects(self, req, ticket, action): 
    293295        """Run the external script""" 
    294         script = self.config.get('ticket-workflow', 
    295                                 action + '.run_external').strip() 
    296         retval = call(script, shell=True) 
    297         if retval: 
    298             self.env.log.error("External script %r exited with %s." % (script, 
    299                                                                        retval)) 
     296        script = os.path.join(self.env.path, 'hooks', action) 
     297        try: 
     298            check_call([script, str(ticket.id), req.authname]) 
     299        except (CalledProcessError, OSError), e: 
     300            self.env.log.error("External script %r exited: %s." % (script, e)) 
  • advancedticketworkflowplugin/0.11/setup.py

    r3632 r3640  
    55setup(   
    66        name='AdvancedTicketWorkflowPlugin', 
    7         version='0.4', 
     7        version='0.5', 
    88        author = 'Eli Carter', 
    99        author_email = 'elicarter@retracile.net',