Merge lp:~stub/launchpad/trivial into lp:launchpad

Proposed by Stuart Bishop on 2010-11-03
Status: Merged
Approved by: Robert Collins on 2010-11-03
Approved revision: 9941
Merged at revision: 11848
Proposed branch: lp:~stub/launchpad/trivial
Merge into: lp:launchpad
Diff against target: 51 lines (+22/-8)
2 files modified
lib/lp/services/scripts/base.py (+4/-7)
utilities/report-database-stats.py (+18/-1)
To merge this branch: bzr merge lp:~stub/launchpad/trivial
Reviewer Review Type Date Requested Status
Robert Collins (community) 2010-11-03 Approve on 2010-11-03
Review via email: mp+39935@code.launchpad.net

Commit Message

Remove some Python 2.5 compatibility code. Fold edge database stats into lpnet database stats.

Description of the Change

Remove some Python 2.5 compatibility code.

Fold edge database stats into lpnet database stats, per Bug #667883

To post a comment you must log in.
Robert Collins (lifeless) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/services/scripts/base.py'
2--- lib/lp/services/scripts/base.py 2010-10-07 16:51:23 +0000
3+++ lib/lp/services/scripts/base.py 2010-11-03 07:56:14 +0000
4@@ -393,13 +393,10 @@
5 def cronscript_enabled(control_url, name, log):
6 """Return True if the cronscript is enabled."""
7 try:
8- if sys.version_info[:2] >= (2, 6):
9- # Timeout of 5 seconds should be fine on the LAN. We don't want
10- # the default as it is too long for scripts being run every 60
11- # seconds.
12- control_fp = urlopen(control_url, timeout=5)
13- else:
14- control_fp = urlopen(control_url)
15+ # Timeout of 5 seconds should be fine on the LAN. We don't want
16+ # the default as it is too long for scripts being run every 60
17+ # seconds.
18+ control_fp = urlopen(control_url, timeout=5)
19 # Yuck. API makes it hard to catch 'does not exist'.
20 except HTTPError, error:
21 if error.code == 404:
22
23=== modified file 'utilities/report-database-stats.py'
24--- utilities/report-database-stats.py 2010-06-29 10:35:44 +0000
25+++ utilities/report-database-stats.py 2010-11-03 07:56:14 +0000
26@@ -132,7 +132,24 @@
27 GROUP BY username
28 """ % params)
29 cur.execute(query)
30- return set(cur.fetchall())
31+ cpu_stats = set(cur.fetchall())
32+
33+ # Fold edge into lpnet, as they are now running the same code.
34+ # This is a temporary hack until we drop edge entirely. See
35+ # Bug #667883 for details.
36+ lpnet_avg_cpu = 0.0
37+ edge_avg_cpu = 0.0
38+ for stats_tuple in list(cpu_stats):
39+ avg_cpu, username = stats_tuple
40+ if username == 'lpnet':
41+ lpnet_avg_cpu = avg_cpu
42+ cpu_stats.discard(stats_tuple)
43+ elif username == 'edge':
44+ edge_avg_cpu = avg_cpu
45+ cpu_stats.discard(stats_tuple)
46+ cpu_stats.add((lpnet_avg_cpu + edge_avg_cpu, 'lpnet'))
47+
48+ return cpu_stats
49
50
51 def main():