Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

The easiest way to use the command line with Python. Command Line Object Mapper. A library for building POSIX command line arguments, commands, and parameters. Very useful for Fabric tasks.

Project Description

Clom is a Python Command Line Object Mapper. It’s intended to make generating generating commands and escaping arguments easier for command line interaction. It’s particularly useful when used with Fabric or subprocess.


Install with pip or easy_install.

pip install clom

Usage Examples


>>> from clom import clom

Build a command:

>>> clom.echo("Don't test me")
"echo 'Don'\\''t test me'"

Augment with arguments:

>>>'-a', '-t', l=True).with_args('~/')
'ls -a -t -l '~/''
>>> clom.curl('', X='POST', data='message=hello')
'curl -X POST --data message=hello'

Use sub commands:

>>> clom.git.checkout('mybranch')
'git checkout mybranch'

Execute with ease:

['clom', 'clom.egg-info', 'docs', 'tests']

'# On branch master'

Iterate over results:

>>> for path in
...     print path

Handle errors:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/mthornton/Dropbox/Projects/python-clom/src/clom/", line 164, in __call__
    raise CommandError(status, stdout, stderr, 'Error while executing "%s" (%s):\n%s' % (cmd, status, stderr or stdout))
CommandError: Error while executing "vagrant up" (3):
No Vagrant environment detected. Run `vagrant init` to set one up.

Group commands:

>>> from clom import AND, OR
>>> OR(clom.vagrant.up, clom.echo('Vagrant up failed'))
'( vagrant up || echo 'Vagrant up failed' )'
>>> OR(clom.vagrant.up, clom.echo('Vagrant up failed')).shell()
< object at 0x10c4a85d0>
>>> print OR(clom.vagrant.up, clom.echo('Vagrant up failed')).shell()
No Vagrant environment detected. Run `vagrant init` to set one up.
Vagrant up failed

Re-use commands:

>>> vbox = clom.VBoxManage
>>> vbox.list.runningvms
'VBoxManage list runningvms'
['"Windows Base" {949ec0af-92d0-4140-8a6c-36301ca6f695}']

Background tasks:

>>> clom.VBoxHeadless.with_opts(startvm="Windows Base").background()
'nohup VBoxHeadless --startvm 'Windows Base' &> /dev/null &'
>>> clom.VBoxHeadless.with_opts(startvm="Windows Base").background().shell()
<CommandResult return_code=0, stdout=0 bytes, stderr=0 bytes>

['"Windows Base" {949ec0af-92d0-4140-8a6c-36301ca6f695}']

Works great with fabric:

>>> from fabric.api import run, local
>>> local(
[localhost] local: ls
clom            clom.egg-info   docs            nohup.out       tests

Can even create fab commands:

>>> clom.fab.test('doctest', 'unit').deploy('dev')
'fab test:doctest,unit deploy:dev'
>>> clom.fab.with_opts('-a', hosts='').deploy.with_args('dev','test')
'fab -a --hosts deploy:dev,test'

See more examples and the API in the Clom Documentation

Running Tests

Test are run using pytest:

pip install pytest
python tests/ -v --doctest-modules
Release History

Release History

History Node


This version
History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
clom-0.7.5.tar.gz (9.1 kB) Copy SHA256 Checksum SHA256 Source Oct 2, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting