INNER CODE UNIT · Python
_get_remote_md5sum
codematrixer/hmdriver2 · hmdriver2/_client.py:199
def _get_remote_md5sum(self, file_path: str) -> Optional[str]:
"""Get the MD5 checksum of a remote file."""
command = f"md5sum {file_path}"
output = self.hdc.shell(command).output.strip()
return output.split()[0] if output else None
def _get_local_md5sum(self, file_path: str) -> str:
"""Get the MD5 checksum of a local file."""
hash_md5 = hashlib.md5()
with open(file_path, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return hash_md5.hexdigest()
def _is_remote_file_exists(self, file_path: str) -> bool:
"""Check if a file exists on the device."""
command = f"[ -f {file_path} ] && echo 'exists' || echo 'not exists'"
result = self.hdc.shell(command).output.strip()