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/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:

ldap:
    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")

    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"

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])

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-1.0.1.tar.gz (5.5 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-1.0.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyutil-juposs-1.0.1.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for pyutil-juposs-1.0.1.tar.gz
Algorithm Hash digest
SHA256 308771f3a8db14150df703a547fb4af1144db068b48b7900ba4863d959931019
MD5 f0a9df8865b3c283bdd3f89a93c0645c
BLAKE2b-256 1c75d18fe51044583308b5a73b49e9b8e406d78ac3a14ff20986a2cb9db9e6f0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyutil_juposs-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for pyutil_juposs-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 71ff5244b02dfe4555a75c39740b813de9f2aecfdc543ba1990f55e756883f5d
MD5 ca1691553f9fb07faa20a332764b36a6
BLAKE2b-256 516dd9d309de17a71a5b8f18a9da611265118761a47c2e56e13748fa81a9664d

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