Package logilab :: Package common :: Module shellutils
[frames] | no frames]

Module shellutils

source code

shell/term utilities, useful to write some python scripts instead of shell scripts.
Classes
  tempdir
  pushd
  ProgressBar
A simple text progression bar.
  DummyProgressBar
  progress
  RawInput
Functions
 
chown(path, login=None, group=None)
Same as os.chown function but accepting user login or group name as argument. If login or group is omitted, it's left unchanged.
source code
 
mv(source, destination, _action=shutil.move)
A shell-like mv, supporting wildcards.
source code
 
rm(*files)
A shell-like rm, supporting wildcards.
source code
 
cp(source, destination)
A shell-like cp, supporting wildcards.
source code
list
find(directory, exts, exclude=False, blacklist=STD_BLACKLIST)
Recursively find files ending with the given extensions from the directory.
source code
iterator
globfind(directory, pattern, blacklist=STD_BLACKLIST)
Recursively finds files matching glob pattern under directory.
source code
 
unzip(archive, destdir) source code
 
getlogin()
avoid using os.getlogin() because of strange tty / stdin problems (man 3 getlogin) Another solution would be to use $LOGNAME, $USER or $USERNAME
source code
 
generate_password(length=8, vocab=string.ascii_letters+string.digits)
dumb password generation function
source code
Variables
  Execute = deprecated('Use subprocess.Popen instead')(Execute)
  ASK = RawInput()
Function Details

chown(path, login=None, group=None)

source code 

Same as os.chown function but accepting user login or group name as argument. If login or group is omitted, it's left unchanged.

Note: you must own the file to chown it (or be root). Otherwise OSError is raised.

find(directory, exts, exclude=False, blacklist=STD_BLACKLIST)

source code 
Recursively find files ending with the given extensions from the directory.
Parameters:
  • directory (str) - directory where the search should start
  • exts (basestring or list or tuple) - extensions or lists or extensions to search
  • exts (basestring or list or tuple) - if this argument is True, returning files NOT ending with the given extensions
  • blacklist (list or tuple) - optional list of files or directory to ignore, default to the value of logilab.common.STD_BLACKLIST
  • exclude (boolean)
Returns: list
the list of all matching files

globfind(directory, pattern, blacklist=STD_BLACKLIST)

source code 

Recursively finds files matching glob pattern under directory.

This is an alternative to logilab.common.shellutils.find.

Parameters:
  • directory (str) - directory where the search should start
  • pattern (basestring) - the glob pattern (e.g .py, foo.py, etc.)
  • blacklist (list or tuple) - optional list of files or directory to ignore, default to the value of logilab.common.STD_BLACKLIST
Returns: iterator
iterator over the list of all matching files