Orbits  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
Classes | Functions | Variables
os Namespace Reference

Classes

class  _Environ
 

Functions

def _get_exports_list
 
def makedirs
 
def removedirs
 
def renames
 
def walk
 
def execl
 
def execle
 
def execlp
 
def execlpe
 
def execvp
 
def execvpe
 
def _execvpe
 
def unsetenv
 
def getenv
 
def _exists
 
def _spawnvef
 
def spawnv
 
def spawnve
 
def spawnvp
 
def spawnvpe
 
def spawnl
 
def spawnle
 
def spawnlp
 
def spawnlpe
 
def popen2
 
def popen3
 
def popen4
 
def _make_stat_result
 
def _pickle_stat_result
 
def _make_statvfs_result
 
def _pickle_statvfs_result
 

Variables

 _names = sys.builtin_module_names
 
list __all__
 
string name = 'posix'
 
string linesep = '\n'
 
int SEEK_SET = 0
 
int SEEK_CUR = 1
 
int SEEK_END = 2
 
dictionary environ = {}
 
int P_WAIT = 0
 
int P_NOWAIT = 1
 

Function Documentation

def os._execvpe (   file,
  args,
  env = None 
)
private
def os._exists (   name)
private
def os._get_exports_list (   module)
private
def os._make_stat_result (   tup,
  dict 
)
private
def os._make_statvfs_result (   tup,
  dict 
)
private
def os._pickle_stat_result (   sr)
private
def os._pickle_statvfs_result (   sr)
private
def os._spawnvef (   mode,
  file,
  args,
  env,
  func 
)
private
def os.execl (   file,
  args 
)
execl(file, *args)

Execute the executable file with argument list args, replacing the
current process. 
def os.execle (   file,
  args 
)
execle(file, *args, env)

Execute the executable file with argument list args and
environment env, replacing the current process. 
def os.execlp (   file,
  args 
)
execlp(file, *args)

Execute the executable file (which is searched for along $PATH)
with argument list args, replacing the current process. 
def os.execlpe (   file,
  args 
)
execlpe(file, *args, env)

Execute the executable file (which is searched for along $PATH)
with argument list args and environment env, replacing the current
process. 
def os.execvp (   file,
  args 
)
execvp(file, args)

Execute the executable file (which is searched for along $PATH)
with argument list args, replacing the current process.
args may be a list or tuple of strings. 
def os.execvpe (   file,
  args,
  env 
)
execvpe(file, args, env)

Execute the executable file (which is searched for along $PATH)
with argument list args and environment env , replacing the
current process.
args may be a list or tuple of strings. 
def os.getenv (   key,
  default = None 
)
Get an environment variable, return None if it doesn't exist.
The optional second argument can specify an alternate default.
def os.makedirs (   name,
  mode = 0777 
)
makedirs(path [, mode=0777])

Super-mkdir; create a leaf directory and all intermediate ones.
Works like mkdir, except that any intermediate path segment (not
just the rightmost) will be created if it does not exist.  This is
recursive.
def os.popen2 (   cmd,
  mode = "t",
  bufsize = -1 
)
Execute the shell command 'cmd' in a sub-process.  On UNIX, 'cmd'
may be a sequence, in which case arguments will be passed directly to
the program without shell intervention (as with os.spawnv()).  If 'cmd'
is a string it will be passed to the shell (as with os.system()). If
'bufsize' is specified, it sets the buffer size for the I/O pipes.  The
file objects (child_stdin, child_stdout) are returned.
def os.popen3 (   cmd,
  mode = "t",
  bufsize = -1 
)
Execute the shell command 'cmd' in a sub-process.  On UNIX, 'cmd'
may be a sequence, in which case arguments will be passed directly to
the program without shell intervention (as with os.spawnv()).  If 'cmd'
is a string it will be passed to the shell (as with os.system()). If
'bufsize' is specified, it sets the buffer size for the I/O pipes.  The
file objects (child_stdin, child_stdout, child_stderr) are returned.
def os.popen4 (   cmd,
  mode = "t",
  bufsize = -1 
)
Execute the shell command 'cmd' in a sub-process.  On UNIX, 'cmd'
may be a sequence, in which case arguments will be passed directly to
the program without shell intervention (as with os.spawnv()).  If 'cmd'
is a string it will be passed to the shell (as with os.system()). If
'bufsize' is specified, it sets the buffer size for the I/O pipes.  The
file objects (child_stdin, child_stdout_stderr) are returned.
def os.removedirs (   name)
removedirs(path)

Super-rmdir; remove a leaf directory and all empty intermediate
ones.  Works like rmdir except that, if the leaf directory is
successfully removed, directories corresponding to rightmost path
segments will be pruned away until either the whole path is
consumed or an error occurs.  Errors during this latter phase are
ignored -- they generally mean that a directory was not empty.
def os.renames (   old,
  new 
)
renames(old, new)

Super-rename; create directories as necessary and delete any left
empty.  Works like rename, except creation of any intermediate
directories needed to make the new pathname good is attempted
first.  After the rename, directories corresponding to rightmost
path segments of the old name will be pruned way until either the
whole path is consumed or a nonempty directory is found.

Note: this function can fail with the new directory structure made
if you lack permissions needed to unlink the leaf directory or
file.
def os.spawnl (   mode,
  file,
  args 
)
spawnl(mode, file, *args) -> integer

Execute file with arguments from args in a subprocess.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. 
def os.spawnle (   mode,
  file,
  args 
)
spawnle(mode, file, *args, env) -> integer

Execute file with arguments from args in a subprocess with the
supplied environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. 
def os.spawnlp (   mode,
  file,
  args 
)
spawnlp(mode, file, *args) -> integer

Execute file (which is looked for along $PATH) with arguments from
args in a subprocess with the supplied environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. 
def os.spawnlpe (   mode,
  file,
  args 
)
spawnlpe(mode, file, *args, env) -> integer

Execute file (which is looked for along $PATH) with arguments from
args in a subprocess with the supplied environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. 
def os.spawnv (   mode,
  file,
  args 
)
spawnv(mode, file, args) -> integer

Execute file with arguments from args in a subprocess.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. 
def os.spawnve (   mode,
  file,
  args,
  env 
)
spawnve(mode, file, args, env) -> integer

Execute file with arguments from args in a subprocess with the
specified environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. 
def os.spawnvp (   mode,
  file,
  args 
)
spawnvp(mode, file, args) -> integer

Execute file (which is looked for along $PATH) with arguments from
args in a subprocess.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. 
def os.spawnvpe (   mode,
  file,
  args,
  env 
)
spawnvpe(mode, file, args, env) -> integer

Execute file (which is looked for along $PATH) with arguments from
args in a subprocess with the supplied environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. 
def os.unsetenv (   key)
def os.walk (   top,
  topdown = True,
  onerror = None,
  followlinks = False 
)
Directory tree generator.

For each directory in the directory tree rooted at top (including top
itself, but excluding '.' and '..'), yields a 3-tuple

    dirpath, dirnames, filenames

dirpath is a string, the path to the directory.  dirnames is a list of
the names of the subdirectories in dirpath (excluding '.' and '..').
filenames is a list of the names of the non-directory files in dirpath.
Note that the names in the lists are just names, with no path components.
To get a full path (which begins with top) to a file or directory in
dirpath, do os.path.join(dirpath, name).

If optional arg 'topdown' is true or not specified, the triple for a
directory is generated before the triples for any of its subdirectories
(directories are generated top down).  If topdown is false, the triple
for a directory is generated after the triples for all of its
subdirectories (directories are generated bottom up).

When topdown is true, the caller can modify the dirnames list in-place
(e.g., via del or slice assignment), and walk will only recurse into the
subdirectories whose names remain in dirnames; this can be used to prune
the search, or to impose a specific order of visiting.  Modifying
dirnames when topdown is false is ineffective, since the directories in
dirnames have already been generated by the time dirnames itself is
generated.

By default errors from the os.listdir() call are ignored.  If
optional arg 'onerror' is specified, it should be a function; it
will be called with one argument, an os.error instance.  It can
report the error to continue with the walk, or raise the exception
to abort the walk.  Note that the filename is available as the
filename attribute of the exception object.

By default, os.walk does not follow symbolic links to subdirectories on
systems that support them.  In order to get this functionality, set the
optional argument 'followlinks' to true.

Caution:  if you pass a relative pathname for top, don't change the
current working directory between resumptions of walk.  walk never
changes the current directory, and assumes that the client doesn't
either.

Example:

import os
from os.path import join, getsize
for root, dirs, files in os.walk('python/Lib/email'):
    print root, "consumes",
    print sum([getsize(join(root, name)) for name in files]),
    print "bytes in", len(files), "non-directory files"
    if 'CVS' in dirs:
        dirs.remove('CVS')  # don't visit CVS directories

Variable Documentation

list os.__all__
Initial value:
1 = ["altsep", "curdir", "pardir", "sep", "extsep", "pathsep", "linesep",
2  "defpath", "name", "path", "devnull",
3  "SEEK_SET", "SEEK_CUR", "SEEK_END"]
os._names = sys.builtin_module_names
dictionary os.environ = {}
string os.linesep = '\n'
string os.name = 'posix'
int os.P_NOWAIT = 1
int os.P_WAIT = 0
int os.SEEK_CUR = 1
int os.SEEK_END = 2
int os.SEEK_SET = 0

Copyright 2014 Google Inc. All rights reserved.