def get_current_status(self):
        self.current_version = None
        self.candidate_version = None

        proc = Popen("apt-cache policy %s" % self.resource.package_name, shell=True, stdout=PIPE)
        out = proc.communicate()[0]
        for line in out.split("\n"):
            line = line.strip().split(':', 1)
            if len(line) != 2:
                continue

            ver = line[1].strip()
            if line[0] == "Installed":
                self.current_version = None if ver == '(none)' else ver
                self.log.debug("Current version of package %s is %s" % (self.resource.package_name, self.current_version))
            elif line[0] == "Candidate":
                self.candidate_version = ver

        if self.candidate_version == "(none)":
            raise Fail("APT does not provide a version of package %s" % self.resource.package_name)
dataset/ETHPy150Open samuel/kokki/kokki/providers/package/apt.py/DebianAptProvider.get_current_status/original