#!/usr/bin/python import yum import json base = yum.YumBase() package_list = base.doPackageLists(pkgnarrow='updates', patterns='', ignore_case=True) if package_list.updates: count = len(package_list.updates) else: count = 0 print count