- cmd_is_package_installed.append('|')
- cmd_is_package_installed.append('grep') # add a grep to get an exit status
- cmd_is_package_installed.append(cmd)
-
- p=subprocess.Popen(cmd_is_package_installed,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- output, err = p.communicate()
-
- rc = p.returncode
- if rc==0:
- msg_status=src.printcolors.printcSuccess("OK")
- if check_cmd[0]=="rpm": # apt output is too messy for being used
+ p=subprocess.Popen(cmd_is_package_installed,
+ stdout=subprocess.PIPE,
+ stderr=FNULL)
+ try:
+ output = subprocess.check_output(['grep', pkg], stdin=p.stdout)
+ msg_status=src.printcolors.printcSuccess("OK")
+ except:
+ msg_status=src.printcolors.printcError("KO")
+ msg_status+=" (package is not installed!)\n"
+ else:
+ p=subprocess.Popen(cmd_is_package_installed,
+ stdout=subprocess.PIPE,
+ stderr=FNULL)
+ output, err = p.communicate()
+ rc = p.returncode
+ if rc==0:
+ msg_status=src.printcolors.printcSuccess("OK")