PyCFUtils (Cristi Fati's Utils for Python (&& more)) - a collection of goodies ((cool) scripts / utilities)
Project description
PyCFUtils
PyCFUtils (Cristi Fati's Utils for Python (&& more)) - a collection of goodies ((cool) scripts / utilities)
Install
Use PIP:
python -m pip install --upgrade pycfutils
Usage example
import time
import pycfutils.io
import pycfutils.miscellaneous as misc
import pycfutils.network
import pycfutils.system
from pycfutils.exceptions import ModuleException, NetworkException
print("Press a key in less than one second...")
print(pycfutils.io.read_key(timeout=1))
print(misc.timestamp_string(human_readable=True))
print(tuple(misc.progression(ratio=2)))
@misc.timed_execution()
def func(arg0, kw0=1):
time.sleep(0.2)
return 5
func("123")
try:
print(pycfutils.network.connect_to_server("127.0.0.1", 22))
except NetworkException as e:
print(e)
pycfutils.system.cpu_stress(3)
# --- Requires PyGObject (also might take some time to complete) ---
try:
from pycfutils.gstreamer import RegistryAccess
except ModuleException as e:
print(e)
else:
ra = RegistryAccess()
print(ra.element_classes())
# --- Windows only ---
import pycfutils.gui
print(pycfutils.gui.message_box("Title", "Text to display", x=320, y=200))
Functionality to build a *.dll (*.so) with SetupTools. Parts of setup.py:
from setuptools import setup
from pycfutils.setup.command.build_clibdll import build_clibdll
from pycfutils.setup.command.install_platlib import install_platlib # Optional
dll = (
"dll_name",
{
"sources": ["src0.c", "src1.c", ],
# ...
"dll": True, # False (or nothing) for regular (static) library
"copy_files": { # Optional (copy artifacts)
"dll_name.so": "pkg_name", # dll_name.dll on Win
}
# ...
},
)
setup(
name="pkg_name",
# ...
cmdclass={
"build_clib": build_clibdll,
"install": install_platlib,
},
libraries=[dll],
# ...
)
There are also some useful (CLI wrapper) scripts in the tools folder. Example:
-
Nix:
ls "pycfutils/tools" for script in $(find "pycfutils/tools" -maxdepth 1 -type f); do python "${script}" -h; done
-
Win:
dir /b "pycfutils\tools" for /f %g in ('dir /b /a-d /a-l "pycfutils\tools\*.py"') do (python "pycfutils\tools\%g" -h)
Or run them as modules (e.g. in 2 separate terminals). Example (Shell snippets that also work in Batch):
-
Terminal 1:
python -m pycfutils.tools.connect_to_server -a 127.0.0.1 -p 16180 # Go to the other terminal and run the other command (start the server), then come back and re-run the previous command python -m pycfutils.tools.connect_to_server -a 127.0.0.1 -p 16180
-
Terminal 2:
python -m pycfutils.tools.start_server -a 127.0.0.1 -p 16180
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
pycfutils-2024.10.26.tar.gz
(29.5 kB
view details)
Built Distributions
File details
Details for the file pycfutils-2024.10.26.tar.gz
.
File metadata
- Download URL: pycfutils-2024.10.26.tar.gz
- Upload date:
- Size: 29.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03651c5e97f99cd8325b97edf53dc4d4a5283526e75e5f5002efe7905f0f4c38 |
|
MD5 | d4c13fca6bf9057bc5d05113163d7271 |
|
BLAKE2b-256 | a1b9f468d751ec32b967d267fc6b599735b3c16c96c4e46e31a3d84efc5b5d0b |
File details
Details for the file pycfutils-2024.10.26-py3-none-win_amd64.whl
.
File metadata
- Download URL: pycfutils-2024.10.26-py3-none-win_amd64.whl
- Upload date:
- Size: 39.0 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | faaaa1a31d807d101d7ab38a4cbf628e2bd485cff53ea858d9411559b450fff7 |
|
MD5 | 5e59d315f8e3d306b0fd4ae37f508550 |
|
BLAKE2b-256 | e4e4125fb809d0b7fa3f79df0be1c8c9fc477d3769889032bd1c929ec80dd698 |
File details
Details for the file pycfutils-2024.10.26-py3-none-win32.whl
.
File metadata
- Download URL: pycfutils-2024.10.26-py3-none-win32.whl
- Upload date:
- Size: 38.5 kB
- Tags: Python 3, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ace5f710536d4f1d2893edc0f91252db9b71fd4f31b49450d7f07abe5f2521fc |
|
MD5 | 7ea52a93fc5ce01c31485981446d9682 |
|
BLAKE2b-256 | 179a38d843daf52aef090fe8bd3b467f5f4a03288776ba9eda241c4544c8becc |
File details
Details for the file pycfutils-2024.10.26-py3-none-any.whl
.
File metadata
- Download URL: pycfutils-2024.10.26-py3-none-any.whl
- Upload date:
- Size: 28.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46f7810d350bca3fccad71a8256c6b7833349edba72ad5bc2096c65337369380 |
|
MD5 | bf2d729ffd3ce1aef2ee70508f8a563a |
|
BLAKE2b-256 | 31b35469065a5c6123b098997d1da0bb2f7cd79ca085b91173df7875702a80d4 |