Merge "releasetools: Address pylint warnings in add_img_to_target_files.py."

This commit is contained in:
Tao Bao
2017-12-05 19:13:04 +00:00
committed by Gerrit Code Review

View File

@@ -45,18 +45,13 @@ Usage: add_img_to_target_files [flag] target_files
from __future__ import print_function from __future__ import print_function
import sys
if sys.hexversion < 0x02070000:
print("Python 2.7 or newer is required.", file=sys.stderr)
sys.exit(1)
import datetime import datetime
import hashlib import hashlib
import os import os
import shlex import shlex
import shutil import shutil
import subprocess import subprocess
import sys
import tempfile import tempfile
import uuid import uuid
import zipfile import zipfile
@@ -66,6 +61,10 @@ import common
import rangelib import rangelib
import sparse_img import sparse_img
if sys.hexversion < 0x02070000:
print("Python 2.7 or newer is required.", file=sys.stderr)
sys.exit(1)
OPTIONS = common.OPTIONS OPTIONS = common.OPTIONS
OPTIONS.add_missing = False OPTIONS.add_missing = False
@@ -388,9 +387,9 @@ def AddVBMeta(output_zip, partitions, prefix="IMAGES/"):
if os.path.exists(image_path): if os.path.exists(image_path):
continue continue
found = False found = False
for dir in ['IMAGES', 'RADIO', 'VENDOR_IMAGES', 'PREBUILT_IMAGES']: for dir_name in ['IMAGES', 'RADIO', 'VENDOR_IMAGES', 'PREBUILT_IMAGES']:
alt_path = os.path.join( alt_path = os.path.join(
OPTIONS.input_tmp, dir, os.path.basename(image_path)) OPTIONS.input_tmp, dir_name, os.path.basename(image_path))
if os.path.exists(alt_path): if os.path.exists(alt_path):
split_args[index + 1] = alt_path split_args[index + 1] = alt_path
found = True found = True
@@ -657,8 +656,6 @@ def AddImagesToTargetFiles(filename):
continue continue
img_radio_path = os.path.join(OPTIONS.input_tmp, "RADIO", img_name) img_radio_path = os.path.join(OPTIONS.input_tmp, "RADIO", img_name)
img_vendor_dir = os.path.join(
OPTIONS.input_tmp, "VENDOR_IMAGES")
if os.path.exists(img_radio_path): if os.path.exists(img_radio_path):
if output_zip: if output_zip:
common.ZipWrite(output_zip, img_radio_path, common.ZipWrite(output_zip, img_radio_path,
@@ -666,6 +663,7 @@ def AddImagesToTargetFiles(filename):
else: else:
shutil.copy(img_radio_path, prebuilt_path) shutil.copy(img_radio_path, prebuilt_path)
else: else:
img_vendor_dir = os.path.join(OPTIONS.input_tmp, "VENDOR_IMAGES")
for root, _, files in os.walk(img_vendor_dir): for root, _, files in os.walk(img_vendor_dir):
if img_name in files: if img_name in files:
if output_zip: if output_zip: