MCPcopy Create free account
hub / github.com/StackStorm/st2 / get_linux_distribution

Function get_linux_distribution

contrib/linux/actions/service.py:35–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33
34
35def get_linux_distribution():
36 # platform.linux_distribution() is not available in Python >= 3.8
37 if hasattr(platform, "linux_distribution"):
38 distro = platform.linux_distribution()[0] # pylint: disable=no-member
39 else:
40 # Fall back to shelling out to lsb_release
41 result = subprocess.run(
42 "lsb_release -i -s", shell=True, check=True, stdout=subprocess.PIPE
43 )
44 distro = result.stdout.decode("utf-8").strip()
45
46 if not distro:
47 raise ValueError("Fail to detect distribution we are running on")
48
49 return distro
50
51
52if len(sys.argv) < 3:

Callers 1

service.pyFile · 0.85

Calls 1

runMethod · 0.45

Tested by

no test coverage detected