# Path: canaryd/subprocess.py
# def ensure_command_tuple(command):
# def decode_output(output):
# def get_command_output(command, *args, **kwargs):


import json
from canaryd.subprocess import CalledProcessError, get_command_output
    for container in data:
        command = container['Config']['Cmd']
        if isinstance(command, list):
            command = ' '.join(command)

        container_data = {
            'runtime': 'docker',
            'running': container['State']['Running'],
            'command': command,
            'environment': container['Config']['Env'],
            'image': container['Config']['Image'],
            'id': container['Id'],
        }

        # Figure out the name(s)
        if 'Names' in container:
            container_data['names'] = container['Names']

        elif 'Name' in container:
            container_data['names'] = [container['Name']]

        # If running, get the PID
        if container_data['running']:
            container_data['pid'] = container['State']['Pid']

        container_id = container['Id'][:6]
        container_key = 'docker/{0}'.format(container_id)

        containers[container_key] = container_data


# Path: canaryd/subprocess.py
# def ensure_command_tuple(command):
# def decode_output(output):
# def get_command_output(command, *args, **kwargs):


# Path: canaryd/plugins/containers_util.py
import json
from canaryd.subprocess import CalledProcessError, get_command_output

    for container in data:
        command = container['Config']['Cmd']
        if isinstance(command, list):
            command = ' '.join(command)

        container_data = {
            'runtime': 'docker',
            'running': container['State']['Running'],
            'command': command,
            'environment': container['Config']['Env'],
            'image': container['Config']['Image'],
            'id': container['Id'],
        }

        # Figure out the name(s)
        if 'Names' in container:
            container_data['names'] = container['Names']

        elif 'Name' in container:
            container_data['names'] = [container['Name']]

        # If running, get the PID
        if container_data['running']:
            container_data['pid'] = container['State']['Pid']

        container_id = container['Id'][:6]
        container_key = 'docker/{0}'.format(container_id)

        containers[container_key] = container_data


    return containers