diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-02-28 09:47:28 +0100 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2022-02-28 10:52:17 +0100 |
commit | ee6fd6a50922d2b27c97084e1c3f9872d495c273 (patch) | |
tree | d8badefd1930a2a0166b270309b3768252c567e4 /man/check-os-release-simple.py | |
parent | Merge pull request #22627 from yuwata/network-l2tp-cleanups (diff) | |
download | systemd-ee6fd6a50922d2b27c97084e1c3f9872d495c273.tar.xz systemd-ee6fd6a50922d2b27c97084e1c3f9872d495c273.zip |
man: recommend built-in platform.freedesktop_os_release() in our page
Python gained support for reading os-release, let's advertise it a bit more.
Our open-coded example is still useful, but let's not suggest it as the
default implementation.
I added quotes around the printed string because it looks a bit better
this way.
Diffstat (limited to 'man/check-os-release-simple.py')
-rw-r--r-- | man/check-os-release-simple.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/man/check-os-release-simple.py b/man/check-os-release-simple.py new file mode 100644 index 0000000000..738b1fd860 --- /dev/null +++ b/man/check-os-release-simple.py @@ -0,0 +1,12 @@ +#!/usr/bin/python +# SPDX-License-Identifier: CC0-1.0 + +import platform +os_release = platform.freedesktop_os_release() + +pretty_name = os_release.get('PRETTY_NAME', 'Linux') +print(f'Running on {pretty_name!r}') + +if 'fedora' in [os_release.get('ID', 'linux'), + *os_release.get('ID_LIKE', '').split()]: + print('Looks like Fedora!') |