tools/lib/provision: Clean the code to directly read files in binary mode.

This commit is contained in:
Rhea Parekh 2017-12-20 17:49:40 +05:30 committed by showell
parent 5dfd7f030a
commit 6e374d30e1
1 changed files with 3 additions and 4 deletions

View File

@ -212,7 +212,7 @@ def main(options):
for apt_depedency in APT_DEPENDENCIES[codename]: for apt_depedency in APT_DEPENDENCIES[codename]:
sha_sum.update(apt_depedency.encode('utf8')) sha_sum.update(apt_depedency.encode('utf8'))
# hash the content of setup-apt-repo # hash the content of setup-apt-repo
sha_sum.update(open('scripts/lib/setup-apt-repo').read().encode('utf8')) sha_sum.update(open('scripts/lib/setup-apt-repo', 'rb').read())
new_apt_dependencies_hash = sha_sum.hexdigest() new_apt_dependencies_hash = sha_sum.hexdigest()
last_apt_dependencies_hash = None last_apt_dependencies_hash = None
@ -319,7 +319,6 @@ def main(options):
import django import django
django.setup() django.setup()
from zerver.lib.str_utils import force_bytes
from zerver.lib.test_fixtures import is_template_database_current from zerver.lib.test_fixtures import is_template_database_current
try: try:
@ -359,8 +358,8 @@ def main(options):
paths += glob.glob('static/locale/*/translations.json') paths += glob.glob('static/locale/*/translations.json')
for path in paths: for path in paths:
with open(path, 'r') as file_to_hash: with open(path, 'rb') as file_to_hash:
sha1sum.update(force_bytes(file_to_hash.read())) sha1sum.update(file_to_hash.read())
compilemessages_hash_path = os.path.join(UUID_VAR_PATH, "last_compilemessages_hash") compilemessages_hash_path = os.path.join(UUID_VAR_PATH, "last_compilemessages_hash")
new_compilemessages_hash = sha1sum.hexdigest() new_compilemessages_hash = sha1sum.hexdigest()