Skip to content

dominicci13/shared-python-utils

Repository files navigation

seller-automation-utils

Shared Python utilities for Amazon and eBay seller automation.

Installation

pip install git+https://github.com/dominicci13/shared-python-utils.git

Or in editable mode for local development:

pip install -e .

Requirements

  • Python 3.10+
  • Windows (uses win32com, pyodbc SQL Server Express, and Windows clipboard APIs)

Configuration

Some modules load runtime config from config/accounts.json next to the entry script (falling back to the working directory). Copy the example and fill in your values:

cp config/accounts.json.example config/accounts.json

Sensitive values (email addresses, credentials) are loaded from a .env file via get_env(). Copy .env.example and fill in your values:

cp .env.example .env

Module Index

accounts

Account name maps and eBay Chrome profiles loaded from config/accounts.json. Amazon login via Outlook OTP.

from seller_automation_utils import AMAZON_ACCOUNT_NAMES, EBAY_PROFILES, amazon_login

alert_utils

Capture browser screenshots and tab URLs on crash, send a crash report via Outlook, and clean up automation processes.

import traceback
from seller_automation_utils import handle_crash

try:
    run_automation()
except Exception:
    handle_crash(driver, traceback.format_exc(), automation_name="My Job")

chrome

Start a Chrome browser with SeleniumBase, with retry on failure.

from seller_automation_utils import start_browser

driver = start_browser(user_data_dir="C:/chrome-profiles", chrome_profile="Default", retry_count=3)

config_utils

Load JSON config files and read environment variables from .env.

from seller_automation_utils import load_config, load_config_safe, get_env

config = load_config_safe("config/settings.json")   # returns {} if file missing
db_name = get_env("DB_NAME", required=True)

custom_functions

General-purpose helpers: clipboard, shadow DOM, file scanning, SQL connection, process control.

from seller_automation_utils import sql_connection, kill_app

conn = sql_connection("MyDatabase")
kill_app("chrome")

database_utils

Parameterized DataFrame inserts for SQL Server via pyodbc.

from seller_automation_utils import insert_dataframe

insert_dataframe(cursor, "dbo.Orders", df, columns=["OrderId", "Status"])

ebay

Customize the eBay Active Listings table columns in the seller dashboard.

from seller_automation_utils import customize_offers_table

customize_offers_table(driver, sold=True, watchers=True)

excel_utils

Open Excel workbooks, run macros, refresh Power Query, and insert images.

from seller_automation_utils import refresh_workbook, run_macro, paste_image_to_sheet

refresh_workbook("C:/reports/dashboard.xlsm", wait=30)
run_macro("C:/reports/report.xlsm", "Module1.FormatSheet")

file_utils

Directory creation, download polling, and directory cleanup.

from seller_automation_utils import create_dir_structure, wait_for_download, clear_directory

create_dir_structure("C:/automation", ["logs", "output/reports"])
path = wait_for_download("C:/Downloads", extension=".csv", timeout_sec=120)
clear_directory("C:/Downloads", extension=".csv")

outlook

Send emails from a configured Outlook account and poll for OTP/verification codes.

from seller_automation_utils import send_email, get_verification_code

send_email("sender@example.com", subject="Report", body="<p>Done</p>", to=["boss@example.com"])
code = get_verification_code("me@example.com", sender_contains="amazon", subject_contains="OTP")

schedule_utils

Run a function on a recurring cron schedule using APScheduler.

from seller_automation_utils import run_on_schedule

run_on_schedule(my_job, hour=8, minute=30, day_of_week="mon-fri")

screenshot_utils

Crop screenshots to Selenium elements or pixel boxes, and paste into Excel.

from seller_automation_utils import crop_to_element, crop_to_box, paste_to_excel

path = crop_to_element(element)
paste_to_excel("C:/reports/report.xlsm", sheet="Dashboard", cell="B5", image_path=path)

ui_utils

Show a native Windows Yes/No dialog and return the user's choice.

from seller_automation_utils import ask_user

if ask_user("Continue with upload?", title="Confirm"):
    upload()

Author

Built by Brian Ramirez (@dominicci13) — automation & AI workflow specialist. More on my GitHub profile and LinkedIn.

License

MIT — see LICENSE.

About

Reusable Python utilities for Amazon and eBay seller-portal automation: SeleniumBase login, Outlook OTP, xlwings, pyodbc inserts, Rich logging, APScheduler.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages