Skip to main content

A python utility package

Project description

How to install?

python3 -m pip install --upgrade pip

pip3 install pyutil-juposs

Defaults

Custom defaults can be stored in $HOME/pyutil_settings.json

See https://github.com/juposs/pyutil/blob/master/pyutil_settings.json_sample

Everything that is not defined in $HOME/pyutil_settings.json will be read from

"$HOME/.local/lib/python3.X/site-packages/pyutil/defaults.py" depending on your installed python version

Usage:

  1. ldap: This will search for ldap object where userPrincipalName equals john.doe@example.org and return the value of pwdlastlet to the variable "result" and return whatever is in extensionAttribute12 to variable "result2"
        from pyutil import Ldap

        Modify defaults and use the minumum parameters:
        instance = Ldap("binduser@example.org", "strongpass", "john.doe@example.org")

        or give all parameters:
        instance = Ldap("binduser@example.org", "strongpass", "john.doe@example.org", "userPrincipalName", "OU=OrgUnit,DC=example,DC=org", "server.example.org")

        then run query with that instance:
        result = instance.query("pwdlastset")
        result2 = instance.query("extensionAttribute12")
  1. mail:
        from pyutil import Mail

        Modify defaults and use the minumum parameters:
        instance = Mail()

        or give all parameters:
        email = Mail("no-rely@example.org", "mailserver.example.org", "25", true, "/path/to/myfile.txt")
        email = Mail("no-rely@example.org", "mailserver.example.org", "25", false)

        then send the mail with that instance:
        instance.send(subject, text, receipient1 [, receipient2])
  1. logging:
        from pyutil import Logger

        Modify defaults and use the minumum parameters:
        logfile1 = Logger()

        or give all parameters:
        logfile1 = Logger("/path/to/logfile", maxBytes=1000, backupCount=10)

        Logfile will rotate after reaching maxBytes, default is '0', never rotate
        If rotation enabled, it will keep 'backupCount' files, default is 10

        then log stuff, for instance:
        log1.info("info")
        log1.warning("Warning")
        log1.error("Error")
        log1.debug("Debug")

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

pyutil-juposs-2.1.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

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

pyutil_juposs-2.1.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file pyutil-juposs-2.1.0.tar.gz.

File metadata

  • Download URL: pyutil-juposs-2.1.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for pyutil-juposs-2.1.0.tar.gz
Algorithm Hash digest
SHA256 56d232466e6366aaccc8ea2cc4cc73827e51c65ac51c786d111905d2d97e4183
MD5 db8a8f5e95be39510d646e52a64bdc62
BLAKE2b-256 bc0866997a5bb9b8773a37a184790959626707e0a114b1718e11525118341507

See more details on using hashes here.

File details

Details for the file pyutil_juposs-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyutil_juposs-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for pyutil_juposs-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 daf23ed286d66925452c9ddbf0306d2d548e64699ee94456f8aeb73c99fdb88a
MD5 3839b2497d9bb7cc0de5e39f6a0467ee
BLAKE2b-256 9c9bef497b59b701991a5e69df465c4b4941498e3fdb838d648c20fd75785b87

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