Revision 01a7cff3 image_creator/disk.py

b/image_creator/disk.py
9 9
import sys
10 10
import guestfs
11 11

  
12
from pbs import dmsetup
13
from pbs import blockdev
12
import pbs
14 13
from pbs import dd
15 14

  
16 15

  
......
18 17
    pass
19 18

  
20 19

  
20
def find_sbin_command(command, exception):
21
    search_paths = ['/usr/local/sbin', '/usr/sbin', '/sbin']
22
    for fullpath in map(lambda x: "%s/%s" % (x, command), search_paths):
23
        if os.path.exists(fullpath) and os.access(fullpath, os.X_OK):
24
            return pbs.Command(fullpath)
25
        continue
26
    raise exception
27

  
28

  
29
try:
30
    from pbs import dmsetup
31
except pbs.CommandNotFound as e:
32
    dmsetup = find_sbin_command('dmsetup', e)
33

  
34
try:
35
    from pbs import blockdev
36
except pbs.CommandNotFound as e:
37
    blockdev = find_sbin_command('blockdev', e)
38

  
39

  
21 40
class Disk(object):
22 41
    """This class represents a hard disk hosting an Operating System
23 42

  

Also available in: Unified diff