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.21 and 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.0)

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.

3.1 changes

  • Several issues with Windows support were fixed.

  • configman.config_item() now supports a safe_mode switch, which will speed up Windows usage of loadconfig() at some risk. See the note on config_item().

  • Named child loggers are now implemented on several cjnfuncs modules. By default, logging from cjnfuncs modules is disabled (internal logging events are usually at the INFO or DEBUG level, while the default logging level is set to WARNING). For example, logging from configman may be enabled by logging.getLogger('cjnfuncs.configman').setLevel(logging.INFO), or using core.set_logging_level(logging.INFO, 'cjnfuncs.configman').

  • Changed mungePath set_attributes from default True to default False to avoid long processing time on Windows by default.

  • deployfiles can now create an empty target directory.

3.1.1 changes

  • get_next_dt now supports a days or weeks offset for the days arg
  • Added separate child logger cjnfuncs.resourcelock_islocked so that is_locked() may be called in a loop without flooding the log while cjnfuncs.resourcelock is set to debug

Revision history

  • 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.2

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.2
File Size Uploaded
cjnfuncs-3.2.2.tar.gz 51.0 kB Details

Built distribution (wheel)

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

Total release size: 104.1 kB

Release files / cjnfuncs-3.2.2.tar.gz

Download URL cjnfuncs-3.2.2.tar.gz
Size 51.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5919e7235118fc6027e38158539b3c6381611c4d94de1c5fe7aa53f3f53f0e41
BLAKE2b-256 checksum
How to use checksums
16bb6fb97ecba8f2f3cf967391071de9d98bcdbfee6fc5ae8609bf98b908497d
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.2-py3-none-any.whl

Download URL cjnfuncs-3.2.2-py3-none-any.whl
Size 53.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f14f40522607e1a1d48ced8e71b0817f82a61ac91ccdc6b60c04ff2a8c142a8
BLAKE2b-256 checksum
How to use checksums
9b151c9202dbfb5d45b51fbefc46143dc7eee822fdd9f16fe47e2919f8c68c8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

3.2.2 This release

2 release files

3.2.1

2 release files

3.2

2 release files

3.1.1

2 release files

3.1

2 release files

3.0.1

2 release files

3.0

2 release files

2.5

2 release files

2.4.1

2 release files

2.4

2 release files

2.3

2 release files

2.2

2 release files

2.1

2 release files

2.0.1

2 release files

2.0

2 release files

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