|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jnios.posix
This module provides access to operating system functionality that is standardized by the C Standard and the POSIX standard (a thinly disguised Unix interface).
The module is based on the original posixmodule.c except that all mistakes and errors are my own. Original author unknown.
Do not import this module directly. Instead, import the module jnios, which provides a portable version of this interface. On Unix, the jnios module provides a superset of the posix interface. On non-Unix operating systems the posix module is not available, but a subset is always available through the jnios interface. Once jnios is imported, there is no performance penalty in using it instead of posix. In addition, jnios provides some additional functionality, such as automatically calling putenv() when an entry in jnios.environ is changed.
The descriptions below are very terse; refer to the corresponding Unix manual (or POSIX documentation) entry for more information. Arguments called path refer to a pathname given as a string.
Errors are reported as exceptions; the usual exceptions are given for type errors, while errors reported by the system calls raise error (a synonym for the standard exception OSError), described below.
Module posix defines the following data items:
Modifying this dictionary does not affect the string environment passed on by execv(), popen() or system(); if you need to change the environment, pass environ to execve() or add variable assignments and export statements to the command string for system() or popen().
However: If you are using this module via the os module (as you should - see the introduction above), environ is a a mapping object that behaves almost like a dictionary but invokes putenv() automatically whenever an item is changed.
When exceptions are classes, this exception carries two attributes, errno and strerror. The first holds the value of the C errno variable, and the latter holds the corresponding error message from strerror(). For exceptions that involve a file system path (e.g. chdir or unlink), the exception instance will contain a third attribute filename which is the file name passed to the function.
When exceptions are strings, the string for the exception is 'OSError'.
It defines the following functions and constants:
Note: this function is intended for low-level I/O and must be applied to a file descriptor as returned by open() or pipe(). To close a ``file object'' returned by the built-in function open() or by popen() or fdopen(), use its close() method.
Note: the standard way to exit is sys.exit(n). _exit() should normally only be used in the child process after a fork().
FIFOs are pipes that can be accessed like regular files. FIFOs exist until they are deleted (for example with os.unlink()). Generally, FIFOs are used as rendezvous between ``client'' and ``server'' type processes: the server opens the FIFO for reading, and the client opens it for writing. Note that mkfifo() doesn't open the FIFO -- it just creates the rendezvous point.
For a description of the flag and mode values, see the Unix or C run-time documentation; flag constants (like O_RDONLY and O_WRONLY) are defined in this module too (see below).
Note: this function is intended for low-level I/O. For normal usage, use the built-in function open(), which returns a ``file object'' with read() and write() methods (and many more).
When putenv() is supported, assignments to items in os.environ are automatically translated into corresponding calls to putenv(); however, calls to putenv() don't update os.environ, so it is actually preferable to assign to items of os.environ.
Note: this function is intended for low-level I/O and must be applied to a file descriptor as returned by open() or pipe(). To read a ``file object'' returned by the built-in function open() or by popen() or fdopen(), or sys.stdin, use its read() or readline() methods.
Note: The standard module stat defines functions and constants that are useful for extracting information from a stat structure.
Note: this function is intended for low-level I/O and must be applied to a file descriptor as returned by open() or pipe(). To write a ``file object'' returned by the built-in function open() or by popen() or fdopen(), or sys.stdout or sys.stderr, use its write() method.
Field Summary | |
static org.python.core.PyObject |
error
|
Constructor Summary | |
posix()
|
Method Summary | |
static void |
_exit(int status)
_exit(status). |
static int |
access(java.lang.String path,
int mode)
access(path, mode) -> 1 if granted, 0 otherwise. |
static void |
chdir(java.lang.String dir)
chdir(path) -> None. |
static void |
chmod(java.lang.String dir,
int mode)
chmod(path, mode) -> None. |
static void |
chown(java.lang.String dir,
int uid,
int gid)
chown(path, uid, gid) -> None. |
static void |
close(int fd)
close(fd) -> None. |
static int |
dup(int fd)
dup(fd) -> fd2- Return a duplicate of a file descriptor. |
static void |
dup2(int fd,
int fd2)
dup2(fd, fd2) -> None. |
static void |
execv(java.lang.String path,
java.lang.String[] args)
execv(path, args). |
static void |
execve(java.lang.String path,
java.lang.String[] args,
org.python.core.PyObject env)
execve(path, args, env). |
static void |
fdatasync(int fd)
fdatasync(fildes) -> None. force write of file with filedescriptor to disk. does not force update of metadata. |
static PosixFile |
fdopen(int fd)
fdopen(fd, [, mode='r' [, bufsize]]) -> file_object. |
static PosixFile |
fdopen(int fd,
java.lang.String mode)
fdopen(fd, [, mode='r' [, bufsize]]) -> file_object. |
static PosixFile |
fdopen(int fd,
java.lang.String mode,
int bufsize)
fdopen(fd, [, mode='r' [, bufsize]]) -> file_object. |
static int |
fork()
fork() -> pid. |
static org.python.core.PyTuple |
fstat(int fd)
fstat(fd) -> (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime). |
static org.python.core.PyTuple |
fstatvfs(int fd)
fstatvfs(fd) -> (bsize, frsize, blocks, bfree, bavail, files, ffree, favail, flag, namemax). |
static org.python.core.PyTuple |
fstatvfs(java.lang.String path)
statvfs(path) -> (bsize, frsize, blocks, bfree, bavail, files, ffree, favail, flag, namemax). |
static void |
fsync(int fd)
fsync(fildes) -> None. force write of file with filedescriptor to disk. |
static void |
ftruncate(int fd,
int len)
ftruncate(fd, length) -> None. |
static java.lang.String |
getcwd()
getcwd() -> path. |
static int |
getegid()
getegid() -> egid. |
static int |
geteuid()
geteuid() -> euid. |
static int |
getgid()
getgid() -> gid. |
static java.lang.String |
getName()
|
static int |
getpgrp()
getpgrp() -> pgrp. |
static int |
getpid()
getpid() -> pid. |
static int |
getppid()
getppid() -> ppid. |
static int |
getuid()
getuid() -> uid. |
void |
initModule(org.python.core.PyObject dict)
|
static void |
kill(int pid,
int sig)
kill(pid, sig) -> None. |
static void |
link(java.lang.String src,
java.lang.String dst)
link(src, dst) -> None. |
static org.python.core.PyList |
listdir(java.lang.String path)
listdir(path) -> list_of_strings. |
static long |
lseek(int fd,
long pos,
int how)
lseek(fd, pos, how) -> newpos. |
static org.python.core.PyTuple |
lstat(java.lang.String file)
lstat(path) -> (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime). |
static void |
main(java.lang.String[] args)
|
static void |
mkdir(java.lang.String path)
mkdir(path [, mode=0777]) -> None. |
static void |
mkdir(java.lang.String dir,
int mode)
mkdir(path, mode=0777) -> None. |
static void |
mkfifo(java.lang.String file,
int mode)
mkfifo(file, [, mode=0666]) -> None. |
static int |
nice(int incr)
nice(inc) -> new_priority. |
static int |
open(java.lang.String file,
int flag)
open(filename, flag) -> fd. |
static int |
open(java.lang.String file,
int flag,
int mode)
open(filename, flag mode=0777) -> fd. |
static org.python.core.PyTuple |
pipe()
pipe() -> (read_end, write_end). |
static void |
plock(int op)
plock(op) -> None. |
static PosixFile |
popen(java.lang.String name)
popen(command [, mode='r' [, bufsize]]) -> pipe. |
static PosixFile |
popen(java.lang.String name,
java.lang.String mode)
popen(command [, mode='r' [, bufsize]]) -> pipe. |
static PosixFile |
popen(java.lang.String name,
java.lang.String mode,
int bufsize)
popen(command [, mode='r' [, bufsize]]) -> pipe. |
static void |
putenv(java.lang.String key,
java.lang.String value)
putenv(key, value) -> None. |
static java.lang.String |
read(int fd,
int size)
read(fd, buffersize) -> string. |
static java.lang.String |
readlink(java.lang.String file)
readlink(path) -> path. |
static void |
remove(java.lang.String file)
remove(path) -> None. |
static void |
rename(java.lang.String src,
java.lang.String dst)
rename(old, new) -> None. |
static void |
rmdir(java.lang.String dir)
rmdir(path) -> None. |
static void |
setgid(int gid)
setgid(gid) -> None. |
static void |
setpgid()
setpgid(pid, pgrp) -> None. |
static void |
setpgrp()
setpgrp() -> None. |
static void |
setsid()
setsid() -> None. |
static void |
setuid(int uid)
setuid(uid) -> None. |
static int |
spawnv(int mode,
java.lang.String path,
java.lang.String[] args)
spawnv(mode, path, args). |
static int |
spawnve(int mode,
java.lang.String path,
java.lang.String[] args,
org.python.core.PyObject env)
spawnve(mode, path, args, env). |
static org.python.core.PyTuple |
stat(java.lang.String file)
stat(path) -> (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime). |
static java.lang.String |
strerror(int code)
strerror(code) -> string. |
static void |
symlink(java.lang.String src,
java.lang.String dst)
symlink(src, dst) -> None. |
static int |
system(java.lang.String cmd)
system(command) -> exit_status. |
static int |
tcgetpgrp(int fd)
tcgetpgrp(fd) -> pgid. |
static void |
tcsetpgrp(int fd,
int pgid)
tcsetpgrp(fd, pgid) -> None. |
static org.python.core.PyTuple |
times()
times() -> (utime, stime, cutime, cstime, elapsed_time). |
static java.lang.String |
ttyname(int fd)
ttyname(fd) -> String. |
static int |
umask(int mask)
umask(new_mask) -> old_mask. |
static org.python.core.PyTuple |
uname()
uname() -> (sysname, nodename, release, version, machine). |
static void |
unlink(java.lang.String file)
unlink(path) -> None. |
static void |
utime(java.lang.String file,
int[] times)
utime(path, (atime, utime)) -> None. |
static org.python.core.PyTuple |
wait(int pid,
int options)
wait() -> (pid, status). |
static org.python.core.PyTuple |
waitpid(int pid,
int options)
waitpid(pid, options) -> (pid, status). |
static int |
WEXITSTATUS(int status)
WEXITSTATUS(status) -> integer. |
static int |
WIFEXITED(int status)
WIFEXITED(status) -> Boolean. |
static int |
WIFSIGNALED(int status)
WIFSIGNALED(status) -> Boolean. |
static int |
WIFSTOPPED(int status)
WIFSTOPPED(status) -> Boolean Return true if the process returning 'status' was stopped. |
static int |
write(int fd,
byte[] buf)
write(fd, string) -> byteswritten. |
static int |
WSTOPSIG(int status)
WSTOPSIG(status) -> integer. |
static int |
WTERMSIG(int status)
WTERMSIG(status) -> integer. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static org.python.core.PyObject error
Constructor Detail |
public posix()
Method Detail |
public void initModule(org.python.core.PyObject dict)
initModule
in interface org.python.core.InitModule
public static final void chdir(java.lang.String dir)
public static final void chmod(java.lang.String dir, int mode)
public static final void fsync(int fd)
public static final void fdatasync(int fd)
public static final void chown(java.lang.String dir, int uid, int gid)
public static final java.lang.String getcwd()
public static final void link(java.lang.String src, java.lang.String dst)
public static final org.python.core.PyList listdir(java.lang.String path)
path: path of directory to list.
The list is in arbitrary order. It does not include the special entries '.' and '..' even if they are present in the directory.
public static final org.python.core.PyTuple lstat(java.lang.String file)
public static final void mkdir(java.lang.String path)
public static final void mkdir(java.lang.String dir, int mode)
public static final int nice(int incr)
public static final java.lang.String readlink(java.lang.String file)
public static final void rename(java.lang.String src, java.lang.String dst)
public static final void rmdir(java.lang.String dir)
public static final org.python.core.PyTuple stat(java.lang.String file)
public static final void symlink(java.lang.String src, java.lang.String dst)
public static final int access(java.lang.String path, int mode)
public static final java.lang.String ttyname(int fd)
public static final int system(java.lang.String cmd)
public static final int umask(int mask)
public static final org.python.core.PyTuple uname()
public static final void unlink(java.lang.String file)
public static final void remove(java.lang.String file)
public static final void utime(java.lang.String file, int[] times)
public static final org.python.core.PyTuple times()
public static final void _exit(int status)
public static final void execv(java.lang.String path, java.lang.String[] args)
path: path of executable file
args: tuple or list of strings
public static final void execve(java.lang.String path, java.lang.String[] args, org.python.core.PyObject env)
path: path of executable file
args: tuple or list of arguments
env: dictonary of strings mapping to strings
public static final int spawnv(int mode, java.lang.String path, java.lang.String[] args)
mode: mode of process creation
path: path of executable file
args: tuple or list of strings
public static final int spawnve(int mode, java.lang.String path, java.lang.String[] args, org.python.core.PyObject env)
mode: mode of process creation
path: path of executable file
args: tuple or list of arguments
env: dictonary of strings mapping to strings
public static final int fork()
Return 0 to child process and PID of child to parent process.
public static final int getegid()
public static final int geteuid()
public static final int getgid()
public static final int getpid()
public static final int getpgrp()
public static final int getppid()
public static final int getuid()
public static final void kill(int pid, int sig)
public static final void plock(int op)
public static final PosixFile popen(java.lang.String name)
public static final PosixFile popen(java.lang.String name, java.lang.String mode)
public static final PosixFile popen(java.lang.String name, java.lang.String mode, int bufsize)
public static final void setuid(int uid)
public static final void setgid(int gid)
public static final void setpgrp()
public static final org.python.core.PyTuple wait(int pid, int options)
public static final org.python.core.PyTuple waitpid(int pid, int options)
public static final void setsid()
public static final void setpgid()
public static final int tcgetpgrp(int fd)
public static final void tcsetpgrp(int fd, int pgid)
public static final int open(java.lang.String file, int flag, int mode)
public static final int open(java.lang.String file, int flag)
public static final void close(int fd)
public static final int dup(int fd)
public static final void dup2(int fd, int fd2)
public static final long lseek(int fd, long pos, int how)
public static final java.lang.String read(int fd, int size)
public static final int write(int fd, byte[] buf)
public static final org.python.core.PyTuple fstat(int fd)
public static final PosixFile fdopen(int fd)
public static final PosixFile fdopen(int fd, java.lang.String mode)
public static final PosixFile fdopen(int fd, java.lang.String mode, int bufsize)
public static final org.python.core.PyTuple pipe()
public static final void mkfifo(java.lang.String file, int mode)
public static final void ftruncate(int fd, int len)
public static final void putenv(java.lang.String key, java.lang.String value)
public static final java.lang.String strerror(int code)
public static final int WIFSTOPPED(int status)
public static final int WIFSIGNALED(int status)
public static final int WIFEXITED(int status)
public static final int WEXITSTATUS(int status)
public static final int WTERMSIG(int status)
public static final int WSTOPSIG(int status)
public static final org.python.core.PyTuple fstatvfs(int fd)
public static final org.python.core.PyTuple fstatvfs(java.lang.String path)
public static void main(java.lang.String[] args)
public static final java.lang.String getName()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |