def partion_disk_usage(sub_metric):
    mountpoints_initialized = [0]
    mountpoints = []

    def gather_metric():
        if mountpoints_initialized[0] == 0:
            for p in psutil.disk_partitions():
                # Only add to list of mountpoints if fstype is
                # specified.  This prevents reading from empty drives
                # such as cd-roms, card readers etc.
                if p.fstype:
                    mountpoints.append(p.mountpoint)
            mountpoints_initialized[0] = 1

        for mountpoint in mountpoints:
            try:
                diskusage = psutil.disk_usage(mountpoint)
                yield getattr(diskusage, sub_metric), {'partition': mountpoint}
            except __HOLE__:
                # Certain partitions, like a CD/DVD drive, are expected to fail
                pass

    gather_metric.__doc__ = "TODO"
    return gather_metric
dataset/ETHPy150Open scalyr/scalyr-agent-2/scalyr_agent/builtin_monitors/windows_system_metrics.py/partion_disk_usage