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

The Logrus is a collection of random utility functions

Project Description
logrus
======

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.

Installation
============

``pip install logrus``

License
=======

Everything in this repository is Apache 2.0 licensed.

Included functions
==================

logrus.cli
----------

findSubCommand(args)
~~~~~~~~~~~~~~~~~~~~

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.
"""
try:
(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)
sys.exit(1)
except StandardError:
print "Could not find a subcommand for %s" % ' '.join(sys.argv)
sys.exit(1)
check_call([command] + args)

isProgram(name)
~~~~~~~~~~~~~~~

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

logrus.utils
------------

mkdir\_p(path)
~~~~~~~~~~~~~~

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

Release History

This version
History Node

0.0.6

History Node

0.0.5

History Node

0.0.4

History Node

0.0.2

History Node

0.0.1

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