I would like to add validation in a python 2.7.x script as
if __check_freebsd__(): # run actions which would only work on FreeBSD (eg create a jail) elif __check_debian__(): # run an alternative that runs on Debian-based systems else: raise Error("unsupported OS")
What would the __check_freebsd__ function look like?
I already have the following code for __check_debian__ :
try: lsb_release_id_short = sp.check_output([lsb_release, "-d", "-s"]).strip().decode("utf-8") ret_value = "Debian" in lsb_release_id_short return ret_value except Exception: return False
So you donβt have to worry about this (suggestions for improvement are welcome, of course).
source share