summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2019-05-08 21:24:45 +0100
committerCalum Lind <calumlind+deluge@gmail.com>2019-05-08 21:24:45 +0100
commit2296906ed3a3b53a84e90f28eea1bfc9b5e23797 (patch)
tree3d1c666c60d02133ec663137985099c89576613a
parent1a134cab1bb0e1ae75b04839cfc24ffde8f3b32f (diff)
downloaddeluge-2296906ed3a3b53a84e90f28eea1bfc9b5e23797.tar.gz
deluge-2296906ed3a3b53a84e90f28eea1bfc9b5e23797.tar.bz2
deluge-2296906ed3a3b53a84e90f28eea1bfc9b5e23797.zip
[Common] Replace platform.linux_distribution function
As of python 3.5, this function is marked as deprecated. So, [distro][1] is the one we will use (this package is listed at the example package in the python's [docs][2]). [1] https://pypi.org/project/distro/ [2] https://docs.python.org/3/library/platform.html#platform.dist
-rw-r--r--DEPENDS.md5
-rw-r--r--deluge/common.py11
-rw-r--r--requirements.txt1
-rwxr-xr-xsetup.py1
4 files changed, 15 insertions, 3 deletions
diff --git a/DEPENDS.md b/DEPENDS.md
index 5739786f3..4b5e92a43 100644
--- a/DEPENDS.md
+++ b/DEPENDS.md
@@ -30,6 +30,10 @@ All modules will require the [common](#common) section dependencies.
- [Pillow] - Optional: Support for resizing tracker icons.
- [dbus-python] - Optional: Show item location in filemanager.
+#### Linux and BSD
+
+- [distro] - Optional: OS platform information.
+
#### Windows OS
- [pywin32]
@@ -75,6 +79,7 @@ All modules will require the [common](#common) section dependencies.
[pillow]: https://pypi.org/project/Pillow/
[libtorrent]: https://libtorrent.org/
[zope.interface]: https://pypi.org/project/zope.interface/
+[distro]: https://github.com/nir0s/distro
[pywin32]: https://github.com/mhammond/pywin32
[certifi]: https://pypi.org/project/certifi/
[py2-ipaddress]: https://pypi.org/project/py2-ipaddress/
diff --git a/deluge/common.py b/deluge/common.py
index d52a26dda..26e160528 100644
--- a/deluge/common.py
+++ b/deluge/common.py
@@ -53,12 +53,17 @@ if platform.system() in ('Windows', 'Microsoft'):
os.environ['SSL_CERT_FILE'] = where()
-# gi makes dbus available on Window but don't import it as unused.
+
if platform.system() not in ('Windows', 'Microsoft', 'Darwin'):
+ # gi makes dbus available on Window but don't import it as unused.
try:
import dbus
except ImportError:
dbus = None
+ try:
+ import distro
+ except ImportError:
+ distro = None
log = logging.getLogger(__name__)
@@ -266,8 +271,8 @@ def get_os_version():
elif osx_check():
os_version = list(platform.mac_ver())
os_version[1] = '' # versioninfo always empty.
- elif linux_check():
- os_version = platform.linux_distribution()
+ elif distro:
+ os_version = distro.linux_distribution()
else:
os_version = (platform.release(),)
diff --git a/requirements.txt b/requirements.txt
index 17458a189..dcbdfb869 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -11,3 +11,4 @@ pywin32; sys_platform == 'win32'
py2-ipaddress; sys_platform == 'win32' and python_version == '2'
certifi; sys_platform == 'win32'
zope.interface>=4.4.2
+distro; 'win' not in sys_platform
diff --git a/setup.py b/setup.py
index 9ff305ef4..17e203bda 100755
--- a/setup.py
+++ b/setup.py
@@ -551,6 +551,7 @@ install_requires = [
"py2-ipaddress; sys_platform == 'win32' and python_version == '2'",
"certifi; sys_platform == 'win32'",
'zope.interface',
+ "distro; 'win' not in sys_platform",
]
tests_require = ['pytest', 'pytest-twisted']