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

Unified Diff: tools/resource_prefetch_predictor/prefetch_predictor_tool.py

Issue 2620053002: predictors: db tool workaround to solve sqlite3 compatibility problem. (Closed)
Patch Set: 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..4371d6fb4133c73fe10ea9cc4112f9a2390e86c9 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 current version of python sqilte3 library doesn't support views but
Benoit L 2017/01/11 09:36:45 Not sure about the "current" version, at least the
alexilin 2017/01/11 12:39:07 Done.
+# command line util does.
+# TODO(alexilin): get rid of this when python sqlite3 adds view support.
+def CreateCompatibleDatabaseCopy(filename):
+ import tempfile, shutil
+ _, tmpfile = tempfile.mkstemp()
+ shutil.copy2(filename, tmpfile)
+ os.system('sqlite3 %s "DROP VIEW MmapStatus"' % (tmpfile,))
Benoit L 2017/01/11 09:36:45 nit: why not subprocess.call(['sqlite3', tmpfile,
alexilin 2017/01/11 12:39:07 Done.
+ return tmpfile
def DatabaseStats(filename, domain):
connection = sqlite3.connect(filename)
@@ -94,7 +104,9 @@ 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)
+ database_copy = CreateCompatibleDatabaseCopy(args.database_filename)
Benoit L 2017/01/11 09:36:45 nit: try: bla bla finally: os.remove(database
alexilin 2017/01/11 12:39:07 Done.
+ DatabaseStats(database_copy, args.domain)
+ 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