provision: Rename file_hash_updated to file_or_package_hash_updated.

Check for changes in package version as well along
with the files.
This commit is contained in:
Vishnu Ks 2018-06-22 16:26:25 +05:30
parent 431d9d6076
commit 109fa85614
2 changed files with 13 additions and 6 deletions

View File

@ -313,13 +313,20 @@ def parse_lsb_release():
distro_info[k] = v
return distro_info
def file_hash_updated(paths, hash_name, is_force):
# type: (List[str], str, bool) -> bool
def file_or_package_hash_updated(paths, hash_name, is_force, package_versions=[]):
# type: (List[str], str, bool, List[str]) -> bool
# Check whether the files or package_versions passed as arguments
# changed compared to the last execution.
sha1sum = hashlib.sha1()
for path in paths:
with open(path, 'rb') as file_to_hash:
sha1sum.update(file_to_hash.read())
# The ouput of tools like build_pygments_data depends
# on the version of some pip packages as well.
for package_version in package_versions:
sha1sum.update(package_version.encode("utf-8"))
hash_path = os.path.join(get_dev_uuid_var_path(), hash_name)
new_hash = sha1sum.hexdigest()
run(['touch', hash_path])

View File

@ -14,7 +14,7 @@ ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__f
sys.path.append(ZULIP_PATH)
from scripts.lib.zulip_tools import run, subprocess_text_output, OKBLUE, ENDC, WARNING, \
get_dev_uuid_var_path, FAIL, parse_lsb_release, file_hash_updated
get_dev_uuid_var_path, FAIL, parse_lsb_release, file_or_package_hash_updated
from scripts.lib.setup_venv import (
setup_virtualenv, VENV_DEPENDENCIES, THUMBOR_VENV_DEPENDENCIES
)
@ -296,7 +296,7 @@ def main(options):
webfont_paths = ["tools/generate-custom-icon-webfont", "static/icons/fonts/template.hbs"]
webfont_paths += glob.glob('static/assets/icons/*')
if file_hash_updated(webfont_paths, "webfont_files_hash", options.is_force):
if file_or_package_hash_updated(webfont_paths, "webfont_files_hash", options.is_force):
run(["tools/generate-custom-icon-webfont"])
else:
print("No need to run `tools/generate-custom-icon-webfont`.")
@ -307,7 +307,7 @@ def main(options):
email_source_paths = ["tools/inline-email-css", "templates/zerver/emails/email.css"]
email_source_paths += glob.glob('templates/zerver/emails/*.source.html')
if file_hash_updated(email_source_paths, "last_email_source_files_hash", options.is_force):
if file_or_package_hash_updated(email_source_paths, "last_email_source_files_hash", options.is_force):
run(["tools/inline-email-css"])
else:
print("No need to run `tools/inline-email-css`.")
@ -377,7 +377,7 @@ def main(options):
paths += glob.glob('static/locale/*/LC_MESSAGES/*.po')
paths += glob.glob('static/locale/*/translations.json')
if file_hash_updated(paths, "last_compilemessages_hash", options.is_force):
if file_or_package_hash_updated(paths, "last_compilemessages_hash", options.is_force):
run(["./manage.py", "compilemessages"])
else:
print("No need to run `manage.py compilemessages`.")