Esempio n. 1
0
 def check(self):
     if not os.access(self.executable, os.X_OK):
         if self.package:
             pkgmgr.installed(self.package)
         else:
             msg = 'Executable %s is not found, you should either ' \
                 'specify `package` attribute or install the software ' \
                 'manually' % (self.executable)
             raise linux.LinuxError(msg)
Esempio n. 2
0
    def check(self):
        if not self.executable.startswith('/'):
            exec_paths = software.whereis(self.executable)
            exec_path = exec_paths[0] if exec_paths else None
        else:
            exec_path = self.executable

        if not exec_path or not os.access(exec_path, os.X_OK):
            if self.package:
                pkgmgr.installed(self.package)

            else:
                msg = 'Executable %s is not found, you should either ' \
                      'specify `package` attribute or install the software ' \
                      'manually' % self.executable
                raise linux.LinuxError(msg)
Esempio n. 3
0
def test_umount_not_mounted():
    m = mock.Mock(side_effect=linux.LinuxError(
        '', '', 'umount: /mnt: not mounted\n', 1, ()))
    with mock.patch('scalarizr.linux.system', m):
        mount.umount('/mnt')
        assert m.called
Esempio n. 4
0
def test_umount_raise_error():
    m = mock.Mock(side_effect=linux.LinuxError(
        '', '', 'umount: /: device is busy.\n', 1, ()))
    with mock.patch('scalarizr.linux.system', m):
        mount.umount('/')
Esempio n. 5
0
def test_mount_no_filesystem():
    m = mock.Mock(side_effect=linux.LinuxError(
        '', '', 'mount: you must specify the filesystem type\n', 32, ()))
    with mock.patch('scalarizr.linux.system', m):
        mount.mount('/dev/sdb', '/mnt')