Python

Running Jupyterhub Docker

Jupyterhub doesn’t seem to have complete instructions available on simply running an instance under Docker with a number of issues, Stackoverflow questions asking for clarifications. These are my quick notes: As the Docker image name indicates, this is singleuser instance preconfigured for user jovyan. Run below command in directory with your notebooks docker run --rm -p 8000:8000 -d -v `pwd`:/home/jovyan/work --name jupyterhub jupyterhub/singleuser jupyterhub There doesn’t seem to be (default) password set for jovyan user, so at this point you cannot login into the GUI.

Splunk custom input with session

Splunk can be extended with custom inputs written in Python. In order to connect to Splunk services, code has to be configured and use a session token. Here is a basic setup emitting records with kvstore names #!/usr/bin/env python import splunklib.client as client import sys import datetime as dt def generate(session_key): service = client.connect(token = session_key) for collection in service.kvstore: ts = dt.datetime.now(tz=dt.timezone.utc).isoformat() print(f'{ts}, collection="{collection.name}"') if __name__ == "__main__": session_key = sys.

Login into a CA SSO/Siteminder protected site with Python Requests

While this below code is simple, it uses two important approaches: utilizes a Requests Session to keep Siteminder login cookies/headers it has a two step load, allowing to fill out the Siteminder form import requests if __name__ == "__main__": mysite = 'http://mysite/' credentials = {'USER': 'myuser', 'PASSWORD': 'mypassword'} s = requests.session() # use Session to keep cookies around page = s.get(mysite) s.post(page.url, data=credentials) # page.url is the Siteminder login screen page = s.