1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
8 from telemetry.core.platform import platform_backend
9 from telemetry.util import support_binaries
12 class DesktopPlatformBackend(platform_backend.PlatformBackend):
14 # This is an abstract class. It is OK to have abstract methods.
15 # pylint: disable=W0223
17 def FlushSystemCacheForDirectory(self, directory, ignoring=None):
18 assert directory and os.path.exists(directory), \
19 'Target directory %s must exist' % directory
20 flush_command = support_binaries.FindPath('clear_system_cache',
23 assert flush_command, 'You must build clear_system_cache first'
26 directory_contents = os.listdir(directory)
27 for item in directory_contents:
28 if not ignoring or item not in ignoring:
29 args.append(os.path.join(directory, item))
32 # http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx
33 # there's a maximum allowable command line of 32,768 characters on windows.
35 # Small note about [:256] and [256:]
36 # [:N] will return a list with the first N elements, ie.
37 # with [1,2,3,4,5], [:2] -> [1,2], and [2:] -> [3,4,5]
38 # with [1,2,3,4,5], [:5] -> [1,2,3,4,5] and [5:] -> []
39 subprocess.check_call([flush_command, '--recurse'] + args[:256])