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']