Skip to content
Snippets Groups Projects
Commit fda518a8 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

refactor: unix -> posix

parent 38e5110c
No related branches found
No related tags found
No related merge requests found
......@@ -12,13 +12,8 @@ This WILL break compatibility.**
**satella 1.0 remains in maintenance mode**
Satella is a Python library for writing server applications, especially those dealing with
small network-oriented tasks. Over time it will constitute a reasonably large library with useful things.
_satella.posix_ in unavailable on non-POSIX systems.
Satella abstracts away communication links a "channels". Channels can be blocking, nonblocking, multiplexed - used as the user likes it. They are essentially streams with rich read functionality and fail awareness. Channels follow an unified API, which makes them simple to understand.
Satella is easy-to-use. It's main task is to reduce the cognitive load on the programmer. It requires minimum-to-none startup and faciliates it's objects, classes and procedures to be used without requiring the coder to read and understand multitude information about unnecessary far-away classes. Code written is simple and concise.
Satella runs both on PyPy and CPython 2.7
Satella is a Python library for writing server applications, especially those dealing with mundane but useful things.
See LICENSE for text of the license.
\ No newline at end of file
# Echoist
This is a simple demo service. It accepts TCP connections and echoes what they sent.
## What it does?
1. Binds port 7
2. Drops privileges via fork - switches to _daemon_ user and group
3. Runs until SIGTERM/SIGKILL is received
......@@ -9,6 +9,7 @@ Welcome to satella's documentation!
coding/debug
instrumentation/traceback
source/modules
examples/echoist
Indices and tables
......
......@@ -5,7 +5,7 @@ How to do common things.
## Check if running as root
```python
from satella.unix import is_running_as_root
from satella.posix import is_running_as_root
if is_running_as_root():
print('Root!')
else:
......@@ -19,7 +19,7 @@ Use a context manager, _AcquirePIDLock_ from module _satella.pid_. Example:
Example:
```python
from satella.unix import AcquirePIDLock
from satella.posix import AcquirePIDLock
with AcquirePIDLock('satella.pid'):
print('Lock is acquired!')
......
# coding=UTF-8
"""
Simple Echo service
"""
from __future__ import print_function, absolute_import, division
import six
import logging
logger = logging.getLogger(__name__)
# coding=UTF-8
"""
It sounds like a melody
"""
from __future__ import print_function, absolute_import, division
import six
import logging
import socket
logger = logging.getLogger(__name__)
from satella.posix import daemonize
if __name__ == '__main__':
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('0.0.0.0', 7))
daemonize(uid='daemon', gid='daemon')
# coding=UTF-8
from __future__ import print_function, absolute_import, division
import six
import logging
logger = logging.getLogger(__name__)
class Instrument(object):
"""Class used for generating metrics"""
def __init__(self, name):
self.name = name
self.ancestry = name.split('.')
def is_child_of(self, instrument):
raise NotImplementedError
\ No newline at end of file
# coding=UTF-8
"""
UNIX things
"""
from __future__ import print_function, absolute_import, division
import six
import logging
import os
import warnings
try:
from satella.posix.daemon import daemonize
from satella.posix.pidlock import AcquirePIDLock
def is_running_as_root():
"""
Is this process running as root?
Checks whether EUID is 0
:return: bool
"""
return os.geteuid() == 0
except ImportError:
warnings.warn(u'Not running on POSIX, some functionality is unavailable')
File moved
File moved
# coding=UTF-8
"""
UNIX things
"""
from __future__ import print_function, absolute_import, division
import six
import logging
import os
from satella.unix.daemon import daemonize
from satella.unix.pidlock import AcquirePIDLock
__all__ = ('daemonize', 'AcquirePIDLock', 'is_running_as_root')
def is_running_as_root():
"""
Is this process running as root?
Checks whether EUID is 0
:return: bool
"""
return os.geteuid() == 0
......@@ -9,6 +9,9 @@ setup(name='satella',
keywords=['ha', 'high availability', 'scalable', 'scalability', 'server'],
packages=[
'satella',
'satella.coding',
'satella.posix',
'satella.instrumentation'
],
install_requires=[
"six",
......@@ -26,6 +29,7 @@ setup(name='satella',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Operating System :: POSIX',
'Operating System :: OS Independent',
'Development Status :: 1 - Planning',
'License :: OSI Approved :: MIT License',
'Topic :: Software Development :: Libraries'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment