#5703 Develop pattern for making scripts run as tasks too

v1.0.0
closed
General
2015-08-20
2013-01-28
No

Would be nice to have a repeatable pattern for running something as either a paster script or as a task. Then with [#5658] a site admin could run a task and not need to have shell access.

Related

Tickets: #5658

Discussion

  • Dave Brondsema

    Dave Brondsema - 2013-01-28
    • milestone: forge-feb-22 --> forge-feb-08
     
  • Dave Brondsema

    Dave Brondsema - 2013-01-28
    • size: --> 2
     
  • Dave Brondsema

    Dave Brondsema - 2013-01-28
    • labels: --> admintasks
     
    • status: open --> in-progress
    • assigned_to: Tim Van Steenburgh
     
  • Dave Brondsema

    Dave Brondsema - 2013-02-08
    • Milestone: forge-feb-08 --> forge-feb-22
     
    • status: in-progress --> code-review
     
  • forge:tv/5703

    As a test, I converted the refresh-all-repos.py script to use the new pattern. You can run:

    paster script production.ini allura/scripts/refreshrepo.py -- [options]
    

    to execute it as a cmd-line script.

    To run it as a task:

    from allura.scripts.refreshrepo import RefreshRepo
    RefreshRepo.post([options])
    
     
  • Dave Brondsema

    Dave Brondsema - 2013-02-12
    • qa: Dave Brondsema
     
  • Dave Brondsema

    Dave Brondsema - 2013-02-12

    Explore making the task callable and not using a pickle or dispatcher.

    @task
    class MyScriptTask(ScriptTask):
        def __call__(arg, arg, arg, ...):
            pass
    

    Bonus points for setting __doc__ to the arg parse usage help.

    Specific changes for refresh repos:

    • drop clean-all, too dangerous
    • need to remove close_all since it causes an error at Allura/allura/model/monq_model.py", line 248, in __call__ session(self).flush(self) AttributeError: 'NoneType' object has no attribute 'flush'
    • can remove the old version of the script probably. Or keep it but have it just import and run the script task?
     
  • Dave Brondsema

    Dave Brondsema - 2013-02-12
    • status: code-review --> in-progress
     
    • status: in-progress --> code-review
     
  • Dave Brondsema

    Dave Brondsema - 2013-02-13
    • status: code-review --> closed
     

Log in to post a comment.