allow lazy expansion of log format strings

Signed-off-by: Nils Philippsen <nils@redhat.com>
This commit is contained in:
Nils Philippsen 2019-11-25 17:57:17 +01:00
parent 6e574a5067
commit f01960d719

View file

@ -33,8 +33,7 @@ log = logging.getLogger(__name__)
def download_db(name, repomd_url, archive):
log.info('%s Downloading file: %s to %s' % (
name.ljust(12), repomd_url, archive))
log.info('%-12s Downloading file: %s to %s', name, repomd_url, archive)
response = requests.get(repomd_url, verify=True)
with open(archive, 'wb') as stream:
stream.write(response.content)
@ -42,7 +41,7 @@ def download_db(name, repomd_url, archive):
def decompress_db(name, archive, location):
''' Decompress the given archive at the specified location. '''
log.info('%s Extracting %s to %s' % (name.ljust(12), archive, location))
log.info('%-12s Extracting %s to %s', name, archive, location)
if archive.endswith('.xz'):
import lzma
with contextlib.closing(lzma.LZMAFile(archive)) as stream_xz:
@ -140,8 +139,8 @@ def get_primary_xml(destfolder, url, name):
# Have we downloaded this before? Did it change?
destfile = os.path.join(destfolder, db)
if not needs_update(destfile, shasum, shatype):
log.debug('%s No change of %s' % (name.ljust(12), repomd_url))
if not needs_update(destfile, hash_digest, hash_type):
log.debug('%s No change of %s', name.ljust(12), repomd_url)
else:
# If it has changed, then download it and move it into place.
archive = os.path.join(destfolder, filename)