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.0.2.tar.gz (7.4 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.0.2-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyutil-juposs-2.0.2.tar.gz
  • Upload date:
  • Size: 7.4 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.0.2.tar.gz
Algorithm Hash digest
SHA256 bea61a3cb35144b694becfddfb112a9c1225c8b3bec8d51f4b9e6be9073de801
MD5 e5a0b5f126d79ba242aab370452119ef
BLAKE2b-256 3d565d53642202401d04bfb7f79ff6fdc870c21b268fad70280324b955fc956a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyutil_juposs-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.7 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.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 72e5309ca2e609408e2d31a27e4d77b39b0c00682e887c170eebca73c6a90fda
MD5 d56ceb167db433603e4024b0d9d96f16
BLAKE2b-256 8a3696066bce21b77110d20e5954cb01ae4d07e814a66a5fc94bd7faac785e04

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