1
mirror of https://github.com/home-assistant/core synced 2024-09-15 17:29:45 +02:00
ha-core/script/fingerprint_frontend.py
Michaël Arnauts c864ea60c9 Improve development workflow in docker (#5079)
* Allow bower install of frontend components as root. Needed for frontend development in docker since everything runs as root in the docker image.

* Improve development workflow in docker

* Use LANG=C.UTF-8 in tox. Fixes installation of libraries with UTF-8 in it's readme.

* Install mysqlclient psycopg2 uvloop after requirements_all.txt again, but with a --no-cache-dir this time. Allows bootstrap_frontend to be executed in a different path like the other scripts.
2017-01-02 22:04:09 +01:00

40 lines
993 B
Python
Executable File

#!/usr/bin/env python3
"""Generate a file with all md5 hashes of the assets."""
from collections import OrderedDict
import glob
import hashlib
import json
fingerprint_file = 'homeassistant/components/frontend/version.py'
base_dir = 'homeassistant/components/frontend/www_static/'
def fingerprint():
"""Fingerprint the frontend files."""
files = (glob.glob(base_dir + '**/*.html') +
glob.glob(base_dir + '*.html') +
glob.glob(base_dir + 'core.js'))
md5s = OrderedDict()
for fil in sorted(files):
name = fil[len(base_dir):]
with open(fil) as fp:
md5 = hashlib.md5(fp.read().encode('utf-8')).hexdigest()
md5s[name] = md5
template = """\"\"\"DO NOT MODIFY. Auto-generated by script/fingerprint_frontend.\"\"\"
FINGERPRINTS = {}
"""
result = template.format(json.dumps(md5s, indent=4))
with open(fingerprint_file, 'w') as fp:
fp.write(result)
if __name__ == '__main__':
fingerprint()