Skip to main content

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


Download files

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

Source Distribution

pycfutils-2025.3.17.tar.gz (32.0 kB view details)

Uploaded Source

Built Distributions

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

pycfutils-2025.3.17-py3-none-win_amd64.whl (41.3 kB view details)

Uploaded Python 3Windows x86-64

pycfutils-2025.3.17-py3-none-win32.whl (40.9 kB view details)

Uploaded Python 3Windows x86

pycfutils-2025.3.17-py3-none-any.whl (31.1 kB view details)

Uploaded Python 3

File details

Details for the file pycfutils-2025.3.17.tar.gz.

File metadata

  • Download URL: pycfutils-2025.3.17.tar.gz
  • Upload date:
  • Size: 32.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.11

File hashes

Hashes for pycfutils-2025.3.17.tar.gz
Algorithm Hash digest
SHA256 8dcf9b242fb17a9502186dba43122d7b257c8464e7c0747b8b4f84ffcec01fdf
MD5 081a108c4bf83f4e1d50287e4d947b96
BLAKE2b-256 455a7ee1f1f133961f850510fb5e88fbada022d1a9ecfcd4b91451384bd38df8

See more details on using hashes here.

File details

Details for the file pycfutils-2025.3.17-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for pycfutils-2025.3.17-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 0c3b87c21a8edad7ee6627086d0d905767197474a4bfc00c1ea194fca36d577a
MD5 be038eee70be7f17c796e20e6b69d5e4
BLAKE2b-256 a1008d67c8941e73876faba41c4eeb62d4da7d989d1aef12dc426f0864152787

See more details on using hashes here.

File details

Details for the file pycfutils-2025.3.17-py3-none-win32.whl.

File metadata

  • Download URL: pycfutils-2025.3.17-py3-none-win32.whl
  • Upload date:
  • Size: 40.9 kB
  • Tags: Python 3, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.11

File hashes

Hashes for pycfutils-2025.3.17-py3-none-win32.whl
Algorithm Hash digest
SHA256 6b4cd566e0f501efdf3d4416404d2d35a2f486edc947fe69312f9d80db210789
MD5 87f7664b5eaa0ae8bda45b99329c4f5e
BLAKE2b-256 98a509b01e916197041d625e546bcc4c61f920492c1f5423834fc9de1c52cde1

See more details on using hashes here.

File details

Details for the file pycfutils-2025.3.17-py3-none-any.whl.

File metadata

  • Download URL: pycfutils-2025.3.17-py3-none-any.whl
  • Upload date:
  • Size: 31.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.11

File hashes

Hashes for pycfutils-2025.3.17-py3-none-any.whl
Algorithm Hash digest
SHA256 45732364b3ef5f2f2de712c113510f4339a867faf67394e6673a248bd915c927
MD5 bb16055a1844e4aaeda4804ab240f817
BLAKE2b-256 3dd77cb3b528d983de81335091f0c5154bf6fa8ffc7784c73420dcde9d53cb0c

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