The routines in netsa.files are intended to help with manipulation of files in the filesystem as well as pathnames.
Given a target path along with a reference path, return the relative path from the target to the reference.
This is a logical operation that does not consult the physical filesystem.
os.path.relpath in Python 2.6 adds something similar to this.
Given a target path along with a base reference path, return whether or not the base path subsumes the target path.
This is a logical operation that does not consult the physical filesystem.
This form of lock is generally used by services that wish to ensure that only one copy of the service is running at a time.
Attempts to acquire a locking PID file at the requested pathname path. If the file does not exist, creates it with the current process ID. If the file does exist but refers to a no-longer-existing process, attempts to replace it. If the file does exist and refers to a running process, does nothing.
Registers the lock to be released (as with release_pidfile_lock) when the currently running process exits, if it has not already been released.
Returns True if this process holds the lock, or False if another running process holds the lock.
Examines the state of a locking PID file at path and returns it. If the file does not exist or is not in the proper format, returns None. If the file does exist and contains a PID, returns (pid, state) where pid is the process ID holding the lock, and state is True if a running process has that process ID, or False otherwise.
Attempts to release a locking PID file at the requested pathname path. If the file does not exist or contains a lock for a different PID, does nothing. Otherwise, unlinks the file.
Return the path to a file named file_name in a temporary directory that will be cleaned up when the process exits. If file_name is None then a new file name is created that has not been used before.
A temporary file at the named location will be cleaned up as long as the Python interpreter exits normally.
Returns an open file object for the file named file_name in the temporary working directory, with the given mode (as described in open. If file_name is None then a new file name is used that has not been used before.
The resulting temporary file will be cleaned up as long as the Python interpreter exits normally.
Returns the path to a named pipe file_name that has been created in a temporary directory that will be cleaned up when the process exits. If file_name is None then a new file name is created that has not been used before.