Bug 1455143 - Use a global logger instance; r?Build
MozReview-Commit-ID: 1RyLZBMx6mH
--- a/build/checksums.py
+++ b/build/checksums.py
@@ -5,27 +5,27 @@
from __future__ import with_statement
from optparse import OptionParser
import hashlib
import logging
import os
+logger = logging.getLogger('checksums.py')
def digest_file(filename, digest, chunk_size=1024):
'''Produce a checksum for the file specified by 'filename'. 'filename'
is a string path to a file that is opened and read in this function. The
checksum algorithm is specified by 'digest' and is a valid OpenSSL
algorithm. If the digest used is not valid or Python's hashlib doesn't
work, the None object will be returned instead. The size of blocks
that this function will read from the file object it opens based on
'filename' can be specified by 'chunk_size', which defaults to 1K'''
assert not os.path.isdir(filename), 'this function only works with files'
- logger = logging.getLogger('checksums.py')
logger.debug('Creating new %s object' % digest)
h = hashlib.new(digest)
with open(filename, 'rb') as f:
while True:
data = f.read(chunk_size)
if not data:
logger.debug('Finished reading in file')
@@ -47,17 +47,16 @@ def process_files(files, output_filename
and needs to be a list of valid OpenSSL algorithms.
The output file is written in the format:
<hash> <algorithm> <filesize> <filepath>
Example:
d1fa09a<snip>e4220 sha1 14250744 firefox-4.0b6pre.en-US.mac64.dmg
'''
- logger = logging.getLogger('checksums.py')
if os.path.exists(output_filename):
logger.debug('Overwriting existing checksums file "%s"' %
output_filename)
else:
logger.debug('Creating a new checksums file "%s"' % output_filename)
with open(output_filename, 'w+') as output:
for file in files:
if os.path.isdir(file):
@@ -122,17 +121,16 @@ def main():
loglevel = logging.DEBUG
elif options.quiet:
loglevel = logging.ERROR
else:
loglevel = logging.INFO
# Set up logging
setup_logging(loglevel)
- logger = logging.getLogger('checksums.py')
# Validate the digest type to use
if not options.digests:
options.digests = ['sha1']
# Validate the files to checksum
files = []
for i in args: