Skip to content

Instantly share code, notes, and snippets.

@gm3dmo
Created November 10, 2014 12:19
Show Gist options
  • Save gm3dmo/2b536d7a211225088431 to your computer and use it in GitHub Desktop.
Save gm3dmo/2b536d7a211225088431 to your computer and use it in GitHub Desktop.
Interact with yum in python and see if a list of rpm/packages are installed
#!/bin/env python
import yum
import sys
import platform
print(platform.dist()[0])
def main():
print(platform.dist()[0])
pkg_list = get_pkg_list()
a='x86_64'
a='i686'
yb = yum.YumBase()
for pkg in pkg_list:
if yb.rpmdb.searchNevra(name=pkg, arch=a):
print 'RPM installed: {0} architecture: {1}'.format(pkg, a)
else:
print 'RPM not installed: {0} architecture: {1}'.format(pkg, a)
def get_pkg_list():
return ['glibc']
def get_test():
pass
if __name__ == '__main__':
sys.exit(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment