Skip to content

Commit

Permalink
updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
olt committed Nov 4, 2009
1 parent 39f275c commit ca3edec
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 9 deletions.
19 changes: 19 additions & 0 deletions doc/modules/log.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
:mod:`scriptine.log` -- simple logging for commands
===================================================

Module Contents
---------------

.. module:: scriptine.log

Calling shell commands
^^^^^^^^^^^^^^^^^^^^^^

.. autofunction:: mark
.. autofunction:: info

.. autofunction:: warn
.. autofunction:: error
.. autofunction:: fatal
.. autofunction:: debug

11 changes: 5 additions & 6 deletions doc/modules/path.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
:mod:`scriptine.path` -- framework for paster create templates
======================================================================
:mod:`scriptine.path` -- work with files and directories
========================================================

Module Contents
---------------
Expand Down Expand Up @@ -32,9 +32,9 @@ Operations on path
.. autoattribute:: path.ext
.. autoattribute:: path.drive
.. automethod:: path.expand
.. automethod:: path._get_namebase
.. automethod:: path._get_ext
.. automethod:: path._get_drive
.. .. automethod:: path._get_namebase
.. .. automethod:: path._get_ext
.. .. automethod:: path._get_drive
.. automethod:: path.splitpath
.. automethod:: path.splitdrive
.. automethod:: path.splitext
Expand Down Expand Up @@ -86,7 +86,6 @@ Querying the filesystem
.. automethod:: path.access
.. automethod:: path.stat
.. automethod:: path.lstat
.. automethod:: path.get_owner
.. automethod:: path.statvfs
.. automethod:: path.pathconf

Expand Down
18 changes: 18 additions & 0 deletions doc/modules/shell.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
:mod:`scriptine.shell` -- call other shell commands
===================================================

Module Contents
---------------

.. module:: scriptine.shell

Calling shell commands
^^^^^^^^^^^^^^^^^^^^^^

.. autofunction:: call
.. autofunction:: sh

.. autofunction:: backtick
.. autofunction:: backtick_


8 changes: 7 additions & 1 deletion scriptine/log.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys

__all__ = ['warn', 'error', 'debug', 'info']
__all__ = ['warn', 'error', 'debug', 'info', 'mark']

L_DEBUG = -1
L_INFO = 0
Expand All @@ -23,27 +23,33 @@ def log(msg, *args):
sys.stderr.flush()

def mark(msg, *args):
"log a process step"
if _level <= L_MARK:
log('---> ' + msg, *args)

def info(msg, *args):
"log an info message"
if _level <= L_INFO:
log('INFO: ' + msg, *args)

def warn(msg, *args):
"log a warning message"
if _level <= L_WARN:
log('WARN: ' + msg, *args)

def error(msg, *args):
"log an error message"
if _level <= L_ERROR:
log('ERROR: ' + msg, *args)

def fatal(msg, *args):
"log an error message and abort the script"
log('ERROR: ' + msg, *args)
log('aborting script...')
sys.exit(1)


def debug(msg, *args):
"log a debug message"
if _level <= L_DEBUG:
log('DEBUG: ' + msg, *args)
10 changes: 8 additions & 2 deletions scriptine/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
@dry_guard
def call(command):
"""
Call `command`.
Call `command`. `command` should be a list of the executable and
all arguments.
>>> call(['some_command', '-v', some_argument]) # doctest: +SKIP
:returns: return code of the command
"""
Expand All @@ -13,7 +16,10 @@ def call(command):
@dry_guard
def sh(command):
"""
Call `command` in a new shell.
Call `command` in a new shell. `command` should be a string with
all arguments.
>>> call('some_command -v arg') # doctest: +SKIP
:returns: return code of the command
"""
Expand Down

0 comments on commit ca3edec

Please sign in to comment.