From d56800028b660686c9eedd5e48e3b61c1b3212e2 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 13 Dec 2023 21:19:29 +0100 Subject: [PATCH] spelling and formating --- pyLSV2/client.py | 27 +++++++++++---------------- pyLSV2/dat_cls.py | 6 +++--- pyLSV2/scripts/cmd.py | 2 +- pyLSV2/scripts/demo.py | 10 +++++++--- pyLSV2/scripts/ssh_tunnel.py | 2 +- 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/pyLSV2/client.py b/pyLSV2/client.py index e8b9cba..65fc7b8 100644 --- a/pyLSV2/client.py +++ b/pyLSV2/client.py @@ -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 @@ -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: @@ -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 @@ -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 @@ -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, @@ -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 @@ -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 @@ -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: diff --git a/pyLSV2/dat_cls.py b/pyLSV2/dat_cls.py index 5e9279c..bcf7c8e 100644 --- a/pyLSV2/dat_cls.py +++ b/pyLSV2/dat_cls.py @@ -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 @@ -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 @@ -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 diff --git a/pyLSV2/scripts/cmd.py b/pyLSV2/scripts/cmd.py index 229c442..2480f63 100644 --- a/pyLSV2/scripts/cmd.py +++ b/pyLSV2/scripts/cmd.py @@ -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: diff --git a/pyLSV2/scripts/demo.py b/pyLSV2/scripts/demo.py index da955f9..17b7f98 100644 --- a/pyLSV2/scripts/demo.py +++ b/pyLSV2/scripts/demo.py @@ -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, @@ -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]$") diff --git a/pyLSV2/scripts/ssh_tunnel.py b/pyLSV2/scripts/ssh_tunnel.py index 56d7af4..4999a1c 100644 --- a/pyLSV2/scripts/ssh_tunnel.py +++ b/pyLSV2/scripts/ssh_tunnel.py @@ -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