Skip to content

Commit

Permalink
ThalesFileInterface.aquire() bugfix
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
maxkrapp1 committed Jan 17, 2023
1 parent d10617c commit 462bb67
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ __pycache__
/.vscode/
/.vs/
/.settings/
/.ipynb_checkpoints/
*.ipynb_checkpoints
/docs/
/source/_build/
*__pycache__
Expand Down
4 changes: 2 additions & 2 deletions Examples/FileExchangeEIS/FileExchangeEIS.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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."
]
Expand All @@ -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\")"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion Examples/FileExchangeEIS/FileExchangeEIS.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 25 additions & 2 deletions thales_remote/file_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

from thales_remote.connection import ThalesRemoteConnection
from dataclasses import dataclass
import warnings


@dataclass
Expand Down Expand Up @@ -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
Expand All @@ -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:
"""
Expand Down

0 comments on commit 462bb67

Please sign in to comment.