diff --git a/README.md b/README.md index 1b15ba9..c764fa7 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ - Md-aliy7 - npalmerDNX - Andreas-strg + - oxbown ## Usage See [lsv2_demo.py](https://github.com/drunsinn/pyLSV2/blob/master/pyLSV2/demos/lsv2_demo.py) for a demonstration of some of the functions. diff --git a/pyLSV2/client.py b/pyLSV2/client.py index 65fc7b8..6babd6d 100644 --- a/pyLSV2/client.py +++ b/pyLSV2/client.py @@ -175,7 +175,8 @@ def _send_recive( self._logger.debug("unknown or unsupported system command %s", bytes_to_send) return False - lsv_content = self._llcom.telegram(command, bytes_to_send) + wait_for_response = bool(expected_response is not lc.RSP.NONE) + lsv_content = self._llcom.telegram(command, bytes_to_send, wait_for_response) if self._llcom.last_response is lc.RSP.UNKNOWN: self._logger.error("unknown response received") diff --git a/pyproject.toml b/pyproject.toml index 58dd027..c490043 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,6 +54,10 @@ log_cli = true log_cli_level = "INFO" log_format = "%(asctime)s %(levelname)s %(message)s" log_date_format = "%Y-%m-%d %H:%M:%S" +addopts = "--address 192.168.56.101" +#addopts = "--address 192.168.56.102" +#addopts = "--address 192.168.56.103" +#addopts = "--address localhost" [tool.codespell] skip = "*.po,*.ts,./docs/_build,./docs/_static,./.git" diff --git a/tests/test_transfer.py b/tests/test_transfer.py index 0d3c98a..0e40f19 100644 --- a/tests/test_transfer.py +++ b/tests/test_transfer.py @@ -80,6 +80,38 @@ def test_file_transfer_binary(address: str, timeout: float): lsv2.disconnect() +def test_file_transfer_comp_mode(address: str, timeout: float): + """test if transferring a file with active compatibility mode works. This is to test if transfer without + secure file transfer works as expected.""" + lsv2 = pyLSV2.LSV2(address, port=19000, timeout=timeout, safe_mode=True, compatibility_mode=True) + lsv2.connect() + + with tempfile.TemporaryDirectory(suffix=None, prefix="pyLSV2_") as tmp_dir_name: + local_send_path = Path("./data/testdata.bmp") + local_recive_path = Path(tmp_dir_name).joinpath("test.bmp") + remote_path = pyLSV2.DriveName.TNC + pyLSV2.PATH_SEP + local_send_path.name + + assert lsv2.file_info(remote_path) is not True + + assert lsv2.send_file(local_path=local_send_path, remote_path=remote_path, override_file=True, binary_mode=True) is True + + assert lsv2.recive_file(local_path=str(local_recive_path), remote_path=remote_path, override_file=True, binary_mode=True) is True + + assert lsv2.delete_file(remote_path) is True + + digests = [] + for filename in [local_send_path, local_recive_path]: + hasher = hashlib.md5() + with open(filename, "rb") as f_p: + buf = f_p.read() + hasher.update(buf) + h_d = hasher.hexdigest() + digests.append(h_d) + assert (digests[0] == digests[1]) is True + + lsv2.disconnect() + + def test_recive_with_path_formating(address: str, timeout: float): """test if reading of file information with / instead of \\ as path separator""" lsv2 = pyLSV2.LSV2(address, port=19000, timeout=timeout, safe_mode=True)