INNER CODE UNIT · Python

_get_local_md5sum

codematrixer/hmdriver2 · hmdriver2/_client.py:205

    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()
        return "exists" in result

    def _setup_device_agent(self, local_path: str, remote_path: str):
        """Ensure the remote agent file is correctly set up."""
        if self._is_remote_file_exists(remote_path):
            local_md5 = self._get_local_md5sum(local_path)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…