Merge lp:~dpm/lp-get-ul10nstats/distro-support into lp:lp-get-ul10nstats

Proposed by David Planella on 2014-09-11
Status: Merged
Approved by: Colin Watson on 2015-02-03
Approved revision: 26
Merged at revision: 20
Proposed branch: lp:~dpm/lp-get-ul10nstats/distro-support
Merge into: lp:lp-get-ul10nstats
Diff against target: 128 lines (+25/-17)
1 file modified
lp-get-ul10nstats.py (+25/-17)
To merge this branch: bzr merge lp:~dpm/lp-get-ul10nstats/distro-support
Reviewer Review Type Date Requested Status
Colin Watson 2014-09-11 Approve on 2015-02-03
Review via email: mp+234349@code.launchpad.net

Description of the Change

As per RT #74952, added distro support for specifying a distro (e.g. 'ubuntu' or 'ubuntu-rtm') and a series (e.g. 'utopic' or '14.09')

This required https://code.launchpad.net/~cjwatson/launchpad/ul10nstats-security-distribution/+merge/248257 to be deployed first, which has now already happened.

To post a comment you must log in.
Colin Watson (cjwatson) :
review: Needs Fixing
21. By David Planella on 2015-02-02

Fixed issue with 'missing FROM-clause entry for table distribution'

22. By David Planella on 2015-02-02

Fixed missing + operator

23. By David Planella on 2015-02-02

Removed unused imports

24. By David Planella on 2015-02-02

Added compatibility code to allow the script to run with the old cron job

David Planella (dpm) wrote :

I believe I've addressed all the comments pointed in the review, thanks!

Colin Watson (cjwatson) :
review: Needs Fixing
25. By David Planella on 2015-02-02

Fixed typo in help message

26. By David Planella on 2015-02-02

Added back, 'join distroseries', had removed it erroneously

Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lp-get-ul10nstats.py'
2--- lp-get-ul10nstats.py 2011-06-09 10:03:44 +0000
3+++ lp-get-ul10nstats.py 2015-02-02 14:14:57 +0000
4@@ -26,9 +26,7 @@
5 import subprocess
6 import json
7 import gzip
8-import csv
9 import errno
10-from tempfile import TemporaryFile
11 import psycopg2
12 import datetime
13
14@@ -66,11 +64,13 @@
15 from potemplate
16 join sourcepackagename on sourcepackagename=sourcepackagename.id
17 join distroseries on distroseries=distroseries.id
18+ join distribution on distroseries.distribution=distribution.id
19 join pofile on pofile.potemplate=potemplate.id
20 join language on pofile.language=language.id
21 where
22 (potemplate.iscurrent or sourcepackagename.name='openoffice.org') and
23- distroseries.name='{0}'
24+ distribution.name='{0}' and
25+ distroseries.name='{1}'
26 order by language.code,
27 sourcepackagename.name,
28 potemplate.translation_domain,
29@@ -89,8 +89,10 @@
30 from potemplate
31 join sourcepackagename on sourcepackagename=sourcepackagename.id
32 join distroseries on distroseries=distroseries.id
33+ join distribution on distroseries.distribution=distribution.id
34 where
35- distroseries.name='{0}'
36+ distribution.name='{0}' and
37+ distroseries.name='{1}'
38 order by sourcepackagename.name,
39 potemplate.name;'''
40
41@@ -131,15 +133,16 @@
42 '''
43
44 def __init__(self, query, query_id, hostname, database, user, port,
45- distro_codename, private_path, public_path = None,
46+ distribution, distroseries, private_path, public_path = None,
47 public_server_user = None, ssh_key_path = None):
48- self.query = query.format(distro_codename)
49+ self.query = query.format(distribution, distroseries)
50 self.query_id = query_id
51 self.hostname = hostname
52 self.database = database
53 self.user = user
54 self.port = port
55- self.distro_codename = distro_codename
56+ self.distribution = distribution
57+ self.distroseries = distroseries
58 self.private_path = private_path
59 self.public_path = public_path
60 self.public_server_user = public_server_user
61@@ -204,7 +207,7 @@
62 Builds and returns the full name of the output file, given its
63 format
64 '''
65- return(self.distro_codename + '-' + self.query_id + '.' + format)
66+ return(self.distribution + '_' + self.distroseries + '_' + self.query_id + '.' + format)
67
68 def __postprocess_result(self, results, description, format):
69 '''
70@@ -276,7 +279,7 @@
71
72 usage = (
73 '''
74-%prog [options] distro_codename
75+%prog [options] distribution distroseries
76
77 Execute PostgreSQL queries to obtain a raw database dump in text files in
78 both csv and json formats, containing statistics about translation coverage
79@@ -292,12 +295,12 @@
80 -- Run the script having set all the defaults for options and specifying
81 natty as the distro to get the data from:
82
83- ./lp-get-ul10nstats.py natty
84+ ./lp-get-ul10nstats.py ubuntu natty
85
86 -- Run the script against a local launchpad instance for testing purposes,
87 obtaining natty data:
88
89- ./lp-get-ul10nstats.py -n localhost -d launchpad_dev natty
90+ ./lp-get-ul10nstats.py -n localhost -d launchpad_dev ubuntu natty
91 '''
92 )
93 parser = optparse.OptionParser(usage = usage)
94@@ -347,15 +350,19 @@
95 )
96 (options, args) = parser.parse_args()
97
98- if not args or len(args) > 1:
99+ if not args or len(args) > 2:
100 logging.error(
101 "You've either specified no arguments or too many of them.\n" +
102- "You need to specify at least (and at most) a distro " +
103- "codename (e.g. natty)")
104+ "You need to specify a distro if different from 'ubuntu' " +
105+ "and at least a series (e.g. ubuntu trusty)")
106 parser.print_help()
107 sys.exit(1)
108-
109- distro_codename = args[0]
110+ elif len(args) == 2:
111+ distribution = args[0]
112+ distroseries = args[1]
113+ elif len(args) == 1:
114+ distribution = "ubuntu"
115+ distroseries = args[0]
116
117 # Set the verbosity
118 logging_format = '%(asctime)s %(levelname)s %(message)s'
119@@ -374,7 +381,8 @@
120 options.database,
121 options.user,
122 options.port,
123- distro_codename,
124+ distribution,
125+ distroseries,
126 options.private_path,
127 options.public_path,
128 options.public_server_user,

Subscribers

People subscribed via source and target branches

to all changes: