Chromium Code Reviews| 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__': |