Package backend :: Package common :: Module fileutils
[hide private]
[frames] | no frames]

Module fileutils

source code

Classes [hide private]
  GecosCache
Cache getpwnam() and getgrnam() calls
  payload
this class implements simple file like object usable for reading payload from rpm, mpm, etc.
Functions [hide private]
 
cleanupAbsPath(path)
take ~taw/../some/path/$MOUNT_POINT/blah and make it sensible.
source code
 
cleanupNormPath(path, dotYN=0)
take ~taw/../some/path/$MOUNT_POINT/blah and make it sensible.
source code
 
rotateFile(filepath, depth=5, suffix='.', verbosity=0)
backup/rotate a file depth (-1==no limit) refers to num.
source code
 
rhn_popen(cmd, progressCallback=None, bufferSize=16384, outputLog=None)
popen-like function, that accepts execvp-style arguments too (i.e.
source code
 
makedirs(path, mode=493, user=None, group=None)
makedirs function that also changes the owners
source code
 
createPath(path, user=None, group=None, chmod=493)
advanced makedirs
source code
 
setPermsPath(path, user=None, group='root', chmod=488)
chown user.group and set permissions to chmod
source code
 
getUidGid(user=None, group=None)
return uid, gid given user and group
source code
 
_ifelse(cond, thenval, elseval) source code
 
ostr_to_sym(octstr, ftype)
Convert filemode in octets (like '644') to string like "ls -l" ("-rwxrw-rw-") ftype is one of: file, directory, symlink, chardev, blockdev.
source code
 
f_date(dbiDate) source code
 
decompress_open(filename, mode='r') source code
Variables [hide private]
  FILETYPE2CHAR = {'blockdev': 'b', 'chardev': 'c', 'directory':...
  __package__ = 'backend.common'
Function Details [hide private]

cleanupAbsPath(path)

source code 
take ~taw/../some/path/$MOUNT_POINT/blah and make it sensible.

Path returned is absolute.
NOTE: python 2.2 fixes a number of bugs with this and eliminates
      the need for os.path.expanduser

cleanupNormPath(path, dotYN=0)

source code 
take ~taw/../some/path/$MOUNT_POINT/blah and make it sensible.

Returned path may be relative.
NOTE: python 2.2 fixes a number of bugs with this and eliminates
      the need for os.path.expanduser

rotateFile(filepath, depth=5, suffix='.', verbosity=0)

source code 
backup/rotate a file
depth (-1==no limit) refers to num. of backups (rotations) to keep.

Behavior:
  (1)
    x.txt (current)
    x.txt.1 (old)
    x.txt.2 (older)
    x.txt.3 (oldest)
  (2)
    all file stats preserved. Doesn't blow away original file.
  (3)
    if x.txt and x.txt.1 are identical (size or checksum), None is
    returned

rhn_popen(cmd, progressCallback=None, bufferSize=16384, outputLog=None)

source code 

popen-like function, that accepts execvp-style arguments too (i.e. an array of params, thus making shell escaping unnecessary)

cmd can be either a string (like "ls -l /dev"), or an array of arguments ["ls", "-l", "/dev"]

Returns the command's error code, a stream with stdout's contents and a stream with stderr's contents

progressCallback --> progress bar twiddler outputLog --> optional log file file object write method

createPath(path, user=None, group=None, chmod=493)

source code 

advanced makedirs

Will create the path if necessary. Will chmod, and chown that path properly. Defaults for user/group to the apache user

Uses the above makedirs() function.


Variables Details [hide private]

FILETYPE2CHAR

Value:
{'blockdev': 'b',
 'chardev': 'c',
 'directory': 'd',
 'file': '-',
 'symlink': 'l'}