當前位置: 首頁>>代碼示例>>Python>>正文


Python iso.Iso類代碼示例

本文整理匯總了Python中kiwi.iso.Iso的典型用法代碼示例。如果您正苦於以下問題:Python Iso類的具體用法?Python Iso怎麽用?Python Iso使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Iso類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_relocate_boot_catalog

    def test_relocate_boot_catalog(self, mock_open):
        mock_open.return_value = self.context_manager_mock
        volume_descriptor = \
            'CD001' + '_' * (0x08c - 0x5) + '0x1d5f23a'
        eltorito_descriptor = \
            'EL TORITO SPECIFICATION' + '_' * (0x47 - 0x17) + '0x1d5f23a'
        new_volume_descriptor = \
            'bogus'
        next_new_volume_descriptor = \
            'TEA01'
        new_boot_catalog = format('\x00' * 0x800)
        read_results = [
            new_boot_catalog,
            next_new_volume_descriptor,
            new_volume_descriptor,
            'catalog',
            eltorito_descriptor,
            volume_descriptor
        ]

        def side_effect(arg):
            return read_results.pop()

        self.file_mock.read.side_effect = side_effect

        Iso.relocate_boot_catalog('isofile')
        assert self.file_mock.write.call_args_list == [
            call('catalog'),
            call(
                'EL TORITO SPECIFICATION' +
                '_' * (0x47 - 0x17) + '\x13\x00\x00\x005f23a'
            )
        ]
開發者ID:k0da,項目名稱:kiwi-1,代碼行數:33,代碼來源:iso_test.py

示例2: test_relocate_boot_catalog

    def test_relocate_boot_catalog(self, mock_open):
        mock_open.return_value = self.context_manager_mock
        volume_descriptor = \
            bytes(b'CD001') + bytes(b'_') * (0x08c - 0x5) + bytes(b'0x1d5f23a')
        eltorito_descriptor = \
            bytes(b'EL TORITO SPECIFICATION') + bytes(b'_') * (0x47 - 0x17) + bytes(b'0x1d5f23a')
        new_volume_descriptor = \
            bytes(b'bogus')
        next_new_volume_descriptor = \
            bytes(b'TEA01')
        new_boot_catalog = bytes(b'\x00') * 0x800
        read_results = [
            new_boot_catalog,
            next_new_volume_descriptor,
            new_volume_descriptor,
            bytes(b'catalog'),
            eltorito_descriptor,
            volume_descriptor
        ]

        def side_effect(arg):
            return read_results.pop()

        self.file_mock.read.side_effect = side_effect

        Iso.relocate_boot_catalog('isofile')
        assert self.file_mock.write.call_args_list == [
            call(bytes(b'catalog')),
            call(
                bytes(b'EL TORITO SPECIFICATION') +
                bytes(b'_') * (0x47 - 0x17) + bytes(b'\x13\x00\x00\x005f23a')
            )
        ]
開發者ID:ChrisBr,項目名稱:kiwi,代碼行數:33,代碼來源:iso_test.py

示例3: test_create_hybrid_with_error

 def test_create_hybrid_with_error(self, mock_command):
     mbrid = mock.Mock()
     mbrid.get_id = mock.Mock(
         return_value='0x0815'
     )
     command = mock.Mock()
     command.error = 'some error message'
     mock_command.return_value = command
     Iso.create_hybrid(42, mbrid, 'some-iso', 'efi')
開發者ID:AdamMajer,項目名稱:kiwi-ng,代碼行數:9,代碼來源:iso_test.py

示例4: test_iso_metadata_path_table_sector_invalid

    def test_iso_metadata_path_table_sector_invalid(self, mock_open):
        mock_open.return_value = self.context_manager_mock
        read_results = [bytes(b'EL TORITO SPECIFICATION'), bytes(b'CD001')]

        def side_effect(arg):
            return read_results.pop()

        self.file_mock.read.side_effect = side_effect
        Iso.fix_boot_catalog('isofile')
開發者ID:ChrisBr,項目名稱:kiwi,代碼行數:9,代碼來源:iso_test.py

示例5: test_iso_metadata_catalog_sector_invalid

    def test_iso_metadata_catalog_sector_invalid(self, mock_open):
        mock_open.return_value = self.context_manager_mock
        volume_descriptor = \
            bytes(b'CD001') + bytes(b'_') * (0x08c - 0x5) + bytes(b'0x1d5f23a')
        read_results = [bytes(b'EL TORITO SPECIFICATION'), volume_descriptor]

        def side_effect(arg):
            return read_results.pop()

        self.file_mock.read.side_effect = side_effect
        Iso.fix_boot_catalog('isofile')
開發者ID:ChrisBr,項目名稱:kiwi,代碼行數:11,代碼來源:iso_test.py

示例6: test_create_hybrid_with_multiple_errors

 def test_create_hybrid_with_multiple_errors(self, mock_command):
     mbrid = mock.Mock()
     mbrid.get_id = mock.Mock(
         return_value='0x0815'
     )
     command = mock.Mock()
     command.error = \
         'isohybrid: Warning: more than 1024 cylinders: 1817\n' + \
         'isohybrid: Not all BIOSes will be able to boot this device\n' + \
         'isohybrid: some other error we do not ignore'
     mock_command.return_value = command
     Iso.create_hybrid(42, mbrid, 'some-iso', 'efi')
開發者ID:AdamMajer,項目名稱:kiwi-ng,代碼行數:12,代碼來源:iso_test.py

示例7: test_create_hybrid

 def test_create_hybrid(self, mock_command):
     mbrid = mock.Mock()
     mbrid.get_id = mock.Mock(
         return_value='0x0815'
     )
     Iso.create_hybrid(42, mbrid, 'some-iso')
     mock_command.assert_called_once_with(
         [
             'isohybrid', '--offset', '42',
             '--id', '0x0815', '--type', '0x83',
             '--uefi', 'some-iso'
         ]
     )
開發者ID:ChrisBr,項目名稱:kiwi,代碼行數:13,代碼來源:iso_test.py

示例8: test_iso_metadata_catalog_invalid

    def test_iso_metadata_catalog_invalid(self, mock_open):
        mock_open.return_value = self.context_manager_mock
        volume_descriptor = \
            'CD001' + '_' * (0x08c - 0x5) + '0x1d5f23a'
        eltorito_descriptor = \
            'EL TORITO SPECIFICATION' + '_' * (0x47 - 0x17) + '0x1d5f23a'
        read_results = [eltorito_descriptor, volume_descriptor]

        def side_effect(arg):
            return read_results.pop()

        self.file_mock.read.side_effect = side_effect
        Iso.fix_boot_catalog('isofile')
開發者ID:k0da,項目名稱:kiwi-1,代碼行數:13,代碼來源:iso_test.py

示例9: test_create_hybrid_with_cylinders_warning

 def test_create_hybrid_with_cylinders_warning(self, mock_command):
     mbrid = mock.Mock()
     mbrid.get_id = mock.Mock(
         return_value='0x0815'
     )
     command = mock.Mock()
     command.error = \
         'isohybrid: Warning: more than 1024 cylinders: 1817\n' + \
         'isohybrid: Not all BIOSes will be able to boot this device\n'
     mock_command.return_value = command
     Iso.create_hybrid(42, mbrid, 'some-iso', 'efi')
     mock_command.assert_called_once_with(
         [
             'isohybrid', '--offset', '42',
             '--id', '0x0815', '--type', '0x83',
             '--uefi', 'some-iso'
         ]
     )
開發者ID:AdamMajer,項目名稱:kiwi-ng,代碼行數:18,代碼來源:iso_test.py

示例10: test_fix_boot_catalog

    def test_fix_boot_catalog(self, mock_open):
        mock_open.return_value = self.context_manager_mock
        volume_descriptor = \
            bytes(b'CD001') + bytes(b'_') * (0x08c - 0x5) + bytes(b'0x1d5f23a')
        eltorito_descriptor = \
            bytes(b'EL TORITO SPECIFICATION') + \
            bytes(b'_') * (0x47 - 0x17) + bytes(b'0x1d5f23a')
        boot_catalog = bytes(b'_') * 64 + struct.pack('B', 0x88) + \
            bytes(b'_') * 32
        read_results = [
            boot_catalog,
            eltorito_descriptor,
            volume_descriptor
        ]

        def side_effect(arg):
            return read_results.pop()

        self.file_mock.read.side_effect = side_effect

        Iso.fix_boot_catalog('isofile')

        if sys.byteorder == 'big':
            assert self.file_mock.write.call_args_list == [
                call(
                    bytes(b'_') * 44 +
                    bytes(b'\x01Legacy (isolinux)\x00\x00\x91\xef\x00\x01') +
                    bytes(b'\x00') * 28 +
                    bytes(b'\x88___________\x01UEFI (grub)') +
                    bytes(b'\x00') * 8
                )
            ]
        else:
            assert self.file_mock.write.call_args_list == [
                call(
                    bytes(b'_') * 44 +
                    bytes(b'\x01Legacy (isolinux)\x00\x00\x91\xef\x01') +
                    bytes(b'\x00') * 29 +
                    bytes(b'\x88___________\x01UEFI (grub)') +
                    bytes(b'\x00') * 8
                )
            ]
開發者ID:AdamMajer,項目名稱:kiwi-ng,代碼行數:42,代碼來源:iso_test.py

示例11: setup

    def setup(self, mock_machine, mock_tempfile):
        temp_type = namedtuple(
            'temp_type', ['name']
        )
        mock_machine.return_value = 'x86_64'
        mock_tempfile.return_value = temp_type(
            name='sortfile'
        )
        self.context_manager_mock = mock.Mock()
        self.file_mock = mock.Mock()
        self.enter_mock = mock.Mock()
        self.exit_mock = mock.Mock()
        self.enter_mock.return_value = self.file_mock
        setattr(self.context_manager_mock, '__enter__', self.enter_mock)
        setattr(self.context_manager_mock, '__exit__', self.exit_mock)

        self.iso = Iso('source-dir')
開發者ID:ChrisBr,項目名稱:kiwi,代碼行數:17,代碼來源:iso_test.py

示例12: create_on_file

    def create_on_file(self, filename, label=None, exclude=None):
        """
        Create iso filesystem from data tree

        There is no label which could be set for iso filesystem
        thus this parameter is not used

        :param string filename: result file path name
        :param string label: unused
        :param string exclude: unused
        """
        iso = Iso(self.root_dir)
        iso.init_iso_creation_parameters(
            self.custom_args['create_options']
        )
        iso.add_efi_loader_parameters()
        Command.run(
            [
                self._find_iso_creation_tool()
            ] + iso.get_iso_creation_parameters() + [
                '-o', filename, self.root_dir
            ]
        )
        hybrid_offset = iso.create_header_end_block(filename)
        Command.run(
            [
                self._find_iso_creation_tool(),
                '-hide', iso.header_end_name,
                '-hide-joliet', iso.header_end_name
            ] + iso.get_iso_creation_parameters() + [
                '-o', filename, self.root_dir
            ]
        )
        iso.relocate_boot_catalog(filename)
        iso.fix_boot_catalog(filename)
        return hybrid_offset
開發者ID:AdamMajer,項目名稱:kiwi-ng,代碼行數:36,代碼來源:isofs.py

示例13: test_iso_metadata_not_bootable

 def test_iso_metadata_not_bootable(self, mock_open):
     mock_open.return_value = self.context_manager_mock
     self.file_mock.read.return_value = bytes(b'CD001')
     Iso.fix_boot_catalog('isofile')
開發者ID:ChrisBr,項目名稱:kiwi,代碼行數:4,代碼來源:iso_test.py

示例14: test_iso_metadata_iso9660_invalid

 def test_iso_metadata_iso9660_invalid(self, mock_open):
     mock_open.return_value = self.context_manager_mock
     self.file_mock.read.return_value = bytes(b'bogus')
     Iso.fix_boot_catalog('isofile')
開發者ID:ChrisBr,項目名稱:kiwi,代碼行數:4,代碼來源:iso_test.py

示例15: TestIso

class TestIso(object):
    @patch('kiwi.iso.NamedTemporaryFile')
    @patch('platform.machine')
    def setup(self, mock_machine, mock_tempfile):
        temp_type = namedtuple(
            'temp_type', ['name']
        )
        mock_machine.return_value = 'x86_64'
        mock_tempfile.return_value = temp_type(
            name='sortfile'
        )
        self.context_manager_mock = mock.Mock()
        self.file_mock = mock.Mock()
        self.enter_mock = mock.Mock()
        self.exit_mock = mock.Mock()
        self.enter_mock.return_value = self.file_mock
        setattr(self.context_manager_mock, '__enter__', self.enter_mock)
        setattr(self.context_manager_mock, '__exit__', self.exit_mock)

        self.iso = Iso('source-dir')

    @patch_open
    @patch('os.path.exists')
    @raises(KiwiIsoLoaderError)
    def test_init_iso_creation_parameters_no_loader(
        self, mock_exists, mock_open
    ):
        mock_exists.return_value = False
        self.iso.init_iso_creation_parameters()

    @patch('kiwi.iso.NamedTemporaryFile')
    @patch('platform.machine')
    def test_init_for_ix86_platform(self, mock_machine, mock_tempfile):
        mock_machine.return_value = 'i686'
        iso = Iso('source-dir')
        assert iso.arch == 'ix86'

    @patch_open
    @patch('kiwi.iso.Command.run')
    @patch('os.path.exists')
    @patch('os.walk')
    def test_init_iso_creation_parameters(
        self, mock_walk, mock_exists, mock_command, mock_open
    ):
        mock_walk.return_value = [
            ('source-dir', ('bar', 'baz'), ('efi', 'eggs', 'header_end'))
        ]
        mock_exists.return_value = True
        mock_open.return_value = self.context_manager_mock

        self.iso.init_iso_creation_parameters(['custom_arg'])

        assert self.file_mock.write.call_args_list == [
            call('7984fc91-a43f-4e45-bf27-6d3aa08b24cf\n'),
            call('source-dir/boot/x86_64/boot.catalog 3\n'),
            call('source-dir/boot/x86_64/loader/isolinux.bin 2\n'),
            call('source-dir/efi 1000001\n'),
            call('source-dir/eggs 1\n'),
            call('source-dir/header_end 1000000\n'),
            call('source-dir/bar 1\n'),
            call('source-dir/baz 1\n')
        ]
        assert self.iso.iso_parameters == [
            'custom_arg', '-R', '-J', '-f', '-pad', '-joliet-long',
            '-sort', 'sortfile', '-no-emul-boot', '-boot-load-size', '4',
            '-boot-info-table',
            '-hide', 'boot/x86_64/boot.catalog',
            '-hide-joliet', 'boot/x86_64/boot.catalog',
        ]
        assert self.iso.iso_loaders == [
            '-b', 'boot/x86_64/loader/isolinux.bin',
            '-c', 'boot/x86_64/boot.catalog'
        ]
        mock_command.assert_called_once_with(
            [
                'isolinux-config', '--base', 'boot/x86_64/loader',
                'source-dir/boot/x86_64/loader/isolinux.bin'
            ]
        )

    @patch_open
    @patch('kiwi.iso.Command.run')
    @patch('kiwi.iso.Path.create')
    @patch('os.path.exists')
    @patch('os.walk')
    def test_init_iso_creation_parameters_failed_isolinux_config(
        self, mock_walk, mock_exists, mock_path, mock_command, mock_open
    ):
        mock_exists.return_value = True
        mock_open.return_value = self.context_manager_mock
        command_raises = [False, True]

        def side_effect(arg):
            if command_raises.pop():
                raise Exception

        mock_command.side_effect = side_effect

        self.iso.init_iso_creation_parameters(['custom_arg'])

#.........這裏部分代碼省略.........
開發者ID:ChrisBr,項目名稱:kiwi,代碼行數:101,代碼來源:iso_test.py


注:本文中的kiwi.iso.Iso類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。