Skip to content

Sweet tiny app framework for Jenkins driven background apps

License

Notifications You must be signed in to change notification settings

turkishmaid/johanna

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

johanna

A sweet tiny app framework for Jenkins driven background apps.

This will support scheduled backgound tasks, typically started fron cron or Jenkins, by super simple

  • setup of a dot-folder in the user's $HOME or use the folder named in $JOHANNA
  • .ini-file based configuration
  • logging support
  • runtime and memory profiling
  • SQLite connection handling
  • mailgun support (needs credentials in the .ini file)

Kickstart Background Procedure

import johanna

def main():
    johanna.apply_schema("./schema.sql")
    with johanna.Connection("Charlotte") as c:
        c.cur.execute("insert or ignore into kvpairs(k, v) values (1, 'eins')")
        c.commit()

if __name__ == "__main__":
    johanna.main(main, mail_subject="Charlotte",
        dbname="charlotte.sqlite")

Kickstart Interactive Consumer

To consume data e.g. in Jupyter Notebooks, you will want less logging, no changes to the database, and no notification email. Please use "interactive mode" for such:

import johanna

johanna.interactive(None, dbname="charlotte.sqlite")
with johanna.Connection("Charlotte") as c:
    c.cur.execute("select * from kvpairs")
    for row in c.cur:
        pass  # do something meaningful

The synonym johanna.interactive() for johanna.main(None,...) has been added to make code more readable.

Mailgun-Anschluss (optional)

Nachdem die Konfigurationsdatei ~/.dwd-cdc/dwd-cdc angelegt ist, kann dort ein Abschnitt wie folgt manuell hinzugefügt werden:

[mailgun]
url = https://api.mailgun.net/v3/sandbox12345678901234567890123.mailgun.org/messages
auth-key = key-8674f976bb0w8678a0ds874sjldao787
from = dwd-cdc <postmaster@sandbox12345678901234567890123.mailgun.org>
to = Sara Ziner <do.not.use@example.com>

Wenn diese Konfiguration vorhanden ist, wird nach jedem Programmlauf die Print- und Log-Ausgabe über den beschriebenen Mailgun-Account an die angegebene to-Adresse geschickt. Weitergehende Konfigurationsmöglichkeiten werden (vielleicht) später hinzugefügt.

Ein kostenloser mailgun Account ("Flex Trial") ist für die Verwendung hier völlig ausreichend. Man muss allerdings die Empfängeradressen vorher als "authorized recipients" anmelden und diese müssen es auch bestätigen.

About

Sweet tiny app framework for Jenkins driven background apps

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages