From 462bb67ff90a446b66371c5dea85a98a91290512 Mon Sep 17 00:00:00 2001 From: maxkrapp1 Date: Tue, 17 Jan 2023 08:48:33 +0100 Subject: [PATCH] ThalesFileInterface.aquire() bugfix The function had a bug and did not work. After #15 the function aquire was given deprecated warning due to misspelling and replaced by acquire. --- .gitignore | 2 +- .../FileExchangeEIS/FileExchangeEIS.ipynb | 4 +-- Examples/FileExchangeEIS/FileExchangeEIS.py | 2 +- thales_remote/file_interface.py | 27 +++++++++++++++++-- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 1306ab3..37db892 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,7 @@ __pycache__ /.vscode/ /.vs/ /.settings/ -/.ipynb_checkpoints/ +*.ipynb_checkpoints /docs/ /source/_build/ *__pycache__ diff --git a/Examples/FileExchangeEIS/FileExchangeEIS.ipynb b/Examples/FileExchangeEIS/FileExchangeEIS.ipynb index 02186ac..09d4839 100644 --- a/Examples/FileExchangeEIS/FileExchangeEIS.ipynb +++ b/Examples/FileExchangeEIS/FileExchangeEIS.ipynb @@ -126,7 +126,7 @@ "source": [ "# Obtaining a single measurement file\n", "\n", - "After the measurement, the measurement file can be retrieved from the remote computer using [aquireFile](https://doc.zahner.de/thales_remote/file_interface.html#thales_remote.file_interface.ThalesFileInterface.aquireFile).\n", + "After the measurement, the measurement file can be retrieved from the remote computer using [acquireFile](https://doc.zahner.de/thales_remote/file_interface.html#thales_remote.file_interface.ThalesFileInterface.acquireFile).\n", "\n", "To transfer the file we need to pass as parameter the path of the file on the computer on which Thales is running. The file path is composed of the path and filename specified in the previous." ] @@ -137,7 +137,7 @@ "metadata": {}, "outputs": [], "source": [ - " file = fileInterface.aquireFile(r\"C:\\THALES\\temp\\myeis.ism\")" + " file = fileInterface.acquireFile(r\"C:\\THALES\\temp\\myeis.ism\")" ] }, { diff --git a/Examples/FileExchangeEIS/FileExchangeEIS.py b/Examples/FileExchangeEIS/FileExchangeEIS.py index 45ff744..dd14255 100644 --- a/Examples/FileExchangeEIS/FileExchangeEIS.py +++ b/Examples/FileExchangeEIS/FileExchangeEIS.py @@ -47,7 +47,7 @@ zahnerZennium.disablePotentiostat() zahnerZennium.setAmplitude(0) - file = fileInterface.aquireFile(r"C:\THALES\temp\myeis.ism") + file = fileInterface.acquireFile(r"C:\THALES\temp\myeis.ism") fileHandle = open(r"D:\myLocalDirectory\asdf.ism", "wb") fileHandle.write(file.binaryData) diff --git a/thales_remote/file_interface.py b/thales_remote/file_interface.py index 97a8181..a3a88e3 100644 --- a/thales_remote/file_interface.py +++ b/thales_remote/file_interface.py @@ -32,6 +32,7 @@ from thales_remote.connection import ThalesRemoteConnection from dataclasses import dataclass +import warnings @dataclass @@ -152,6 +153,28 @@ def disableAutomaticFileExchange(self) -> str: return self.enableAutomaticFileExchange(False) def aquireFile(self, filename: str) -> Union[FileData, None]: + """ + transfer a single file, deprecated because misspelled. + + This command transfers a single from Term to Python. + **This command can only be executed if automatic transfer is disabled.** If automatic transfer is enabled, None is returned. + The parameter filename is used to specify the full path of the file, on the computer running + the Thales software, to be transferred e.g. r"C:\\THALES\\temp\\test1\\myeis.ism". + + The function returns the file as dataclass. + + :param filename: Filename with path on the Thales computer. + :returns: A dataclass with the file or None if this command is called when automatic file + exchange is activated. + """ + warnings.warn( + "This function is misspelled and will be removed, use acquireFile instead.", + DeprecationWarning, + stacklevel=2, + ) + return self.acquireFile(filename) + + def acquireFile(self, filename: str) -> Union[FileData, None]: """ transfer a single file @@ -167,12 +190,12 @@ def aquireFile(self, filename: str) -> Union[FileData, None]: exchange is activated. """ if self._receiver_is_running: + return None + else: self.remoteConnection.sendTelegram( f"3,{self._device_name},1,{filename}", message_type=128 ) return self._receiveFile() - else: - return None def setSavePath(self, path: str) -> None: """