Home | Trees | Indices | Help |
|
---|
|
Provides general-purpose utilities.
Author: Kenneth J. Pronovici <pronovic@ieee.org>
|
|||
AbsolutePathList Class representing a list of absolute paths. |
|||
ObjectTypeList Class representing a list containing only objects with a certain type. |
|||
RestrictedContentList Class representing a list containing only object with certain values. |
|||
RegexMatchList Class representing a list containing only strings that match a regular expression. |
|||
RegexList Class representing a list of valid regular expression strings. |
|||
_Vertex Represents a vertex (or node) in a directed graph. |
|||
DirectedGraph Represents a directed graph. |
|||
PathResolverSingleton Singleton used for resolving executable paths. |
|||
UnorderedList Class representing an "unordered list". |
|||
Pipe Specialized pipe class for use by executeCommand .
|
|||
Diagnostics Class holding runtime diagnostic information. |
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
|||
ISO_SECTOR_SIZE = 2048.0 Size of an ISO image sector, in bytes. |
|||
BYTES_PER_SECTOR = 2048.0 Number of bytes (B) per ISO sector. |
|||
BYTES_PER_KBYTE = 1024.0 Number of bytes (B) per kilobyte (kB). |
|||
BYTES_PER_MBYTE = 1048576.0 Number of bytes (B) per megabyte (MB). |
|||
BYTES_PER_GBYTE = 1073741824.0 Number of bytes (B) per megabyte (GB). |
|||
KBYTES_PER_MBYTE = 1024.0 Number of kilobytes (kB) per megabyte (MB). |
|||
MBYTES_PER_GBYTE = 1024.0 Number of megabytes (MB) per gigabyte (GB). |
|||
SECONDS_PER_MINUTE = 60.0 Number of seconds per minute. |
|||
MINUTES_PER_HOUR = 60.0 Number of minutes per hour. |
|||
HOURS_PER_DAY = 24.0 Number of hours per day. |
|||
SECONDS_PER_DAY = 86400.0 Number of seconds per day. |
|||
UNIT_BYTES = 0 Constant representing the byte (B) unit for conversion. |
|||
UNIT_KBYTES = 1 Constant representing the kilobyte (kB) unit for conversion. |
|||
UNIT_MBYTES = 2 Constant representing the megabyte (MB) unit for conversion. |
|||
UNIT_GBYTES = 4 Constant representing the gigabyte (GB) unit for conversion. |
|||
UNIT_SECTORS = 3 Constant representing the ISO sector unit for conversion. |
|||
_UID_GID_AVAILABLE = True
|
|||
logger = logging.getLogger("CedarBackup3.log.util")
|
|||
outputLogger = logging.getLogger("CedarBackup3.output")
|
|||
MTAB_FILE =
|
|||
MOUNT_COMMAND =
|
|||
UMOUNT_COMMAND =
|
|||
DEFAULT_LANGUAGE =
|
|||
LANG_VAR =
|
|||
LOCALE_VARS =
|
|||
__package__ =
|
|
Returns the keys of the dictionary sorted by value.
|
Converts a size in one unit to a size in another unit. This is just a convenience function so that the functionality can be implemented in just one place. Internally, we convert values to bytes and then to the final unit. The available units are:
|
Get the uid/gid associated with a user/group pair This is a no-op if user/group functionality is not available on the platform.
|
Changes ownership of path to match the user and group. This is a no-op if user/group functionality is not available on the
platform, or if the either passed-in user or group is
|
Splits a command line string into a list of arguments. Unfortunately, there is no "standard" way to parse a command
line string, and it's actually not an easy problem to solve portably
(essentially, we have to emulate the shell argument-processing logic).
This code only respects double quotes ( Incidentally, I found this particular parsing method while digging around in Google Groups, and I tweaked it for my own use.
|
Resolves the real path to a command through the path resolver mechanism. Both extensions and standard Cedar Backup functionality need a way to resolve the "real" location of various executables. Normally, they assume that these executables are on the system path, but some callers need to specify an alternate location. Ideally, we want to handle this configuration in a central location. The Cedar Backup path resolver mechanism (a singleton called PathResolverSingleton) provides the central location to store the mappings. This function wraps access to the singleton, and is what all functions (extensions or standard functionality) should call if they need to find a command. The passed-in command must actually be a list, in the standard form
used by all existing Cedar Backup code (something like
If the passed-in command can't be resolved or no mapping exists, then the command itself will be returned unchanged. This way, we neatly fall back on default behavior if we have no sensible alternative.
|
Executes a shell command, hopefully in a safe way. This function exists to replace direct calls to Instead, it's safer to pass a list of arguments in the style supported
bt Under the normal case, this function will return a tuple of
By default, The The
Notes:
|
Calculates the age (in days) of a file. The "age" of a file is the amount of time since the file was
last used, per the most recent of the file's Technically, we only intend this function to work with files, but it will probably work with anything on the filesystem.
|
Safely encodes a filesystem path as a Unicode string, converting bytes to fileystem encoding if necessary.
See Also: http://lucumr.pocoo.org/2013/7/2/the-updated-guide-to-unicode/ |
Attempts to portably return the null device on this system. The null device is something like |
Converts English day name to numeric day of week as from
For instance, the day
|
Indicates whether "today" is the backup starting day per configuration. If the current day's English name matches the indicated starting day, then today is a starting day.
|
Returns a "normalized" path based on a path name. A normalized path is a representation of a path that is also a valid
file name. To make a valid file name out of a complete path, we have to
convert or remove some characters that are significant to the filesystem
-- in particular, the path separator and any leading Note that this is a one-way transformation -- you can't safely derive the original path from the normalized path. To normalize a path, we begin by looking at the first character. If
the first character is As a special case, a path consisting only of a single
|
Removes all of the keys from the dictionary. The dictionary is altered in-place. Each key must exist in the dictionary.
|
Format a byte quantity so it can be sensibly displayed. It's rather difficult to look at a number like "72372224 bytes" and get any meaningful information out of it. It would be more useful to see something like "69.02 MB". That's what this function does. Any time you want to display a byte value, i.e.: print "Size: %s bytes" % bytes Call this function instead: print "Size: %s" % displayBytes(bytes) What comes out will be sensibly formatted. The indicated number of
digits will be listed after the decimal point, rounded based on whatever
rules are used by Python's standard
|
Gets a reference to a named function. This does some hokey-pokey to get back a reference to a dynamically
named function. For instance, say you wanted to get a reference to the
myfunc = getFunctionReference("os.path", "isdir") Although we won't bomb out directly, behavior is pretty much undefined
if you pass in The only validation we enforce is that whatever we get back must be callable. I derived this code based on the internals of the Python unittest implementation. I don't claim to completely understand how it works.
Copyright: Some of this code, prior to customization, was originally part of the Python 2.3 codebase. Python code is copyright (c) 2001, 2002 Python Software Foundation; All Rights Reserved. |
Mounts the indicated device at the indicated mount point. For instance, to mount a CD, you might use device path
Note:
This only works on platforms that have a concept of
"mounting" a filesystem through a command-line
|
Unmounts whatever device is mounted at the indicated mount point. Sometimes, it might not be possible to unmount the mount point
immediately, if there are still files open there. Use the
If the indicated mount point is not really a mount point per
If
Note:
This only works on platforms that have a concept of
"mounting" a filesystem through a command-line
|
Indicates whether a specific filesystem device is currently mounted. We determine whether the device is mounted by looking through the
system's
Note: This only works on platforms that have a concept of an mtab file to show mounted volumes, like UNIXes. It won't work on Windows. |
Sanitizes the operating system environment. The operating system environment is contained in
Currently, all it does is reset the locale (removing
The
|
Deference a soft link, optionally normalizing it to an absolute path.
|
Checks that all values are unique. The values list is checked for duplicate values. If there are duplicates, an exception is thrown. All duplicate values are listed in the exception.
|
Parses a list of values out of a comma-separated string. The items in the list are split by comma, and then have whitespace
stripped. As a special case, if
|
|
LOCALE_VARS
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 | http://epydoc.sourceforge.net |