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

Side by Side Diff: tools/telemetry/telemetry/core/platform/linux_platform_backend.py

Issue 381293003: [Telemetry] Consider linux distribution number is 0 when it cannot be parsed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/telemetry/telemetry/core/platform/linux_platform_backend_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 import os 6 import os
7 import subprocess 7 import subprocess
8 import sys 8 import sys
9 9
10 from telemetry import decorators 10 from telemetry import decorators
(...skipping 26 matching lines...) Expand all
37 def GetOSName(self): 37 def GetOSName(self):
38 return 'linux' 38 return 'linux'
39 39
40 @decorators.Cache 40 @decorators.Cache
41 def GetOSVersionName(self): 41 def GetOSVersionName(self):
42 if not os.path.exists('/etc/lsb-release'): 42 if not os.path.exists('/etc/lsb-release'):
43 raise NotImplementedError('Unknown Linux OS version') 43 raise NotImplementedError('Unknown Linux OS version')
44 44
45 codename = None 45 codename = None
46 version = None 46 version = None
47 with open('/etc/lsb-release') as f: 47 for line in self._GetFileContents('/etc/lsb-release').splitlines():
48 for line in f.readlines(): 48 key, _, value = line.partition('=')
49 key, _, value = line.partition('=') 49 if key == 'DISTRIB_CODENAME':
50 if key == 'DISTRIB_CODENAME': 50 codename = value.strip()
51 codename = value.strip() 51 elif key == 'DISTRIB_RELEASE':
52 elif key == 'DISTRIB_RELEASE': 52 try:
53 version = float(value) 53 version = float(value)
54 if codename and version: 54 except ValueError:
55 break 55 version = 0
56 if codename and version:
57 break
56 return platform_backend.OSVersion(codename, version) 58 return platform_backend.OSVersion(codename, version)
57 59
58 def CanFlushIndividualFilesFromSystemCache(self): 60 def CanFlushIndividualFilesFromSystemCache(self):
59 return True 61 return True
60 62
61 def FlushEntireSystemCache(self): 63 def FlushEntireSystemCache(self):
62 p = subprocess.Popen(['/sbin/sysctl', '-w', 'vm.drop_caches=3']) 64 p = subprocess.Popen(['/sbin/sysctl', '-w', 'vm.drop_caches=3'])
63 p.wait() 65 p.wait()
64 assert p.returncode == 0, 'Failed to flush system cache' 66 assert p.returncode == 0, 'Failed to flush system cache'
65 67
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 cloud_storage.GetIfChanged(bin_path, cloud_storage.INTERNAL_BUCKET) 116 cloud_storage.GetIfChanged(bin_path, cloud_storage.INTERNAL_BUCKET)
115 os.chmod(bin_path, 0755) 117 os.chmod(bin_path, 0755)
116 except cloud_storage.CloudStorageError, e: 118 except cloud_storage.CloudStorageError, e:
117 logging.error(str(e)) 119 logging.error(str(e))
118 if fallback_package: 120 if fallback_package:
119 logging.error('You may proceed by manually installing %s via:\n' 121 logging.error('You may proceed by manually installing %s via:\n'
120 'sudo apt-get install %s' % (bin_name, fallback_package)) 122 'sudo apt-get install %s' % (bin_name, fallback_package))
121 sys.exit(1) 123 sys.exit(1)
122 124
123 assert self.CanLaunchApplication(bin_name), 'Failed to install ' + bin_name 125 assert self.CanLaunchApplication(bin_name), 'Failed to install ' + bin_name
OLDNEW
« no previous file with comments | « no previous file | tools/telemetry/telemetry/core/platform/linux_platform_backend_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698