Merge lp://qastaging/~kalebral-deactivatedaccount/drizzle-automation/fix-lcov into lp://qastaging/drizzle-automation

Proposed by Lee Bieber
Status: Merged
Merged at revision: not available
Proposed branch: lp://qastaging/~kalebral-deactivatedaccount/drizzle-automation/fix-lcov
Merge into: lp://qastaging/drizzle-automation
Diff against target: None lines
To merge this branch: bzr merge lp://qastaging/~kalebral-deactivatedaccount/drizzle-automation/fix-lcov
Reviewer Review Type Date Requested Status
Jay Pipes Approve
Review via email: mp+7351@code.qastaging.launchpad.net
To post a comment you must log in.
Revision history for this message
Lee Bieber (kalebral-deactivatedaccount) wrote :

Fix problem when parsing index.html to store data into db, pos returns a -1 if it can't find the pattern, so I changed "if pos:" to "if pos > 0:" and then added an "else percentage[dir]= 0.0" so it would have a record in the percentage table (causes other havoc if not there). Also moved the "if variables['no_store_db'] == False:" to the beginning of this logic as before we were not checking if we were storing this info in the db until after we had done all this processing.

Revision history for this message
Jay Pipes (jaypipes) wrote :

Excellent work. I'll merge in shortly.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lcov/run.py'
2--- lcov/run.py 2009-05-07 12:37:42 +0000
3+++ lcov/run.py 2009-06-10 23:02:49 +0000
4@@ -180,39 +180,40 @@
5 sys.exit(1)
6
7 # Scrape the top-level percentages from lcov/index.html and store them in DB
8- logging.info("Storing results of this run in local DB.")
9-
10- # Scrape the percentages...
11- percentages= {}
12-
13- # Grab our index file for the lcov reports
14- index_file_contents= open("%s/lcov/index.html" % working_dir).read()
15- for dir in lcov_dirs:
16-
17- pattern= "href=\"%s/index.html\"" % dir
18- pos= index_file_contents.find(pattern)
19+ if variables['no_store_db'] == False:
20+ logging.info("Storing results of this run in local DB.")
21+
22+ # Scrape the percentages...
23+ percentages= {}
24+
25+ # Grab our index file for the lcov reports
26+ index_file_contents= open("%s/lcov/index.html" % working_dir).read()
27+ for dir in lcov_dirs:
28+
29+ pattern= "href=\"%s/index.html\"" % dir
30+ pos= index_file_contents.find(pattern)
31
32- if pos:
33- float_pattern= "alt=\""
34- new_pos= index_file_contents.find(float_pattern, pos)
35- if new_pos:
36- new_pos= new_pos + 5 # length of alt="
37- end_pos= new_pos + 1
38- while index_file_contents[end_pos].isdigit() or index_file_contents[end_pos] == '.':
39- end_pos= end_pos + 1
40- dir_percent= float(index_file_contents[new_pos:end_pos])
41- percentages[dir]= dir_percent
42-
43-
44- # Insert into the DB...
45- sql= ""
46- for dir in lcov_dirs:
47- sql= sql + """
48- INSERT INTO lcov_stats (server, version, dir_name, run_date, coverage_percent) VALUES ('%s','%s','%s','%s', %0.2f);
49- """ % (server_name, server_version, dir, run_date, percentages[dir])
50-
51- if variables['no_store_db'] == False:
52- import lib.db
53- lib.db.execute_sql(sql)
54-
55+ if pos > 0:
56+ float_pattern= "alt=\""
57+ new_pos= index_file_contents.find(float_pattern, pos)
58+ if new_pos:
59+ new_pos= new_pos + 5 # length of alt="
60+ end_pos= new_pos + 1
61+ while index_file_contents[end_pos].isdigit() or index_file_contents[end_pos] == '.':
62+ end_pos= end_pos + 1
63+ dir_percent= float(index_file_contents[new_pos:end_pos])
64+ percentages[dir]= dir_percent
65+ else:
66+ percentages[dir]= 0.0
67+
68+ # Insert into the DB...
69+ sql= ""
70+ for dir in lcov_dirs:
71+ logging.info("%s %s %s %s %0.2f " % (server_name, server_version, dir, run_date, percentages[dir]))
72+ sql= sql + """
73+ INSERT INTO lcov_stats (server, version, dir_name, run_date, coverage_percent) VALUES ('%s','%s','%s','%s', %0.2f); """ % (server_name, server_version, dir, run_date, percentages[dir])
74+
75+ import lib.db
76+ lib.db.execute_sql(sql)
77+
78 return True

Subscribers

People subscribed via source and target branches

to all changes: