提交 4877be45 编写于 作者: N nicolargo

Deprecated platform method in Python 3.7 #945

上级 ae539dde
......@@ -10,13 +10,14 @@ Enhancements and news features:
* Add ZeroMQ exporter (issue #939)
* Add CouchDB exporter (issue #928)
* Add hotspot Wifi informations (issue #937)
* Add default interface speed and automatic rate thresolds (issue #718)
* Add default interface speed and automatic rate thresolds (issue #718)
* Highlight max stats in the processes list (issue #878)
* Docker alerts and actions (issue #875)
* Glances API returns the processes PPID (issue #926)
* Configure server cached time from the command line --cached-time (issue #901)
* Make the log logger configurable (issue #900)
* System uptime in export (issue #890)
* Deprecated platform method in Python 3.7 (issue #945)
Bugs corrected:
......
......@@ -2,7 +2,7 @@
#
# This file is part of Glances.
#
# Copyright (C) 2015 Nicolargo <nicolas@nicolargo.com>
# Copyright (C) 2016 Nicolargo <nicolas@nicolargo.com>
#
# Glances is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
......@@ -23,7 +23,14 @@ import os
import platform
import re
from io import open
try:
import distro
except ImportError:
distro_tag = False
else:
distro_tag = True
from glances.logger import logger
from glances.compat import iteritems
from glances.plugins.glances_plugin import GlancesPlugin
......@@ -38,7 +45,8 @@ snmp_oid = {'default': {'hostname': '1.3.6.1.2.1.1.5.0',
# Dict (key: OS short name) of dict (reg exp OID to human)
# Windows:
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms724832%28v=vs.85%29.aspx
snmp_to_human = {'windows': {'Windows Version 6.3': 'Windows 8.1 or Server 2012R2',
snmp_to_human = {'windows': {'Windows Version 10.0': 'Windows 10 or Server 2016',
'Windows Version 6.3': 'Windows 8.1 or Server 2012R2',
'Windows Version 6.2': 'Windows 8 or Server 2012',
'Windows Version 6.1': 'Windows 7 or Server 2008R2',
'Windows Version 6.0': 'Windows Vista or Server 2008',
......@@ -112,11 +120,19 @@ class Plugin(GlancesPlugin):
self.stats['hostname'] = platform.node()
self.stats['platform'] = platform.architecture()[0]
if self.stats['os_name'] == "Linux":
linux_distro = platform.linux_distribution()
if linux_distro[0] == '':
self.stats['linux_distro'] = _linux_os_release()
else:
if distro_tag:
# Use the distro external lib
# Why ?
# Because platform.linux_distribution is predicated in Python 3.7
linux_distro = distro.linux_distribution()
self.stats['linux_distro'] = ' '.join(linux_distro[:2])
else:
try:
# For Python < 3.7
linux_distro = platform.linux_distribution()
self.stats['linux_distro'] = ' '.join(linux_distro[:2])
except AttributeError:
self.stats['linux_distro'] = _linux_os_release()
self.stats['os_version'] = platform.release()
elif self.stats['os_name'].endswith('BSD'):
self.stats['os_version'] = platform.release()
......
......@@ -33,7 +33,7 @@ def get_data_files():
def get_requires():
requires = ['psutil>=2.0.0']
requires = ['psutil>=2.0.0', 'distro>=1.0.0']
return requires
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册