Skip to content

Commit

Permalink
Auto merge of #4590 - cwsaunders:master, r=str4d
Browse files Browse the repository at this point in the history
Update two dev tool files from Python 2 to Python 3
  • Loading branch information
zkbot committed Jul 29, 2020
2 parents e789632 + 777cda9 commit b1b6512
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions contrib/devtools/fix-copyright-headers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
'''
Run this script inside of src/ and it will look for all the files
that were changed this year that still have the last year in the
Expand Down Expand Up @@ -46,7 +46,7 @@ def getLastGitModifiedDate(filePath):
filePath = os.getcwd() + filePath
modifiedTime = getLastGitModifiedDate(filePath)
if len(modifiedTime) > 0 and str(year) in modifiedTime:
print n,"Last Git Modified: ", modifiedTime, " - ", filePath
print(n,"Last Git Modified: ", modifiedTime, " - ", filePath)
os.popen(command % (last_year,year,filePath))
n = n + 1

Expand Down
14 changes: 7 additions & 7 deletions contrib/devtools/optimize-pngs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import os
import sys
Expand Down Expand Up @@ -44,30 +44,30 @@ def content_hash(filename):
[pngcrush, "-brute", "-ow", "-rem", "gAMA", "-rem", "cHRM", "-rem", "iCCP", "-rem", "sRGB", "-rem", "alla", "-rem", "text", file_path],
stderr=subprocess.STDOUT).rstrip('\n')
except:
print "pngcrush is not installed, aborting..."
print("pngcrush is not installed, aborting...")
sys.exit(0)

#verify
if "Not a PNG file" in subprocess.check_output([pngcrush, "-n", "-v", file_path], stderr=subprocess.STDOUT):
print "PNG file "+file+" is corrupted after crushing, check out pngcursh version"
print("PNG file "+file+" is corrupted after crushing, check out pngcursh version")
sys.exit(1)

fileMetaMap['sha256New'] = file_hash(file_path)
fileMetaMap['contentHashPost'] = content_hash(file_path)

if fileMetaMap['contentHashPre'] != fileMetaMap['contentHashPost']:
print "Image contents of PNG file "+file+" before and after crushing don't match"
print("Image contents of PNG file "+file+" before and after crushing don't match")
sys.exit(1)

fileMetaMap['psize'] = os.path.getsize(file_path)
outputArray.append(fileMetaMap)
print("done\n"),

print "summary:\n+++++++++++++++++"
print("summary:\n+++++++++++++++++")
for fileDict in outputArray:
oldHash = fileDict['sha256Old']
newHash = fileDict['sha256New']
totalSaveBytes += fileDict['osize'] - fileDict['psize']
print fileDict['file']+"\n size diff from: "+str(fileDict['osize'])+" to: "+str(fileDict['psize'])+"\n old sha256: "+oldHash+"\n new sha256: "+newHash+"\n"
print(fileDict['file']+"\n size diff from: "+str(fileDict['osize'])+" to: "+str(fileDict['psize'])+"\n old sha256: "+oldHash+"\n new sha256: "+newHash+"\n")

print "completed. Total reduction: "+str(totalSaveBytes)+" bytes"
print("completed. Total reduction: "+str(totalSaveBytes)+" bytes")

0 comments on commit b1b6512

Please sign in to comment.