A simple Python library
Project description
✅ Python Automation Library with Excel, Web, and SFTP Utilities This library provides reusable utilities for automating Excel, web interactions with Selenium, and secure file transfers with SSH/SFTP. It is designed to save time and effort by abstracting common tasks into simple-to-use functions.
📁 Library Structure Overview bash Copy Edit 📦 automation_utils/ ┣ 📜 init.py ┣ 📜 Utility.py → Excel + general automation tools ┣ 📜 chrome.py → Selenium reusable web automation functions ┣ 📜 selenium_certificate.py → Specialized Selenium logic for certificate selection ┣ 📜 sftp.py → SSH/SFTP helper functions ┗ 📜 README.md 🔧 Utility.py (Excel/General Automation) Utility.py contains reusable functions for various automation tasks related to data handling and Excel processing:
Cleaning Data:
str_to_float: Converts string columns to float and cleans data.
col_to_str: Converts columns to string and removes unwanted .0 suffix.
Sanity_Clean_df: Strips whitespace from column names and values in DataFrames.
Excel Formatting:
set_column_width: Sets column widths in an Excel worksheet.
set_header: Applies header formatting and column styles using xlsxwriter.
write_Data_to_Excel: Writes a DataFrame to Excel with optional formatting and summary rows.
Create_Pivot_Table: Creates dynamic Pivot Tables with win32com.
Excel File Management:
create_ZipFile: Creates zip archives from Excel outputs.
CleanFolder: Removes all files within a directory.
convert_Excel_to_csv: Converts an Excel file to CSV.
General Automation:
logFiles: Configures logging for error tracking.
TimeOut: Pauses script execution for specified intervals.
MailTrigger: Sends an email with optional attachments.
🌐 chrome.py (Selenium Web Automation) chrome.py contains essential Selenium helper functions that simplify web automation tasks, especially for dynamic pages and interactions:
click_element(driver, locator): Safely clicks an element, handling waits and exceptions.
send_keys(driver, locator, text): Enters text into a field, ensuring it's ready for input.
change_download_directory(driver, path): Dynamically changes the download directory in Chrome at runtime.
extract_text(driver, locator): Extracts and returns visible text from a specified web element.
These methods are robust and include error handling and logging to ensure smooth automation in dynamic web environments.
📄 selenium_certificate.py selenium_certificate.py focuses on automating certificate selection workflows, especially useful for secure logins that require a certificate or token:
select_certificate(driver, cert_name): Automates the selection of a digital certificate from available options (handles popups, frame switching, etc.).
🔐 sftp_util.py sftp_util.py provides SSH/SFTP helper functions using the paramiko library for secure file handling and remote server management.
SFTP Functions: connect(self) Establishes an SSH connection to the remote server.
connect_server(self) Connects to the server and prepares the session for file transfers.
put_file(self, local_file_path, remote_file_path) Uploads a file from the local machine to the remote server.
download_file(self, remote_file_path, local_file_path) Downloads a file from the remote server to the local machine.
upload_directory(self, local_directory, remote_directory) Uploads an entire directory from the local machine to the remote server.
download_directory(self, remote_directory, local_directory) Downloads an entire directory from the remote server to the local machine.
create_directory(self, remote_path) Creates a directory on the remote server.
remove_file(self, remote_file_path) Removes a file from the remote server.
rename_file(self, remote_old_path, remote_new_path) Renames a file on the remote server.
rename_folder(self, remote_old_path, remote_new_path) Renames a folder on the remote server.
list_directory(self, remote_file_path) Lists the contents of a remote directory.
list_directory_detailed(self, remote_path) Lists detailed information of files in the remote directory.
details_folder_file(self, path) Retrieves detailed information about files and directories on the remote server.
current_path_details(self) Retrieves the current path details on the remote server.
adjust_remote_path(self, remote_file_path) Adjusts the file path on the remote server for proper file handling.
check_directory(self, directory) Checks if a directory exists on the remote server.
set_cursor_path(self, cursor_path) Sets the cursor path for the current file operation.
Remote Command Execution: execute_command(self, command) Executes a command on the remote server via SSH.
run_bat_file(self, bat_file, arguments=None) Runs a .bat file on the remote server with optional arguments.
run_python_script(self, script_path, arguments=None) Executes a Python script on the remote server.
run_shell_script(self, script_path, arguments=None) Runs a shell script on the remote server.
Admin Functions: start_service(self, service_name) Starts a specified service on the remote server.
stop_service(self, service_name) Stops a specified service on the remote server.
restart_service(self, service_name) Restarts a specified service on the remote server.
kill_process(self, process_name) Terminates a process running on the remote server.
check_service_status(self, service_name) Checks the status of a specified service on the remote server.
check_cpu_usage(self) Retrieves the CPU usage statistics on the remote server.
check_memory_usage(self) Checks the memory usage on the remote server.
check_disk_usage(self) Retrieves disk usage statistics on the remote server.
list_processes(self) Lists all processes running on the remote server.
get_system_uptime(self) Retrieves the system uptime on the remote server.
view_system_events(self) Views the system event logs on the remote server.
File Handling: file_exists(self, remote_file_path) Checks if a specific file exists on the remote server.
get_file_size(self, remote_file_path) Retrieves the size of a file on the remote server.
change_file_permissions(self, remote_file_path, permissions) Changes the permissions of a file on the remote server.
move_directory(self, remote_old_path, remote_new_path) Moves a directory on the remote server.
append_to_remote_file(self, remote_file_path, content) Appends content to a file on the remote server.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file utilies-0.1.0.2.tar.gz.
File metadata
- Download URL: utilies-0.1.0.2.tar.gz
- Upload date:
- Size: 31.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d731f42fdb9b3fcdedc7b596fa3aa896f92fb7552f766f87e5446b9bba9a003
|
|
| MD5 |
3c8e985a2159c0c4566714f2a4ecaa0b
|
|
| BLAKE2b-256 |
aa9068d4d84db243289f8ec3942ba6ee8220bacd5b7c55898d4b1f86cb3e0653
|
File details
Details for the file utilies-0.1.0.2-py3-none-any.whl.
File metadata
- Download URL: utilies-0.1.0.2-py3-none-any.whl
- Upload date:
- Size: 30.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1995d3ec87faf4dd0f0ebff1c2502a2e268e16e74afd03cacd4648114be79edc
|
|
| MD5 |
6b77a4d5653e2b26558c0dce7b8e4d52
|
|
| BLAKE2b-256 |
a657cb77a54e6042044c45eafb4f54e328725da3e95871d614b0f298a3f7b2d5
|