7675.891.2
by Bryce Harrington
Break out BugzillaRemoteComponentFinder to separate script file |
1 |
#!/usr/bin/python -S
|
7675.891.1
by Bryce Harrington
Proof-of-concept implementation of component update cronjob |
2 |
#
|
3 |
# Copyright 2010 Canonical Ltd. This software is licensed under the
|
|
4 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
5 |
||
7675.891.2
by Bryce Harrington
Break out BugzillaRemoteComponentFinder to separate script file |
6 |
# pylint: disable-msg=W0403
|
7 |
import _pythonpath |
|
8 |
||
7675.891.1
by Bryce Harrington
Proof-of-concept implementation of component update cronjob |
9 |
import time |
10 |
||
7675.891.49
by Bryce Harrington
Use config setting for db role |
11 |
from canonical.config import config |
7675.891.2
by Bryce Harrington
Break out BugzillaRemoteComponentFinder to separate script file |
12 |
from lp.services.scripts.base import LaunchpadCronScript |
13 |
from canonical.launchpad.scripts.bzremotecomponentfinder import ( |
|
14 |
BugzillaRemoteComponentFinder, |
|
7675.891.6
by Bryce Harrington
Cleanup |
15 |
)
|
7675.891.3
by Bryce Harrington
Move from use of pycurl to straight urllib2 |
16 |
|
7675.891.11
by Bryce Harrington
Batch db operations together. |
17 |
|
7675.891.2
by Bryce Harrington
Break out BugzillaRemoteComponentFinder to separate script file |
18 |
class UpdateRemoteComponentsFromBugzilla(LaunchpadCronScript): |
7675.891.1
by Bryce Harrington
Proof-of-concept implementation of component update cronjob |
19 |
|
7675.891.2
by Bryce Harrington
Break out BugzillaRemoteComponentFinder to separate script file |
20 |
def add_my_options(self): |
21 |
self.parser.add_option( |
|
7675.891.19
by Bryce Harrington
Drop --component-group. |
22 |
"-b", "--bugtracker", dest="bugtracker", |
7675.891.2
by Bryce Harrington
Break out BugzillaRemoteComponentFinder to separate script file |
23 |
help="Update only the bug tracker with this name in launchpad") |
24 |
||
25 |
def main(self): |
|
26 |
start_time = time.time() |
|
7675.891.17
by Bryce Harrington
Drop the stubbed in --purge-first option. |
27 |
finder = BugzillaRemoteComponentFinder( |
28 |
self.logger) |
|
7675.891.19
by Bryce Harrington
Drop --component-group. |
29 |
finder.getRemoteProductsAndComponents( |
30 |
bugtracker_name=self.options.bugtracker) |
|
7675.891.11
by Bryce Harrington
Batch db operations together. |
31 |
|
7675.891.2
by Bryce Harrington
Break out BugzillaRemoteComponentFinder to separate script file |
32 |
run_time = time.time() - start_time |
33 |
print("Time for this run: %.3f seconds." % run_time) |
|
7675.891.1
by Bryce Harrington
Proof-of-concept implementation of component update cronjob |
34 |
|
35 |
||
36 |
if __name__ == "__main__": |
|
7675.891.2
by Bryce Harrington
Break out BugzillaRemoteComponentFinder to separate script file |
37 |
|
38 |
updater = UpdateRemoteComponentsFromBugzilla( |
|
7675.891.39
by Bryce Harrington
Final tidying up |
39 |
"updatebugzillaremotecomponents", |
7675.891.50
by Bryce Harrington
Tweak security settings so script will run successfully |
40 |
dbuser=config.updatebugzillaremotecomponents.dbuser) |
7675.891.1
by Bryce Harrington
Proof-of-concept implementation of component update cronjob |
41 |
updater.lock_and_run() |