-
-def find_sbin_command(command, exception):
- search_paths = ['/usr/local/sbin', '/usr/sbin', '/sbin']
- for fullpath in map(lambda x: "%s/%s" % (x, command), search_paths):
- if os.path.exists(fullpath) and os.access(fullpath, os.X_OK):
- return pbs.Command(fullpath)
- continue
- raise exception
-
-
-try:
- from pbs import dmsetup
-except pbs.CommandNotFound as e:
- dmsetup = find_sbin_command('dmsetup', e)
-
-try:
- from pbs import blockdev
-except pbs.CommandNotFound as e:
- blockdev = find_sbin_command('blockdev', e)
+dd = get_command('dd')
+dmsetup = get_command('dmsetup')
+losetup = get_command('losetup')
+blockdev = get_command('blockdev')