MCPcopy Index your code
hub / github.com/python/cpython / verifyThirdPartyFile

Function verifyThirdPartyFile

Mac/BuildScript/build-installer.py:795–817  ·  view source on GitHub ↗

Download file from url to filename fname if it does not already exist. Abort if file contents does not match supplied md5 checksum.

(url, checksum, fname)

Source from the content-addressed store, hash-verified

793 pass
794
795def verifyThirdPartyFile(url, checksum, fname):
796 """
797 Download file from url to filename fname if it does not already exist.
798 Abort if file contents does not match supplied md5 checksum.
799 """
800 name = os.path.basename(fname)
801 if os.path.exists(fname):
802 print("Using local copy of %s"%(name,))
803 else:
804 print("Did not find local copy of %s"%(name,))
805 print("Downloading %s"%(name,))
806 downloadURL(url, fname)
807 print("Archive for %s stored as %s"%(name, fname))
808 if len(checksum) == 32:
809 algo = 'md5'
810 elif len(checksum) == 64:
811 algo = 'sha256'
812 else:
813 raise ValueError(checksum)
814 if os.system(
815 'CHECKSUM=$(openssl %s %s) ; test "${CHECKSUM##*= }" = "%s"'
816 % (algo, shellQuote(fname), checksum) ):
817 fatal('%s checksum mismatch for file %s' % (algo, fname))
818
819def build_universal_openssl(basedir, archList):
820 """

Callers 1

buildRecipeFunction · 0.85

Calls 5

downloadURLFunction · 0.85
shellQuoteFunction · 0.85
fatalFunction · 0.70
basenameMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…