Skip to main content

A Python utility.

Project description

wtfutil

wtfutil is a Python utility library for everyday scripting and automation: HTTP, files, strings & crypto, databases, Windows processes, multi-channel notifications, translation, and random images.

Author: vicrack
中文文档: README_zh.md
Full API reference: docs/ (per-module, EN/ZH)
Agent notes: AGENTS.md


Installation

pip install wtfutil

Requires Python 3.10+.


Quick Start

from wtfutil import requests_session, read_lines, write_json, send, get_resource

req = requests_session(proxies=10809, timeout=30)
r = req.get("https://example.com/")

lines = read_lines(get_resource("urls.txt"), unique=True)
write_json("out.json", {"ok": True})

send("Alert", "Task finished")

Sub-module imports work as well: from wtfutil import httputil, fileutil, notifyutil, util.


CLI & single-instance

pykill — kill Python processes (CLI)

Installed as a console script (not in wtfutil.__all__). Wraps procutil with Rich tables and optional interactive selection.

pykill                          # list all Python processes, pick PIDs to kill
pykill myscript.py              # kill by script path
pykill myscript.py -l           # list only
pykill -c "celery worker"       # match command-line substring

Details: docs/en/pykill.md · docs/zh/pykill.md

singleinstance — one instance per script

from wtfutil import single_instance, SingleInstanceException

try:
    with single_instance(flavor_id="my_job"):
        run_job()
except SingleInstanceException:
    print("Already running")

flavor_id distinguishes multiple single-instance modes for the same script; lock file defaults to the system temp directory.
Details: docs/en/singleinstance.md · docs/zh/singleinstance.md


Module Overview

Module Description API docs
wtfutil.httputil Enhanced requests session, raw HTTP, URL/IP/DNS, SSL adapters EN · ZH
wtfutil.fileutil File I/O, hashing, JarAnalyzer EN · ZH
wtfutil.strutil Encoding, hashing, RSA/DES, string tools EN · ZH
wtfutil.sqlutil SQLite / MySQL wrappers, Database, SQL helpers EN · ZH
wtfutil.procutil Windows process control (Windows only) EN · ZH
wtfutil.notifyutil Multi-channel notifications EN · ZH
wtfutil.translateutil Baidu Translate API EN · ZH
wtfutil.imgutil Random avatar fetch EN · ZH
wtfutil.singleinstance Single-instance lock (SingleInstance, @single_instance) EN · ZH
wtfutil.util Misc helpers, get_resource EN · ZH
pykill (CLI) List/kill Python processes (uses procutil) EN · ZH

All public symbols are also exported at package top level (from wtfutil import read_text, ...). See wtfutil/__init__.py __all__.


Configuration Summary

wtfconfig.ini is resolved by get_resource("wtfconfig.ini"): current dir → resource/wtfconfig.ini~/wtfconfig.ini. Environment variables override the file.

[notify]
CONSOLE = true
FEISHU_KEY =
# ... see docs/en/notifyutil.md

[img]
APIHZ_IMG_ID =
APIHZ_IMG_KEY =

Details: notifyutil, imgutil. Example file: wtfconfig.ini.example.


Contributing

Issues and pull requests are welcome on GitHub.

When adding or changing public APIs, update the module __all__, wtfutil/__init__.py, and the matching files under docs/en/ and docs/zh/. See AGENTS.md for agent-oriented project notes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wtfutil-1.2.17-py3-none-any.whl (72.8 kB view details)

Uploaded Python 3

File details

Details for the file wtfutil-1.2.17-py3-none-any.whl.

File metadata

  • Download URL: wtfutil-1.2.17-py3-none-any.whl
  • Upload date:
  • Size: 72.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for wtfutil-1.2.17-py3-none-any.whl
Algorithm Hash digest
SHA256 df946c3084fdd6f7d3eda71a5af5ab71f122a9273215d775a5ab2c1a3f3cd127
MD5 9eb24d412025f18e3bdead024f9f69d8
BLAKE2b-256 980b56564f5c4817a172b5dcf4f50e9026f0d3bc9a2b7259fbeb2259d1bf481b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page