예제 #1
0
def guess_initrd(chroot='', regexp=None):
    """Tries to guess initrd by regexp

    :param chroot: Path to chroot
    :param regexp: (String) Regular expression (must have python syntax).
    Default is r'^(initrd|initramfs).*'
    """
    initrd = utils.guess_filename(path=os.path.join(chroot, 'boot'),
                                  regexp=(regexp or r'^(initrd|initramfs).*'))

    if initrd:
        return initrd

    raise errors.GrubUtilsError('Error while trying to find initrd: '
                                'regexp=%s' % regexp)
예제 #2
0
def guess_kernel(chroot='', regexp=None):
    """Tries to guess kernel by regexp

    :param chroot: Path to chroot
    :param regexp: (String) Regular expression (must have python syntax).
    Default is r'^vmlinuz.*'
    """
    kernel = utils.guess_filename(path=os.path.join(chroot, 'boot'),
                                  regexp=(regexp or r'^vmlinuz.*'))

    if kernel:
        return kernel

    raise errors.GrubUtilsError('Error while trying to find kernel: '
                                'regexp=%s' % regexp)
예제 #3
0
파일: grub.py 프로젝트: openstack/bareon
def guess_kernel(chroot='', regexp=None):
    """Tries to guess kernel by regexp

    :param chroot: Path to chroot
    :param regexp: (String) Regular expression (must have python syntax).
    Default is r'^vmlinuz.*'
    """
    kernel = utils.guess_filename(
        path=os.path.join(chroot, 'boot'),
        regexp=(regexp or r'^vmlinuz.*'))

    if kernel:
        return kernel

    raise errors.GrubUtilsError('Error while trying to find kernel: '
                                'regexp=%s' % regexp)
예제 #4
0
파일: grub.py 프로젝트: openstack/bareon
def guess_initrd(chroot='', regexp=None):
    """Tries to guess initrd by regexp

    :param chroot: Path to chroot
    :param regexp: (String) Regular expression (must have python syntax).
    Default is r'^(initrd|initramfs).*'
    """
    initrd = utils.guess_filename(
        path=os.path.join(chroot, 'boot'),
        regexp=(regexp or r'^(initrd|initramfs).*'))

    if initrd:
        return initrd

    raise errors.GrubUtilsError('Error while trying to find initrd: '
                                'regexp=%s' % regexp)
예제 #5
0
 def test_guess_filename_not_exact_match_forward_sort(self, mock_oslistdir):
     mock_oslistdir.return_value = ["file1", "file2", "file3"]
     filename = utils.guess_filename("/some/path", "^file.*", reverse=False)
     # by default files are sorted in backward direction
     self.assertEqual(filename, "file1")
     mock_oslistdir.assert_called_once_with("/some/path")
예제 #6
0
 def test_guess_filename_not_found(self, mock_oslistdir):
     mock_oslistdir.return_value = ["file1", "file2", "file3"]
     filename = utils.guess_filename("/some/path", "^file4.*")
     self.assertIsNone(filename)
     mock_oslistdir.assert_called_once_with("/some/path")
예제 #7
0
 def test_guess_filename(self, mock_oslistdir):
     mock_oslistdir.return_value = ["file1", "file2", "file3"]
     filename = utils.guess_filename("/some/path", "^file2.*")
     self.assertEqual(filename, "file2")
     mock_oslistdir.assert_called_once_with("/some/path")
예제 #8
0
 def test_guess_filename_not_exact_match_forward_sort(self, mock_oslistdir):
     mock_oslistdir.return_value = ['file1', 'file2', 'file3']
     filename = utils.guess_filename('/some/path', '^file.*', reverse=False)
     # by default files are sorted in backward direction
     self.assertEqual(filename, 'file1')
     mock_oslistdir.assert_called_once_with('/some/path')
예제 #9
0
 def test_guess_filename_not_found(self, mock_oslistdir):
     mock_oslistdir.return_value = ['file1', 'file2', 'file3']
     filename = utils.guess_filename('/some/path', '^file4.*')
     self.assertIsNone(filename)
     mock_oslistdir.assert_called_once_with('/some/path')
예제 #10
0
 def test_guess_filename(self, mock_oslistdir):
     mock_oslistdir.return_value = ['file1', 'file2', 'file3']
     filename = utils.guess_filename('/some/path', '^file2.*')
     self.assertEqual(filename, 'file2')
     mock_oslistdir.assert_called_once_with('/some/path')
예제 #11
0
 def test_guess_filename_not_exact_match_forward_sort(self, mock_oslistdir):
     mock_oslistdir.return_value = ['file1', 'file2', 'file3']
     filename = utils.guess_filename('/some/path', '^file.*', reverse=False)
     # by default files are sorted in backward direction
     self.assertEqual(filename, 'file1')
     mock_oslistdir.assert_called_once_with('/some/path')
예제 #12
0
 def test_guess_filename_not_found(self, mock_oslistdir):
     mock_oslistdir.return_value = ['file1', 'file2', 'file3']
     filename = utils.guess_filename('/some/path', '^file4.*')
     self.assertIsNone(filename)
     mock_oslistdir.assert_called_once_with('/some/path')
예제 #13
0
 def test_guess_filename(self, mock_oslistdir):
     mock_oslistdir.return_value = ['file1', 'file2', 'file3']
     filename = utils.guess_filename('/some/path', '^file2.*')
     self.assertEqual(filename, 'file2')
     mock_oslistdir.assert_called_once_with('/some/path')