Revert "Deprecated platform method in Python 3.7 #945"

This reverts commit 4877be45ea.
This commit is contained in:
Alessio Sergi 2016-10-31 19:10:12 +01:00
parent fc9580bc41
commit 85fa23ab71
4 changed files with 5 additions and 22 deletions

1
NEWS
View File

@ -21,7 +21,6 @@ Enhancements and news features:
* 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)
* Refactor the --disable-* options (issue #948)
Bugs corrected:

View File

@ -23,14 +23,7 @@ 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
@ -120,19 +113,11 @@ class Plugin(GlancesPlugin):
self.stats['hostname'] = platform.node()
self.stats['platform'] = platform.architecture()[0]
if self.stats['os_name'] == "Linux":
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])
linux_distro = platform.linux_distribution()
if linux_distro[0] == '':
self.stats['linux_distro'] = _linux_os_release()
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['linux_distro'] = ' '.join(linux_distro[:2])
self.stats['os_version'] = platform.release()
elif self.stats['os_name'].endswith('BSD'):
self.stats['os_version'] = platform.release()

View File

@ -1,2 +1 @@
psutil==4.4.0
distro==1.0.0

View File

@ -33,7 +33,7 @@ def get_data_files():
def get_requires():
requires = ['psutil>=2.0.0', 'distro>=1.0.0']
requires = ['psutil>=2.0.0']
return requires