- i am installing some package based on operating system output.
- I want to introduce try-except block (or any better way) for linux1 & linux2 loops to print the package is missing in OS or other error while install
- 3rd loop (Linux-Others) should just give warning and proceed with rest of package installation even if I have error
.
import platform
operating_system=platform.platform()
def package_install():
listA=['package1','pa9ckage2','package3']
listB=['package4','package5','package6']
listC=['package10','package20','package30']
if 'linux1' in operating_system:
self._log.info("Linux-A")
yum_command = yum_command = [
YUM_EXECUTABLE,
"-y",
"install"
] + listA
return self._executor.execute_command(yum_command)
elif 'linux2' in operating_system:
self._log.info("Linux-B")
yum_command = yum_command = [
YUM_EXECUTABLE,
"-y",
"install"
] + listB
return self._executor.execute_command(yum_command)
else:
self._log.info("Linux-Others")
yum_command = yum_command = [
YUM_EXECUTABLE,
"-y",
"install"
] + listC
return self._executor.execute_command(yum_command)