Package org.python.modules.posix
Class PosixModule
- java.lang.Object
-
- org.python.modules.posix.PosixModule
-
- All Implemented Interfaces:
ClassDictInit
public class PosixModule extends java.lang.Object implements ClassDictInit
The posix/nt module, depending on the platform.
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description PosixModule()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
_exit()
static void
_exit(int status)
static PyObject
_get_shell_commands()
Helper function for the subprocess module, returns the potential shell commands for this OS.static boolean
access(PyObject path, int mode)
static void
chdir(PyObject path)
static void
chmod(PyObject path, int mode)
static void
chown(PyObject path, int uid, int gid)
static void
classDictInit(PyObject dict)
static void
close(PyObject fd)
static void
closerange(PyObject fd_lowObj, PyObject fd_highObj)
static void
fdatasync(PyObject fd)
static PyObject
fdopen(PyObject fd)
static PyObject
fdopen(PyObject fd, java.lang.String mode)
static PyObject
fdopen(PyObject fd, java.lang.String mode, int bufsize)
static void
fsync(PyObject fd)
static void
ftruncate(PyObject fd, long length)
static PyObject
getcwd()
static PyObject
getcwdu()
static int
getegid()
static int
geteuid()
static int
getgid()
static PyObject
getlogin()
static java.lang.String
getOSName()
static int
getpgrp()
static int
getpid()
static jnr.posix.POSIX
getPOSIX()
static int
getppid()
static int
getuid()
static boolean
isatty(PyObject fdObj)
static void
kill(int pid, int sig)
static void
lchmod(PyObject path, int mode)
static void
lchown(PyObject path, int uid, int gid)
static void
link(PyObject src, PyObject dst)
static PyList
listdir(PyObject path)
static long
lseek(PyObject fd, long pos, int how)
static void
mkdir(PyObject path)
static void
mkdir(PyObject path, int mode)
static FileIO
open(PyObject path, int flag)
static FileIO
open(PyObject path, int flag, int mode)
static PyTuple
pipe()
static PyObject
popen(PyObject[] args, java.lang.String[] kwds)
static void
putenv(java.lang.String key, java.lang.String value)
static PyObject
read(PyObject fd, int buffersize)
static PyString
readlink(PyObject path)
static void
remove(PyObject path)
static void
rename(PyObject oldpath, PyObject newpath)
static void
rmdir(PyObject path)
static void
setpgrp()
static void
setsid()
static PyObject
strerror(int code)
static void
symlink(PyObject src, PyObject dst)
static PyTuple
times()
static int
umask(int mask)
static PyTuple
uname()
Resembles CPython's uname with the addition that we also attempt a Windows-equivalent variant on win-systems.static void
unlink(PyObject path)
static void
unsetenv(java.lang.String key)
static PyObject
urandom(int n)
static void
utime(PyObject path, PyObject times)
static PyObject
wait$()
static PyObject
waitpid(int pid, int options)
static int
write(PyObject fd, BufferProtocol bytes)
-
-
-
Field Detail
-
__doc__
public static final PyString __doc__
-
__doc___exit
public static PyString __doc___exit
-
__doc__access
public static PyString __doc__access
-
__doc__chdir
public static PyString __doc__chdir
-
__doc__chmod
public static PyString __doc__chmod
-
__doc__chown
public static PyString __doc__chown
-
__doc__close
public static PyString __doc__close
-
__doc__fdopen
public static PyString __doc__fdopen
-
__doc__fdatasync
public static PyString __doc__fdatasync
-
__doc__fsync
public static PyString __doc__fsync
-
__doc__ftruncate
public static PyString __doc__ftruncate
-
__doc__getcwd
public static PyString __doc__getcwd
-
__doc__getcwdu
public static PyString __doc__getcwdu
-
__doc__getegid
public static PyString __doc__getegid
-
__doc__geteuid
public static PyString __doc__geteuid
-
__doc__getgid
public static PyString __doc__getgid
-
__doc__getlogin
public static PyString __doc__getlogin
-
__doc__getppid
public static PyString __doc__getppid
-
__doc__getuid
public static PyString __doc__getuid
-
__doc__getpid
public static PyString __doc__getpid
-
__doc__getpgrp
public static PyString __doc__getpgrp
-
__doc__isatty
public static PyString __doc__isatty
-
__doc__kill
public static PyString __doc__kill
-
__doc__lchmod
public static PyString __doc__lchmod
-
__doc__lchown
public static PyString __doc__lchown
-
__doc__link
public static PyString __doc__link
-
__doc__listdir
public static PyString __doc__listdir
-
__doc__lseek
public static PyString __doc__lseek
-
__doc__mkdir
public static PyString __doc__mkdir
-
__doc__open
public static PyString __doc__open
-
__doc__pipe
public static PyString __doc__pipe
-
__doc__popen
public static PyString __doc__popen
-
__doc__putenv
public static PyString __doc__putenv
-
__doc__read
public static PyString __doc__read
-
__doc__readlink
public static PyString __doc__readlink
-
__doc__remove
public static PyString __doc__remove
-
__doc__rename
public static PyString __doc__rename
-
__doc__rmdir
public static PyString __doc__rmdir
-
__doc__setpgrp
public static PyString __doc__setpgrp
-
__doc__setsid
public static PyString __doc__setsid
-
__doc__strerror
public static PyString __doc__strerror
-
__doc__symlink
public static PyString __doc__symlink
-
__doc__times
public static PyString __doc__times
-
__doc__umask
public static PyString __doc__umask
-
__doc__uname
public static PyString __doc__uname
-
__doc__unlink
public static PyString __doc__unlink
-
__doc__utime
public static PyString __doc__utime
-
__doc__wait
public static PyString __doc__wait
-
__doc__waitpid
public static PyString __doc__waitpid
-
__doc__write
public static PyString __doc__write
-
__doc__unsetenv
public static PyString __doc__unsetenv
-
__doc__urandom
public static PyString __doc__urandom
-
-
Method Detail
-
classDictInit
public static void classDictInit(PyObject dict)
-
_exit
public static void _exit()
-
_exit
public static void _exit(int status)
-
access
public static boolean access(PyObject path, int mode)
-
chdir
public static void chdir(PyObject path)
-
chmod
public static void chmod(PyObject path, int mode)
-
chown
public static void chown(PyObject path, int uid, int gid)
-
close
public static void close(PyObject fd)
-
fdatasync
public static void fdatasync(PyObject fd)
-
fsync
public static void fsync(PyObject fd)
-
ftruncate
public static void ftruncate(PyObject fd, long length)
-
getcwd
public static PyObject getcwd()
-
getcwdu
public static PyObject getcwdu()
-
getegid
public static int getegid()
-
geteuid
public static int geteuid()
-
getgid
public static int getgid()
-
getlogin
public static PyObject getlogin()
-
getppid
public static int getppid()
-
getuid
public static int getuid()
-
getpid
public static int getpid()
-
getpgrp
public static int getpgrp()
-
isatty
public static boolean isatty(PyObject fdObj)
-
kill
public static void kill(int pid, int sig)
-
lchmod
public static void lchmod(PyObject path, int mode)
-
lchown
public static void lchown(PyObject path, int uid, int gid)
-
lseek
public static long lseek(PyObject fd, long pos, int how)
-
mkdir
public static void mkdir(PyObject path)
-
mkdir
public static void mkdir(PyObject path, int mode)
-
pipe
public static PyTuple pipe()
-
putenv
public static void putenv(java.lang.String key, java.lang.String value)
-
remove
public static void remove(PyObject path)
-
rmdir
public static void rmdir(PyObject path)
-
setpgrp
public static void setpgrp()
-
setsid
public static void setsid()
-
strerror
public static PyObject strerror(int code)
-
times
public static PyTuple times()
-
umask
public static int umask(int mask)
-
uname
public static PyTuple uname()
Resembles CPython's uname with the addition that we also attempt a Windows-equivalent variant on win-systems. Implementation overview:
Original/CPython (POSIX only):
(uname -s, uname -n, uname -r, uname -v, uname -m)
This version (non-Windows):
(property os.name, InetAddress.getLocalHost().getHostName(), property os.version, uname -v, uname -m)
Adjustments on OSX:
Normalize "Mac OS X" to "Darwin",
uname -r instead of property os.version
Fallbacks:
nodename/uname -n: exec uname -n
version/uname -v: ""
machine/uname -m: property os.arch
This version (Windows):
(reproduces platform.uname behavior on Windows)
("Windows", InetAddress.getLocalHost().getHostName(), property os.name: part after "Windows", cmd.exe /C ver: part after "Version", env PROCESSOR_ARCHITECTURE)
Fallback for nodename/uname -n on Windows:
- env USERDOMAIN
- exec hostname
For machine-entry on Windows this is a simplified description. It is actually mapped to typical uname -m values as follows (pseudo-code):
PROCESSOR_ARCHITECTURE = x86 and PROCESSOR_ARCHITEW6432 undefined: "x86"
else if PROCESSOR_ARCHITECTURE = x86: PROCESSOR_ARCHITEW6432 else: PROCESSOR_ARCHITECTURE
Potential flaws:
- could be a 32-bit machine, but actually not i686
- user might need to discriminate AMD64 from EM64T
In the rare case that your application is sensitive to one of these flaws you shouldn't be using our uname-hack for Windows, but directly look at PROCESSOR_ARCHITECTURE and friends.- Returns:
- PyTuple containing sysname, nodename, release, version, machine
-
unlink
public static void unlink(PyObject path)
-
wait$
public static PyObject wait$()
-
waitpid
public static PyObject waitpid(int pid, int options)
-
write
public static int write(PyObject fd, BufferProtocol bytes)
-
unsetenv
public static void unsetenv(java.lang.String key)
-
urandom
public static PyObject urandom(int n)
-
_get_shell_commands
public static PyObject _get_shell_commands()
Helper function for the subprocess module, returns the potential shell commands for this OS.- Returns:
- a tuple of lists of command line arguments. E.g. (['/bin/sh', '-c'])
-
getPOSIX
public static jnr.posix.POSIX getPOSIX()
-
getOSName
public static java.lang.String getOSName()
-
-