code: def rpm_eval(macro):
      
      try:
          value = subprocess.Popen(
              ['rpm', '--eval', macro],
              stdout=subprocess.PIPE).communicate()[0].strip()
      except OSError:
          logger.error('Failed to get value of {0} rpm macro'.format(
              macro), exc_info=True)
          value = b''
      return console_to_str(value)
docs: Get value of given macro using rpm tool