Skip to content

Commit 0e9ab44

Browse files
author
Anthony Baxter
committed
consistency in file formats
1 parent 4c43d3b commit 0e9ab44

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

tools/migrate-queries.py

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
#! /usr/bin/env python
2-
'''
3-
migrate-queries <instance-home> [<instance-home> *]
4-
5-
Migrate old queries in the specified instances to Roundup 0.6.0+ by
6-
removing the leading ? from their URLs. 0.6.0+ queries do not carry a
7-
leading ?; it is added by the 0.6.0 templating, so old queries lead
8-
to query URLs with a double leading ?? and a consequent 404 Not Found.
9-
'''
10-
__author__ = 'James Kew <[email protected]>'
11-
12-
import sys
13-
import roundup.instance
14-
15-
if len(sys.argv) == 1:
16-
print __doc__
17-
sys.exit(1)
18-
19-
# Iterate over all instance homes specified in argv.
20-
for home in sys.argv[1:]:
21-
# Do some basic exception handling to catch bad arguments.
22-
try:
23-
instance = roundup.instance.open(home)
24-
except:
25-
print 'Cannot open instance home directory %s!' % home
26-
continue
27-
28-
db = instance.open('admin')
29-
30-
print 'Migrating active queries in %s (%s):'%(
31-
instance.config.TRACKER_NAME, home)
32-
for query in db.query.list():
33-
url = db.query.get(query, 'url')
34-
if url[0] == '?':
35-
url = url[1:]
36-
print ' Migrating query%s (%s)'%(query,
37-
db.query.get(query, 'name'))
38-
db.query.set(query, url=url)
39-
40-
db.commit()
41-
db.close()
42-
1+
#! /usr/bin/env python
2+
'''
3+
migrate-queries <instance-home> [<instance-home> *]
4+
5+
Migrate old queries in the specified instances to Roundup 0.6.0+ by
6+
removing the leading ? from their URLs. 0.6.0+ queries do not carry a
7+
leading ?; it is added by the 0.6.0 templating, so old queries lead
8+
to query URLs with a double leading ?? and a consequent 404 Not Found.
9+
'''
10+
__author__ = 'James Kew <[email protected]>'
11+
12+
import sys
13+
import roundup.instance
14+
15+
if len(sys.argv) == 1:
16+
print __doc__
17+
sys.exit(1)
18+
19+
# Iterate over all instance homes specified in argv.
20+
for home in sys.argv[1:]:
21+
# Do some basic exception handling to catch bad arguments.
22+
try:
23+
instance = roundup.instance.open(home)
24+
except:
25+
print 'Cannot open instance home directory %s!' % home
26+
continue
27+
28+
db = instance.open('admin')
29+
30+
print 'Migrating active queries in %s (%s):'%(
31+
instance.config.TRACKER_NAME, home)
32+
for query in db.query.list():
33+
url = db.query.get(query, 'url')
34+
if url[0] == '?':
35+
url = url[1:]
36+
print ' Migrating query%s (%s)'%(query,
37+
db.query.get(query, 'name'))
38+
db.query.set(query, url=url)
39+
40+
db.commit()
41+
db.close()
42+

0 commit comments

Comments
 (0)