mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-26 23:05:05 +03:00
c3ececcf96
* ufbt: added "dolphin_ext" target (expects "external" subfolder in cwd with dolphin assets); cleaned up unused code * ufbt: codestyle fixes * scripts: fixed style according to ruff linter * scripts: additional cleanup & codestyle fixes * github: pass target hw code when installing local SDK with ufbt * ufbt: added error message for missing folder in dolphin builder * scripts: more linter fixes * sdk: added flipper_format_stream; ufbt: support for --extra-define * fbt: reduced amount of global defines * scripts, fbt: rearranged imports Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
27 lines
585 B
Python
27 lines
585 B
Python
import datetime
|
|
import hashlib
|
|
|
|
|
|
def timestamp():
|
|
return int(datetime.datetime.now().timestamp())
|
|
|
|
|
|
def file_hash(path: str, algo: str, block_size: int = 4096):
|
|
h = hashlib.new(algo)
|
|
with open(path, "rb") as fd:
|
|
while True:
|
|
data = fd.read(block_size)
|
|
if len(data) > 0:
|
|
h.update(data)
|
|
else:
|
|
break
|
|
return h.hexdigest()
|
|
|
|
|
|
def file_md5(path, block_size=4096):
|
|
return file_hash(path, "md5", block_size)
|
|
|
|
|
|
def file_sha256(path, block_size=4096):
|
|
return file_hash(path, "sha256", block_size)
|