Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Unified Diff: tools/resource_prefetch_predictor/prefetch_predictor_tool.py

Issue 2620053002: predictors: db tool workaround to solve sqlite3 compatibility problem. (Closed)
Patch Set: Fix mess. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/resource_prefetch_predictor/prefetch_predictor_tool.py
diff --git a/tools/resource_prefetch_predictor/prefetch_predictor_tool.py b/tools/resource_prefetch_predictor/prefetch_predictor_tool.py
index 1160f5f3a108505cfa20615fbccb5e881286ee22..9680c657cf68394793183f2140f63a799e67b53b 100755
--- a/tools/resource_prefetch_predictor/prefetch_predictor_tool.py
+++ b/tools/resource_prefetch_predictor/prefetch_predictor_tool.py
@@ -13,6 +13,7 @@ adb pull \
import argparse
import sqlite3
+import os
from resource_prefetch_predictor_pb2 import (PrefetchData, ResourceData)
@@ -77,6 +78,15 @@ class Entry(object):
continue
self._PrettyPrintResource(resource)
+# The version of python sqlite3 library we have in Ubuntu 14.04 LTS doesn't
+# support views but command line util does.
+# TODO(alexilin): get rid of this when python sqlite3 adds view support.
+def CreateCompatibleDatabaseCopy(filename):
+ import tempfile, shutil, subprocess
+ _, tmpfile = tempfile.mkstemp()
+ shutil.copy2(filename, tmpfile)
+ subprocess.call(['sqlite3', tmpfile, 'DROP VIEW MmapStatus'])
+ return tmpfile
def DatabaseStats(filename, domain):
connection = sqlite3.connect(filename)
@@ -94,7 +104,12 @@ def main():
help='Path to the database')
parser.add_argument('-d', dest='domain', default=None, help='Domain')
args = parser.parse_args()
- DatabaseStats(args.database_filename, args.domain)
+ try:
+ database_copy = CreateCompatibleDatabaseCopy(args.database_filename)
+ DatabaseStats(database_copy, args.domain)
+ finally:
+ if os.path.exists(database_copy):
+ os.remove(database_copy)
if __name__ == '__main__':
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698