Skip to content

Commit

Permalink
ENH. Add name and version of current linux distribution. (#119)
Browse files Browse the repository at this point in the history
* ENH. Add name and version of current linux distribution. Add placeholder for windows and mac os names.

* Handle Darwin and Windows, catch any exceptions

* Fix BLK100 errors

---------

Co-authored-by: Bane Sullivan <banesullivan@gmail.com>
  • Loading branch information
carsten-forty2 and banesullivan authored May 5, 2024
1 parent 6e5bb1f commit b373f38
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ ignore =
# Quotes (temporary)
Q0,
# bare excepts (temporary)
B001, E722
B001, E722,
# Ignore "black" formatting errors, since black is already checked
BLK100
28 changes: 26 additions & 2 deletions scooby/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,34 @@ def __init__(self):
def system(self) -> str:
"""Return the system/OS name.
E.g. ``'Linux'``, ``'Windows'``, or ``'Java'``. An empty string is
E.g. ``'Linux (name version)'``, ``'Windows'``, or ``'Darwin'``. An empty string is
returned if the value cannot be determined.
"""
return platform().system()
s = platform().system()
if s == 'Linux':
try:
s += (
f' ({platform().freedesktop_os_release()["NAME"]} '
+ f'{platform().freedesktop_os_release()["VERSION_ID"]})'
)
except Exception:
pass
elif s == 'Windows':
try:
release, version, csd, ptype = platform().win32_ver()
s += f' ({release} {version} {csd} {ptype})'
except Exception:
pass
elif s == 'Darwin':
try:
release, _, _ = platform().mac_ver()
s += f' (macOS {release})'
except Exception:
pass
elif s == 'Java':
# TODO: parse platform().java_ver()
pass
return s

@property
def platform(self) -> str:
Expand Down

0 comments on commit b373f38

Please sign in to comment.