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 Logrus is a collection of random utility functions

Project Description

The logrus is a collection of random utility functions. Nothing in here
is all that special, they're just yet another implementation of
functions I've rewritten at every job to use in various utility scripts.
By open sourcing them now, I'm hoping to not have to write them again.


``pip install logrus``


Everything in this repository is Apache 2.0 licensed.

Included functions



Given a list ['foo','bar', 'baz'], attempts to create a command name in
the format 'foo-bar-baz'. If that command exists, we run it. If it
doesn't, we check to see if foo-bar exists, in which case we run
``foo-bar baz``. We keep taking chunks off the end of the command name
and adding them to the argument list until we find a valid command name
we can run.

This allows us to easily make git-style command drivers where for
example we have a driver script, foo, and subcommand scripts foo-bar and
foo-baz, and when the user types ``foo bar foobar`` we find the foo-bar
script and run it as ``foo-bar foobar``

:param list\|tuple args: list to try and convert to a command args pair
:returns: command and arguments list :rtype: tuple :raises
StandardError: if the args can't be matched to an executable subcommand

Example usage:


def fooDriver():
Process the command line arguments and run the appropriate foo subcommand.

We want to be able to do git-style handoffs to subcommands where if we
do `foo blah foo bar` and the executable foo-blah-foo exists, we'll call
it with the argument bar.

We deliberately don't do anything with the arguments other than hand
them off to the foo subcommand. Subcommands are responsible for their
own argument parsing.
(command, args) = findSubCommand(sys.argv)

# If we can't construct a subcommand from sys.argv, it'll still be able
# to find this foo driver script, and re-running ourself isn't useful.
if os.path.basename(command) == 'foo':
print "Could not find a subcommand for %s" % ' '.join(sys.argv)
except StandardError:
print "Could not find a subcommand for %s" % ' '.join(sys.argv)
check_call([command] + args)


Search for a given program in ``$PATH``, and return True if it exists
and is executable.

:param str name: Name of program to search for :returns: whether or not
the program can be found in $PATH :rtype: bool



os module doesn't have a ``mkdir -p`` equivalent so added one.
Release History

Release History

This version
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
logrus-0.0.6-py2-none-any.whl (4.3 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Apr 2, 2017
logrus-0.0.6.tar.gz (3.5 kB) Copy SHA256 Checksum SHA256 Source Apr 2, 2017

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