pynix: Linux System APIs in Python

https://travis-ci.com/cheshirekow/pynix.svg?branch=master https://readthedocs.org/projects/pynix/badge/?version=latest https://img.shields.io/badge/chat-on%20disord-green.svg?logo=discord

The pynix python package provides access to a number of linux system APIs that are not part of the python standard library.

Installation

Install with pip

The easiest way to install pynix is from pypi.org using pip. The project name on pypi.org is libpynix, so the canonical insallation command would be:

pip install libpynix

However, depending on your distribution, you may need:

sudo pip install libpynix

if you wish to in a system global location (e.g. /usr/local/lib/python3.6/dist-packages), or:

pip install --user libpynix

if you wish to install in a user global location (e.g. ~/.local/lib/python3.6/site-packages) which I would probably recommend for most users.

Install from source

You can also install from source with pip. You can download a release package from github or pypi and then install it directly with pip. For example:

pip install libpynix-<version>.tar.gz

Note that the release packages on github are automatically generated from git tags which are the same commit used to generate the corresponding version package on pypi.org. So whether you install a particular version from github or pypi shouldn’t matter. They should be the exact same file.

Pip can also install directly from github. For example:

pip install git+https://github.com/cheshirekow/pynix.git

If you wish to test a pre-release or dev package from a branch called foobar you can install it with:

pip install "git+https://github.com/cheshirekow/pynix.git@foobar"

Implemented APIs

Linux APIs that are implemented in pynix are:

Release Notes

v0.1 series

v0.1.0

Initial release of the pynix package. Provides support for the following linux APIs:

  • epoll
  • gettid
  • inotify
  • mount
  • prctl
  • [gs]etres[ug]id
  • signalfd
  • sigprocmask
  • sigset
  • unshare

Changelog

v0.1 series

v0.1.0

dev0:
  • Initial release

pynix package

Module contents

class pynix.EpollEvent

Bases: object

Wraps struct epoll_event see https://www.man7.org/linux/man-pages/man7/epoll.7.html

data

user data stored with event entry

events

bitmask of available events

class pynix.EpollEventBuf

Bases: object

pynix.EpollEvent(int capacity) Stores an array of struct epoll_event

capacity

number of epollevents slots that can be filled

size

number of epoll events filled

class pynix.EpollEventBufIter

Bases: object

pynix.EpollEventIter(pynix.EpollEventBuf buffer) Iterator over events in an eventbuf`

class pynix.SigInfo

Bases: object

Wraps struct signalfd_siginfo

ssi_addr

Address that generated signal (for hardware-generated signals)

ssi_band

Band event (SIGIO)

ssi_code

Signal code

ssi_errno

Error number (unused)

ssi_fd

File descriptor (SIGIO)

ssi_int

Integer sent by sigqueue(3)

ssi_overrun

POSIX timer overrun count

ssi_pid

PID of sender

ssi_ptr

Pointer sent by sigqueue(3)

ssi_signo

Signal number

ssi_status

Exit status or signal (SIGCHLD)

ssi_stime

System CPU time consumed (SIGCHLD)

ssi_tid

Kernel timer ID (POSIX timers)

ssi_trapno

Trap number that caused signal

ssi_uid

Real UID of sender

ssi_utime

User CPU time consumed (SIGCHLD

class pynix.SigSet

Bases: object

Wraps sigset_t see: http://man7.org/linux/man-pages/man3/sigsetops.3.html

add()
delete()
empty()
fill()
ismember()
pynix.chroot()
pynix.epoll_create()
pynix.epoll_ctl()
pynix.epoll_pwait()
pynix.epoll_wait()
exception pynix.error

Bases: Exception

pynix.getresgid()
pynix.getresuid()
pynix.gettid()
pynix.inotify_add_watch()
pynix.inotify_init()
pynix.inotify_read()
pynix.inotify_rm_watch()
pynix.mount()
pynix.prctl()
pynix.setresgid()
pynix.setresuid()
pynix.signalfd()
pynix.signalfd_read()
pynix.sigprocmask()
pynix.unshare()

Indices and tables