Control Docker containers from within container

This is a short note on how to make a container access and control another container on the same host. The trick is to have the “controller” container map the host’s docker.sock into the container.

Read more...

Nuke gizmos to groups

Recursively replace all gizmos in Nuke script with a group. The only exception is the Cryptomatte nodes, which will be maintained as gizmos.

Read more...

Distributing Python script(s) as zip file

A recent discussion on 3DPRO sparked me to scribble down some ideas on how to somewhat painlessly distribute a Python package to be run in DCC applications such as Maya or Nuke as simply as possible. So this is an alternative to building a wheel and mucking around with virtual environments.

Read more...

Google Hangouts Chat incoming webhook using Python standard library only

The official docs on setting up an incoming webhook uses the third-party httplib2, which is not part of the Python 3.6 standard library. Here’s a quick snippet using only the standard library instead:

import json
import urllib.parse
import urllib.request


def main():
    # python 3.6

    url = '<INCOMING-WEBHOOK-URL>'
    bot_message = {'text': 'Hello from Python script!'}
    message_headers = {'Content-Type': 'application/json; charset=UTF-8'}

    byte_encoded = json.dumps(bot_message).encode('utf-8')
    req = urllib.request.Request(url=url, data=byte_encoded, headers=message_headers)
    response = urllib.request.urlopen(req)

    print(response.read())


if __name__ == '__main__':
    main()

Cartesian product in Python

A cartesian product operation can return a set of “combinations” based on given values, so for example I could have the following values:

a b c
1 1 1
  2 2
    3

I would then expect the cartesian product operation to return something like a1b1c1, a1b1c2, a1b1c3, a1b2c1 and so on…

Many, many times have had to solve this problem over and over in Python… it’s time to jot down some notes.

Read more...