loris_log.ftpClient

The library to push log message to FTP server.

class FtpClient:

Class to establish connection and writing to FTP server.

FtpClient(hostname, port_num, username, password)

Establish communication with the remote FTP server.

Args:

hostname (string): FTP server hostname.
port_num (integer): FTP server port number.
username (string): FTP server username.
password (string): FTP server password.

Raise InvalidFTPPortNumberException:

If the port number is not of type int and is equal or less
than zero.

Raise InvalidFTPUserNameException:

If the username is not of type string or it is an empty 
string or it is a None value.

Raise InvalidFTPPasswordException:

If the password is not of type string or it is an empty
string or it is a None value.

Raise FTPConnectionFailedException:

If the connection to the FTP remote server was not 
a success.

Raise InvalidFTPHostNameException:

If any of the port number, username, and password
are invalid.
ftp_client
def create_ftp_log_data(self, directory_path, file_name, root):

Create the log file the sensors, or devices data log. The creation of the log file is based on the defined directory path and file name. The user also been giving the ability to customize the file creation of whether to create the log file start from parent directory or otherwise.

Args:

directory_path (string): The directory path of the log file.
file_name (string): The name of the log file (for device data).
root (bool): Whether the folder and file creation is to
                    start from root directory.

Raises:

FTPFileCreationException: If the required data for log file
    creation is not fulfilling the desire requirements; or
    is attempt to parsing the invalid log file or directory.
def set_ftp_log_data(self, directory_path, file_name, log_data):

Set the csv log file with the desired log data. The new log data will continue log onto the existing file, if the log file was present. Otherwise, new file gonna be created for this new log data. Please do take note that the file type must be of csv type.

Args:

directory_path (string): The path to the csv log file.
file_name (string): The name of the csv log file.
log_data (bytes): The log data.

Raise NoneValueException:

If the directory path, file name or the data to be logged
is of None value.

Raise InvalidAttributeException:

If the directory path, file name is not the type of string,
while the log data is not type of byte.

Raise EmptyParameterException:

If the directory path, file name or log data is empty.
def create_ftp_log_file(self, directory_path, file_name, root):

Create the ftp log file based on the user defined directory path, file name, and user decision of whether to have the creation of log file started from the root directory.

Args:

directory_path (string): The log file directory path.
file_name (string): The log file's file name.
root (boolean): The decision to start from root directory

Raises:

FTPFileCreationException: If the required parameters are
not fulfilled, or attempt to parse the non-existed file
or folder.
def set_ftp_log_file(self, directory_path, file_name, message):

Set the log file with application or system log. If the log file was already existed, the new log will continue appended on to the existing log file. Otherwise, new log file gonna be created.

Args:

directory_path (string): The path to the log file.
file_name (string): The log file name.
message (string): The log message.

Raise NoneValueException:

If the directory path and file name is a type None.

Raise InvalidAttributeException:

If the directory path, file name or log message is
not the type string.

Raise EmptyParameterException:

If the directory path, file name or log message is
not empty.