Skip to content

Commit

Permalink
Switch from a silent warning to using logging.
Browse files Browse the repository at this point in the history
That matches what we do elsewhere in the codebase.

Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette committed Mar 24, 2024
1 parent f670030 commit 6ba9643
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions pycdlib/eltorito.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from __future__ import absolute_import
from __future__ import print_function

import os
import logging
import struct

from pycdlib import pycdlibexception
Expand All @@ -35,6 +35,9 @@
from pycdlib import udf as udfmod # NOQA pylint: disable=unused-import


_logger = logging.getLogger('pycdlib')


class EltoritoBootInfoTable(object):
"""
A class that represents an El Torito Boot Info Table. The Boot Info Table
Expand Down Expand Up @@ -944,31 +947,19 @@ def hdmbrcheck(disk_mbr, sector_count, bootable):
raise pycdlibexception.PyCdlibInvalidInput('Boot image has multiple partitions')

if bootable and status != PARTITION_STATUS_ACTIVE:
# genisoimage prints a warning in this case, but we have no other
# warning prints in the whole codebase, and an exception will probably
# make us too fragile. So we leave the code but don't do anything.
with open(os.devnull, 'w') as devnull:
print('Warning: partition not marked active', file=devnull)
_logger.warning('Warning: partition not marked active')

cyl = ((s_seccyl & 0xC0) << 10) | s_cyl
sec = s_seccyl & 0x3f
if cyl != 0 or s_head != 1 or sec != 1:
# genisoimage prints a warning in this case, but we have no other
# warning prints in the whole codebase, and an exception will probably
# make us too fragile. So we leave the code but don't do anything.
with open(os.devnull, 'w') as devnull:
print('Warning: partition does not start at 0/1/1', file=devnull)
_logger.warning('Warning: partition does not start at 0/1/1')

cyl = ((e_seccyl & 0xC0) << 10) | e_cyl
sec = e_seccyl & 0x3f
geometry_sectors = (cyl + 1) * (e_head + 1) * sec

if sector_count != geometry_sectors:
# genisoimage prints a warning in this case, but we have no other
# warning prints in the whole codebase, and an exception will probably
# make us too fragile. So we leave the code but don't do anything.
with open(os.devnull, 'w') as devnull:
print('Warning: image size does not match geometry', file=devnull)
_logger.warning('Warning: image size does not match geometry')

system_type = parttype

Expand Down

0 comments on commit 6ba9643

Please sign in to comment.