Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A command and control infrastructure written in Python
tree: 3cfde4e753

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


Just trying to learn python decorators, but it's also somewhat useful. The module stands for "Command and Control"


# In a file named
from comnctl import task, group, local, remote
git = remote("git", "mzlee", "")
servers = group('spam', [git, local])
def start(agent):
    """Start a task"""'echo Starting')
def status(agent):
    """Check the status"""'echo current status')
    agent.out('and some stuff')
def stop(agent):
    """Stop the servers"""

But what's going on here? Let's break it down.

The Module

This module comprises of two main components, a task and an agent.


The agent is some place you want to run a command. Currently it only supports a local shell ('/bin/sh') or a remote server ('ssh'). Additionally, there is support for groups, though currently it only works for groups one level deep.


The task is some set of commands to be run. Currently, it supports arbitrary python (results may vary), print out, and shell out to the specific agent. Because it isn't very fancy, it actually just collects all of the commands and sends them in one block to the sub process.

Additionally, there is some markup to help differentiate between the shell commands ('>>>'), the print out ('<<<'), the print error ('!!!'), and the return value ('---'). This is interweaved to the best of my ability, which admittedly is not very good.

Finally, there is rudimentary support for dependencies, though it does not check for cycles or other nasty things. When defining a function as a task, one can include the list of dependencies. These are called in the order they're listed.


The script 'cnctl' will automatically read and parse the defined file. That is, it basically just dumps the entire into its own namespace and tries to deal with it in a reasonable manner.

Given no arguments, it will list the registered tasks and agents. To run a specific task on a specific agent, use:

cnctl agent.task

For example, if you wanted to run the 'start' task on the local host, you would use

cnctl local.start

Other Stuff

Not sure what else I might add. This was hacked together in two nights so it's going to be very rough.

Feature Requests

(From myself...)

  • A way to define a group of tasks
Something went wrong with that request. Please try again.