Skip to content

Commit

Permalink
spelling and formating
Browse files Browse the repository at this point in the history
  • Loading branch information
drunsinn committed Dec 13, 2023
1 parent 15ea673 commit d568000
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 24 deletions.
27 changes: 11 additions & 16 deletions pyLSV2/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,7 @@
class LSV2:
"""implements functions for communicationg with CNC controls via LSV2"""

def __init__(
self,
hostname: str,
port: int = 0,
timeout: float = 15.0,
safe_mode: bool = True,
compatibility_mode: bool = False
):
def __init__(self, hostname: str, port: int = 0, timeout: float = 15.0, safe_mode: bool = True, compatibility_mode: bool = False):
"""
Implementation of the LSV2 protocol used to communicate with certain CNC controls
Expand Down Expand Up @@ -446,7 +439,7 @@ def _read_parameters(self, force: bool = False) -> ld.SystemParameters:
if isinstance(result, (bytearray,)) and len(result) > 0:
self._sys_par.axes_sampling_rate = lm.decode_system_information(result)
else:
self._logger.debug("could not read system information on axes samling rate")
self._logger.debug("could not read system information on axes sampling rate")
return self._sys_par

def _read_version(self, force: bool = False) -> ld.VersionInfo:
Expand Down Expand Up @@ -589,7 +582,7 @@ def execution_state(self) -> lc.ExecState:

def directory_info(self, remote_directory: str = "") -> ld.DirectoryEntry:
"""
Read information about the currenct working directory on the control.
Read information about the current working directory on the control.
Requires access level ``FILETRANSFER`` to work.
:param remote_directory: optional. change working directory before reading info
Expand Down Expand Up @@ -633,7 +626,7 @@ def change_directory(self, remote_directory: str) -> bool:
if isinstance(result, (bool,)) and result is True:
self._logger.debug("changed working directory to %s", dir_path)
return True

if remote_directory == self.directory_info().path:
self._logger.info("control responded as if the dir change did not work but path is still correct...")
return True
Expand Down Expand Up @@ -721,7 +714,7 @@ def drive_info(self) -> List[ld.DriveEntry]:
for entry in result:
drives_list.extend(lm.decode_drive_info(entry))

self._logger.debug(
self._logger.debug(
"successfully received %d packages for drive information %s",
len(result),
drives_list,
Expand All @@ -733,7 +726,9 @@ def drive_info(self) -> List[ld.DriveEntry]:
)

if "TNC:" not in [d.name for d in drives_list]:
self._logger.warning("an error occured while parsing drive info. this might be either a problem with the decoding or the control does not support this function!")
self._logger.warning(
"an error occurred while parsing drive info. this might be either a problem with the decoding or the control does not support this function!"
)
return []
return drives_list

Expand Down Expand Up @@ -1057,12 +1052,12 @@ def send_file(
lt.get_error_text(self.last_error),
)
else:
#if len(result) == 2:
# if len(result) == 2:

self._logger.info(
"could not send data, received unexpected response '%s' with data 0x%s",
self._llcom.last_response,
result.hex()
result.hex(),
)
return False

Expand Down Expand Up @@ -1625,7 +1620,7 @@ def get_file_list(self, path: str = "", descend: bool = True, pattern: str = "")
if self.change_directory(path) is False:
self._logger.warning("could not change to directory %s" % path)
return []

if len(pattern) == 0:
file_list = self._walk_dir(descend)
else:
Expand Down
6 changes: 3 additions & 3 deletions pyLSV2/dat_cls.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __str__(self) -> str:
@property
def control(self) -> str:
"""
version identifyer of the control
version identifier of the control
:getter: returns the version string
:setter: sets the version string
Expand Down Expand Up @@ -67,7 +67,7 @@ def control(self, value: str):
@property
def type(self) -> ControlType:
"""
control type identifyer of the control
control type identifier of the control
:getter: returns the control type
:setter: sets the control type
Expand Down Expand Up @@ -386,7 +386,7 @@ def output_words_start_address(self, value: int):

@property
def number_of_output_words(self) -> int:
"""total number of outpu words"""
"""total number of output words"""
return self._number_of_output_words

@number_of_output_words.setter
Expand Down
2 changes: 1 addition & 1 deletion pyLSV2/scripts/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def main():
con.connect()
except socket.gaierror as ex:
logger.error("An Exception occurred: '%s'", ex)
logger.error("Could not resove host information: '%s'", host_machine)
logger.error("Could not resolve host information: '%s'", host_machine)
sys.exit(-2)

if source_is_remote:
Expand Down
10 changes: 7 additions & 3 deletions pyLSV2/scripts/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ def comprehensive_demo():

print("Basics:")
print("# Connected to a '{:s}' running software version '{:s}'".format(con.versions.control, con.versions.nc_sw))
print("# Version as numeric values base:{:d} type:{:d} version:{:d} service pack:{:d}".format(con.versions.nc_sw_base, con.versions.nc_sw_type, con.versions.nc_sw_version, con.versions.nc_sw_service_pack))
print(
"# Version as numeric values base:{:d} type:{:d} version:{:d} service pack:{:d}".format(
con.versions.nc_sw_base, con.versions.nc_sw_type, con.versions.nc_sw_version, con.versions.nc_sw_service_pack
)
)
print(
"# Using LSV2 version '{:d}' with version flags '0x{:02x}' and '0x{:02x}'".format(
con.parameters.lsv2_version,
Expand Down Expand Up @@ -163,8 +167,8 @@ def comprehensive_demo():
for file_entry in only_dir:
print("## directory name: {:s}, date {:}".format(file_entry.name, file_entry.timestamp))

#con.change_directory("TNC:/smartNC")
#print([c.name for c in con.directory_content()])
# con.change_directory("TNC:/smartNC")
# print([c.name for c in con.directory_content()])

print("# file search")
h_files = con.get_file_list(path="TNC:", pattern=r"[\$A-Za-z0-9_-]*\.[hH]$")
Expand Down
2 changes: 1 addition & 1 deletion pyLSV2/scripts/ssh_tunnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
For this to work you have to:
1. enable ssh connections on the control
2. create a ssh key pair on your computer
3. add the private key to one of the user accouts on the control (default is 'user')
3. add the private key to one of the user accounts on the control (default is 'user')
4. make sure ssh is allowed through the firewall on the control
5. install the python library 'sshtunnel'
6. edit this file and set address, user name and path to the key file
Expand Down

0 comments on commit d568000

Please sign in to comment.