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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/platform/linux_platform_backend.py
diff --git a/tools/telemetry/telemetry/core/platform/linux_platform_backend.py b/tools/telemetry/telemetry/core/platform/linux_platform_backend.py
index e2535208bcc9ee88078cae30a9c30d250a2ba76c..89d9dd392c575bb0ea850e5a125fb327d9bec1b9 100644
--- a/tools/telemetry/telemetry/core/platform/linux_platform_backend.py
+++ b/tools/telemetry/telemetry/core/platform/linux_platform_backend.py
@@ -44,15 +44,17 @@ class LinuxPlatformBackend(
codename = None
version = None
- with open('/etc/lsb-release') as f:
- for line in f.readlines():
- key, _, value = line.partition('=')
- if key == 'DISTRIB_CODENAME':
- codename = value.strip()
- elif key == 'DISTRIB_RELEASE':
+ for line in self._GetFileContents('/etc/lsb-release').splitlines():
+ key, _, value = line.partition('=')
+ if key == 'DISTRIB_CODENAME':
+ codename = value.strip()
+ elif key == 'DISTRIB_RELEASE':
+ try:
version = float(value)
- if codename and version:
- break
+ except ValueError:
+ version = 0
+ if codename and version:
+ break
return platform_backend.OSVersion(codename, version)
def CanFlushIndividualFilesFromSystemCache(self):
« 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