def is_rpm_package_installed ( pkg ) : with settings ( hide ( 'warnings' , 'running' , 'stdout' , 'stderr' ) , warn_only = True , capture = True ) : result = sudo ( "rpm -q %s" % pkg ) if result . return_code == 0 : return True elif result . return_code == 1 : return False else : # print error to user print ( result ) raise SystemExit ( )
python check rpm exists
checks if a particular rpm package is installed
def is_rpm_package_installed(pkg):
    """ checks if a particular rpm package is installed """

    with settings(hide('warnings', 'running', 'stdout', 'stderr'),
                  warn_only=True, capture=True):

        result = sudo("rpm -q %s" % pkg)
        if result.return_code == 0:
            return True
        elif result.return_code == 1:
            return False
        else:   # print error to user
            print(result)
            raise SystemExit()