Statistics
| Branch: | Tag: | Revision:

root / image_creator / util.py @ 3ccb2618

History | View | Annotate | Download (524 Bytes)

1 3ccb2618 Nikos Skalkotos
#!/usr/bin/env python
2 3ccb2618 Nikos Skalkotos
3 3ccb2618 Nikos Skalkotos
import pbs
4 3ccb2618 Nikos Skalkotos
5 3ccb2618 Nikos Skalkotos
def get_command(command):
6 3ccb2618 Nikos Skalkotos
    def find_sbin_command(command, exception):
7 3ccb2618 Nikos Skalkotos
        search_paths = ['/usr/local/sbin', '/usr/sbin', '/sbin']
8 3ccb2618 Nikos Skalkotos
        for fullpath in map(lambda x: "%s/%s" % (x, command), search_paths):
9 3ccb2618 Nikos Skalkotos
            if os.path.exists(fullpath) and os.access(fullpath, os.X_OK):
10 3ccb2618 Nikos Skalkotos
                return pbs.Command(fullpath)
11 3ccb2618 Nikos Skalkotos
        raise exception
12 3ccb2618 Nikos Skalkotos
13 3ccb2618 Nikos Skalkotos
    try:
14 3ccb2618 Nikos Skalkotos
        return pbs.__getattr__(command)
15 3ccb2618 Nikos Skalkotos
    except pbs.CommadNotFount as e:
16 3ccb2618 Nikos Skalkotos
        return find_sbin_command(command, e)