Edgewall Software

source: trunk/contrib/workflow/migrate_original_to_basic.py

Last change on this file was 12788, checked in by rjollos, 14 months ago

1.1.2dev: Replace print statements with print_function from __future__ module. Refs #11600.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.4 KB
Line 
1#!/usr/bin/python
2# -*- coding: utf-8 -*-
3#
4# Copyright (C) 2007-2013 Edgewall Software
5# Copyright (C) 2007 Eli Carter <retracile@gmail.com>
6# All rights reserved.
7#
8# This software is licensed as described in the file COPYING, which
9# you should have received as part of this distribution. The terms
10# are also available at http://trac.edgewall.com/license.html.
11#
12# This software consists of voluntary contributions made by many
13# individuals. For the exact contribution history, see the revision
14# history and logs, available at http://trac.edgewall.org/.
15
16import sys
17
18import trac.env
19from trac.ticket.default_workflow import load_workflow_config_snippet
20
21
22def main():
23    """Rewrite the ticket-workflow section of the config; and change all
24    'assigned' tickets to 'accepted'.
25    """
26    if len(sys.argv) != 2:
27        print("Usage: %s path_to_trac_environment" % sys.argv[0])
28        sys.exit(1)
29    tracdir = sys.argv[1]
30    trac_env = trac.env.open_environment(tracdir)
31
32    # Update the config...
33    old_workflow = trac_env.config.options('ticket-workflow')
34    for name, value in old_workflow:
35        trac_env.config.remove('ticket-workflow', name)
36    load_workflow_config_snippet(trac_env.config, 'basic-workflow.ini')
37    trac_env.config.save()
38
39    # Update the ticket statuses...
40    trac_env.db_transaction("""
41        UPDATE ticket SET status = 'accepted' WHERE status = 'assigned'
42        """)
43
44if __name__ == '__main__':
45    main()
Note: See TracBrowser for help on using the repository browser.