Bug 1455143 - Handle directory inputs earlier; r=ted
authorGregory Szorc <gps@mozilla.com>
Wed, 18 Apr 2018 15:35:57 -0700
changeset 468154 2bbe78c011d3a4631a3a34b47811564463ab66e5
parent 468153 e6d309fde362cef30e20aba408958cbce3884425
child 468155 c9cbbb881c78d5d928b3a6453c1f46940c6f3758
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs1455143
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1455143 - Handle directory inputs earlier; r=ted This makes the logic in process_files() simpler. MozReview-Commit-ID: KdphRJZLinx
build/checksums.py
--- a/build/checksums.py
+++ b/build/checksums.py
@@ -54,33 +54,30 @@ def process_files(files, output_filename
 
     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):
-                logger.warn('%s is a directory, skipping' % file)
-            else:
-                for digest in digests:
-                    hash = digest_file(file, digest)
-                    if hash is None:
-                        logger.warn('Unable to generate a hash for %s. ' +
-                                    'Skipping.' % file)
-                        continue
-                    if file.startswith(strip):
-                        short_file = file[len(strip):]
-                        short_file = short_file.lstrip('/')
-                    else:
-                        short_file = file
-                    print >>output, '%s %s %s %s' % (hash, digest,
-                                                     os.path.getsize(file),
-                                                     short_file)
+            for digest in digests:
+                hash = digest_file(file, digest)
+                if hash is None:
+                    logger.warn('Unable to generate a hash for %s. ' +
+                                'Skipping.' % file)
+                    continue
+                if file.startswith(strip):
+                    short_file = file[len(strip):]
+                    short_file = short_file.lstrip('/')
+                else:
+                    short_file = file
+                print >>output, '%s %s %s %s' % (hash, digest,
+                                                 os.path.getsize(file),
+                                                 short_file)
 
 
 def setup_logging(level=logging.DEBUG):
     '''This function sets up the logging module using a speficiable logging
     module logging level.  The default log level is DEBUG.
 
     The output is in the format:
         <level> - <message>
@@ -129,17 +126,19 @@ def main():
 
     # Validate the digest type to use
     if not options.digests:
         options.digests = ['sha1']
 
     # Validate the files to checksum
     files = []
     for i in args:
-        if os.path.exists(i):
+        if os.path.isdir(i):
+            logger.warn('%s is a directory; ignoring' % i)
+        elif os.path.exists(i):
             files.append(i)
         else:
             logger.info('File "%s" was not found on the filesystem' % i)
     process_files(files, options.outfile, options.digests, options.strip)
 
 
 if __name__ == '__main__':
     main()