On Fri, 2015-08-28 at 13:02 +0200, Vratislav Podzimek wrote:
On Fri, 2015-08-28 at 12:10 +0200, Martin Kolman wrote:
> Also make sure that what we only return block devices and fix the
^ extra "what"
Fixing locally. :)
> output formatting regression.
>
> Resolves: rhbz#1253184
> Resolves: rhbz#1247886
> Signed-off-by: Martin Kolman <mkolman(a)redhat.com>
> ---
> data/command-stubs/list-harddrives-stub | 25
> +++++++++++++++++++++++--
> 1 file changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/data/command-stubs/list-harddrives-stub b/data/command
> -stubs/list-harddrives-stub
> index ae5e6b9..c35d2f3 100755
> --- a/data/command-stubs/list-harddrives-stub
> +++ b/data/command-stubs/list-harddrives-stub
> @@ -17,14 +17,35 @@
> # You should have received a copy of the GNU General Public
> License
> # along with this program. If not, see <
>
http://www.gnu.org/licenses/>.
> #
> +from __future__ import print_function
I think we can live with Python2's print statement in this script for
rhel7-branch.
Makes sense, changing locally. :)
>
> import sys
> +import os
> +import stat
> import parted
>
> +def check_device(device):
> + if stat.S_ISBLK(os.stat(device.path).st_mode):
> + # exclude device mapper devices
> + if device.type == parted.DEVICE_DM:
> + return False
> + # exclude block devices for CD/DVD disks
> + elif device.path.startswith("/dev/sr"):
> + return False
> + # exclude zram bloc devices
> + elif device.path.startswith("/dev/zram"):
> + return False
> + # the remaining block devices should be fine
> + else:
> + return True
> + else:
> + # ignore everything that is not a block device
> + return False
> +
> def main(argv):
> lst = set()
>
> - for dev in filter(lambda d: d.type != parted.DEVICE_DM and not
> d.path.startswith("/dev/sr"), parted.getAllDevices()):
> + for dev in filter(lambda d: check_device(d),
> parted.getAllDevices()):
> if dev.path.startswith("/dev/"):
> path = dev.path[5:]
> else:
> @@ -35,7 +56,7 @@ def main(argv):
> lst = list(lst)
> lst.sort()
> for dev, size in lst:
> - print(dev, size)
> + print("%s %s" % (dev, size))
>
> if __name__ == "__main__":
> main(sys.argv)
Looks good to me otherwise.
Thanks! :)