Skip to content

Commit 6ba9643

Browse files
committed
Switch from a silent warning to using logging.
That matches what we do elsewhere in the codebase. Signed-off-by: Chris Lalancette <clalancette@gmail.com>
1 parent f670030 commit 6ba9643

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

pycdlib/eltorito.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from __future__ import absolute_import
2020
from __future__ import print_function
2121

22-
import os
22+
import logging
2323
import struct
2424

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

3737

38+
_logger = logging.getLogger('pycdlib')
39+
40+
3841
class EltoritoBootInfoTable(object):
3942
"""
4043
A class that represents an El Torito Boot Info Table. The Boot Info Table
@@ -944,31 +947,19 @@ def hdmbrcheck(disk_mbr, sector_count, bootable):
944947
raise pycdlibexception.PyCdlibInvalidInput('Boot image has multiple partitions')
945948

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

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

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

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

973964
system_type = parttype
974965

0 commit comments

Comments
 (0)