Skip to main content

cjnfuncs - A framework and collection of utility functions for script writing

NOTE: These link point to the github repo since relative links to other .md files do not work on PyPI.

module Description/Purpose
core Set up the base environment
configman Feature-rich configuration file toolset
timevalue Handle time values with units, such as '5m' (5 minutes), and schedule future operations
mungePath Ease-of-use pathlib extension for constructing and manipulating file paths
rwt / run_with_timeout Execute any function with an enforced timeout
deployfiles Push bundled setup files within a package to the proper user/system locations
resourcelock Inter-process resource lock mechanism
SMTP Send notification and email messages

Developed and tested on Python 3.9, 3.11, and 3.13. Supported on all higher Python versions. Developed on Linux. Supported on Windows, except for the resourcelock module (posix-ipc module dependency).

In this documentation, "tool script" refers to a Python project that imports and uses cjnfuncs. Some may be simple scripts, and others may themselves be installed packages.


Installation and usage

pip install cjnfuncs

A package template using cjnfuncs is available at https://github.com/cjnaz/tool_template, which is the basis of PyPI posted tools such as:

Project repo: https://github.com/cjnaz/cjnfuncs


Key changes since the prior major public release (version 3.1)

3.2.4 changes

  • Minor, isolated changes
    • core - trap/warning for attempting to open logging to file owned by root
    • resourcelock - added /dev/shm deleted files note

3.2.3 changes

  • Minor, isolated changes
    • configman.write() - the target directory tree is created if not existing, oneliner comment at top of written file
    • configman.write() - config_timestamp only updated when written by persistent_config.save()
    • configman.loadconfig() - remap_logdirbase is disabled for secondary configs
    • configman tuned up debug logging
    • resource lock moved signal traps inside of cli(), else they become global to the entire application -->

3.2.2 change

  • periodic_log output now includes [category - <package>.<module>.<function>(<line number>)] for debug traceability of where the log event came from.

3.2.1 change

  • periodic_log returns True/False whether call was logged - useful for follow on code that needs to run if the logging event happened.

3.2 changes

  • persistent_config - Layered on top of config_item, this new class provides a clean and simple tool for carrying runtime data across tool script restarts and system reboots.

  • Shared memory block handling - Extending resourcelock's features, read/write access is provided to the shared memory block associated with a user-defined lock.


Revision history

  • 3.2.4 261124 - core: trap/warning for attempting to open logging to file owned by root, added resourcelock /dev/shm deleted files note
  • 3.2.3 261022 - Minor, isolated features tuning to configman and resource_lock
  • 3.2.2 261002 - periodic_log output now includes [category - <package>.<module>.<function>(<line number>)] for debug traceability of where the log event came from.
  • 3.2.1 260526 - periodic_log now returns True/False whether the the call was logged. Minor changes in resourcelock.
  • 3.2 260506 - New features: persistent_config and shared memory block handling
  • 3.1.1 260207 - separate resourcelock_islocked logger, get_next_dt days/weeks offset
  • 3.1 251109 Support for and use of child loggers, deployfiles create empty dir, Windows fixes, config_item() safe_mode switch, mungePath set_attributes from default False
  • 3.0.1 251005 - Allow '.' in config section names
  • 3.0 250705 - Added run_with_timeout, set / restore_logging_level, periodic_logging, get_next_dt. Functional change to mungePath.
  • 2.5 250206 - Added multi-line and quoted string support to configman
  • 2.4.1 241118 - resource_lock only init lock_info if not existing
  • 2.4 241105 - Twilio support in snd_notif, resource_lock trace/debug features, check_path_exists exception fix
  • 2.3 240821 - Added mungePath ./ support. Resolved check_path_exists() memory leak. Added same_process_ok to resourcelock.getlock() Added prereload_callback to config_item.loadconfig()
  • 2.2 240119 - Added SMTP DKIM support. Set SMTP server connect timeout to EmailRetryWait.
  • 2.1 240104 - Partitioned to separate modules. Added modify_configfile. Added native support for float, list, tuple, and dict in loadconfig(). Added getcfg() type checking. Documentation touch for logging formats in config file. Improved snd_notif failure logging. Added email/notif send retries. Added resourcelock module.
  • 2.0.1 230222 - deploy_files() fix for files from package
  • 2.0 230208 - Refactored and converted to installed package. Renamed funcs3 to cjnfuncs.
  • ...
  • 0.1 180524 - New. First github posting

Metadata

Release files for cjnfuncs 3.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cjnfuncs 3.2.4
File Size Uploaded Provenance Actions
cjnfuncs-3.2.4.tar.gz 51.7 kB Without provenance Details for cjnfuncs-3.2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cjnfuncs 3.2.4
File Interpreter ABI Platform Actions
cjnfuncs-3.2.4-py3-none-any.whl Python 3 none any Details for cjnfuncs-3.2.4-py3-none-any.whl

Total release size: 105.5 kB

Release files / cjnfuncs-3.2.4.tar.gz

Download URL cjnfuncs-3.2.4.tar.gz
Size 51.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e92dbfc7621f4b965e744b0b4095aa9603c63459b81104ad82315875142fb4df
BLAKE2b-256 checksum
How to use checksums
f20cac2bcd3e01755e3f232495732d01411f55051476c7bbdf71f334436ed784
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / cjnfuncs-3.2.4-py3-none-any.whl

Download URL cjnfuncs-3.2.4-py3-none-any.whl
Size 53.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8338fca9c02c30fe3b8ac20ce991af0533b747b9fbd165245fb2140fcb4588c3
BLAKE2b-256 checksum
How to use checksums
1f0f15317cc398437d61c0ca3b247017c2b52b6e7b29aba29b20d133442cb377
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Security for cjnfuncs 3.2.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page