releasetools: Switch to Python logging.

Converts the following files to Python logging.

add_img_to_target_files.py
blockimgdiff.py
build_image.py
check_ota_package_signature.py
common.py
img_from_target_files.py
make_recovery_patch.py
ota_from_target_files.py
sparse_img.py
verity_utils.py

This separates logging outputs from normal outputs, and allows easier
switching between different verbosity levels. It also supports adjusting
logging config via environment variable (LOGGING_CONFIG).

Test: `m dist`
Test: `python -m unittest discover build/make/tools/releasetools`
Change-Id: Idfc3f7aff83e03f41f3c9b5067d64fd595d5192d
This commit is contained in:
Tao Bao
2018-10-12 10:30:39 -07:00
parent bcd3d85971
commit 32fcdab512
10 changed files with 247 additions and 182 deletions

View File

@@ -13,6 +13,7 @@
# limitations under the License.
import bisect
import logging
import os
import struct
import threading
@@ -20,6 +21,8 @@ from hashlib import sha1
import rangelib
logger = logging.getLogger(__name__)
class SparseImage(object):
"""Wraps a sparse image file into an image object.
@@ -61,8 +64,9 @@ class SparseImage(object):
raise ValueError("Chunk header size was expected to be 12, but is %u." %
(chunk_hdr_sz,))
print("Total of %u %u-byte output blocks in %u input chunks."
% (total_blks, blk_sz, total_chunks))
logger.info(
"Total of %u %u-byte output blocks in %u input chunks.", total_blks,
blk_sz, total_chunks)
if not build_map:
assert not hashtree_info_generator, \