A simple Template for create python project
Project description
potato.py Library
The potato.py library provides a set of utility functions for common tasks related to database connectivity, email notifications, file operations, and more. This README.md file serves as a guide on how to use the library after installing it from PyPI.
Installation
To install the potato.py library, run the following command:
pip install potatopy
Usage
Once the library is installed, you can use it in your Python project by importing the necessary modules:
from potatopy import DatabaseConnector, EmailNotifier, Template
Email Notifications
You can send emails using the EmailNotifier class.
# Example Usage
email_params = {
"sender": "your_email@gmail.com",
"recipient": "recipient1@gmail.com;recipient2@gmail.com",
"recipient_cc": "cc1@gmail.com;cc2@gmail.com",
"subject": "Your Email Subject",
"body": "<p>Your email body in HTML format</p>",
"footer": "Additional email footer",
"smtp_server": "your_smtp_server",
"smtp_port": 587, # or 21 depending on your need
}
email_notifier = EmailNotifier()
result = email_notifier.send_email(**email_params)
File Operations
You can perform various file operations like listing files, reading CSV files, and moving directories with the Template class.
# Example Usage
template = Template()
# List files in a folder
folder_path = "path/to/your/folder"
files = template.list_files_in_folder(folder_path)
# Read data from a CSV file
csv_file_path = "path/to/your/file.csv"
data = template.read_csv_file(csv_file_path)
# Move a directory to a new location
source_path = "path/to/your/source"
destination_path = "path/to/your/destination"
directory_name = "your_directory_name"
template.move_directory(source_path, destination_path, directory_name)
# Delete a directory
folder_to_delete = "path/to/your/folder"
template.delete_directory(folder_to_delete)
# Export data to a CSV file
data_table = your_data_table_widget # Replace with your actual data table
export_path = "path/to/your/export/file.csv"
message = "Export successful!"
template.export_to_csv(data_table, export_path, message)
Logging and Error Handling
You can initialize logging, log messages with dates, and handle errors.
# Example Usage
template = Template()
# Initialize logging
log_file = "path/to/your/log/file.log"
template.logging_init(log_file)
# Log a message with date
template.logging_date("Your log message with date")
# Log a message without date
template.logging_message("Your log message without date")
# Handle errors
try:
# Your code that may raise an exception
except Exception as e:
template.handle_error(e)
GUI Window Operations
You can manage the position and layout of GUI windows with the Template class.
# Example Usage
template = Template()
# Set window position
root = your_root_window # Replace with your actual root window
window = your_child_window # Replace with your actual child window
width, height = 800, 600 # Set your window dimensions
template.set_window_position(root, window, width, height)
# Fix window position
template.fix_window_position(window, root)
Database Connectivity
The library supports connections to PostgreSQL, MySQL, and Oracle databases.
PostgreSQL Connection
# Example Usage
postgres_params = {
"host": "your_host",
"database": "your_database",
"user": "your_user",
"password": "your_password",
"port": "your_port",
"query": "your_query",
}
db_connector = DatabaseConnector()
connection = db_connector.connect_postgresql(**postgres_params)
result = connection.fetchall()
MySQL Connection
# Example Usage
mysql_params = {
"host": "your_host",
"database": "your_database",
"user": "your_user",
"password": "your_password",
"port": "your_port",
"query": "your_query",
}
db_connector = DatabaseConnector()
connection = db_connector.connect_mysql(**mysql_params)
result = connection.fetchall()
Oracle Connection
# Example Usage
oracle_params = {
"host": "your_host",
"database": "your_database",
"user": "your_user",
"password": "your_password",
"port": "your_port",
"query": "your_query",
}
db_connector = DatabaseConnector()
connection = db_connector.connect_oracle(**oracle_params)
result = connection.fetchall()
FTP Operations
The FTP class provides functionality for interacting with an FTP server, including file uploads, downloads, deletions, file listing, renaming, existence checks, directory creation, and reading file contents.
# Example Usage
ftp = FTP(host_name="your_ftp_host", user="your_ftp_user", password="your_ftp_password")
# Upload a file to the FTP server
local_src_path = "path/to/local/file.txt"
remote_dest_path = "path/to/remote/file.txt"
success = ftp.upload_file(local_src_path, remote_dest_path)
print(f"Upload Successful: {success}")
# Download a file from the FTP server
remote_src_path = "path/to/remote/file.txt"
local_dest_path = "path/to/local/file.txt"
success = ftp.download_file(remote_src_path, local_dest_path)
print(f"Download Successful: {success}")
Miscellaneous
# Example Usage
template = Template()
# Run a function at intervals
template.run_interval()
# Print a formatted message
template.print_message("OK", "Your information message")
template.print_message("NG", "Your error message")
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
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 potatopy-1.0.0.tar.gz.
File metadata
- Download URL: potatopy-1.0.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
881190d270f1449438b20fc43df93836412a714095636d6bee6d1d9ef48ab1c9
|
|
| MD5 |
0ed3a3a02579f834980fb6b48e92fe1d
|
|
| BLAKE2b-256 |
5f55af49766c9fa39f973009f5fe1b54ef18b9c84b74e29fddd7efee57889fc6
|
File details
Details for the file potatopy-1.0.0-py3-none-any.whl.
File metadata
- Download URL: potatopy-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16204dcbd21148a99f41341bf2568a00d92aaf83093618f46b963a10ffebf76b
|
|
| MD5 |
5058b1d74133bb897f1fd702ed2ac107
|
|
| BLAKE2b-256 |
d052f0c7b2fd0e6da91ba1e15da9cf516668ff9a7cf7e58b554ff56e93ce11fc
|