def is_installed(name):
    ret = exec_cmd("/usr/bin/dpkg-query -l '{0}'".format(name))
    if ret['returncode'] != 0:
        return False

    # There's no way to use return code of any of the dpkg-query options.
    # Instead we use the "state" column of dpkg-query -l
    # So programmaticaly here:
    # 1. Get stdout
    # 2. Split on new line
    # 3. Get the last but one line (last is blank, in any case?)
    # 4. Get first character (i=installed)
    try:
        return ret['stdout'].split('\n')[-2][0] == 'i'
    except __HOLE__ as err:
        log.error(err)
        return False
dataset/ETHPy150Open comodit/synapse-agent/synapse/resources/packages-plugin/apt.py/is_installed