semvec/pypi-packages huggingface dataset:
tshelve 1.0.0
A faster kind of Python shelf
License: MIT
Requires Python: >=3.5
Keywords: shelve,threads,threading,fileio,persistence

tshelve
========

Description
------------

A near dupicate of the `shelve <https://docs.python.org/3/library/shelve.html#module-shelve>`_ module,
but with `threading <https://docs.python.org/3/library/threading.html>`_ used under the
hood to speed up execution time.

Purpose
--------

Regular `shelve <https://docs.python.org/3/library/shelve.html#module-shelve>`_ operations can be
notoriously slow. The ``tshelve`` module 
aims to provide a more efficient program,
that is still similar to the built-in. 

Installation
-------------

Installing ``tshelve`` should be done with `PIP <https://pypi.org/project/pip/>`_:

.. code-block:: sh

    $ pip install tshelve

Benefits
-------------

* A more meaningful `repr <https://docs.python.org/3/library/functions.html#repr>`_:
    
    The default ``repr``:

    .. code-block:: python
        
        repr(shelve.Shelf({}) == '<shelve.Shelf object at 0x00572CB8>'
    
    ``tshelve``'s ``repr``:

    .. code-block:: python
    
        repr(tshelve.TShelf({})) == TShelf(dict={}, protocol=5, writeback=False, keyencoding='utf-8')

* Similar to the shelve module in the standard library.

The amount of speed up that ``tshelve``
brings will depend on the code. However,
there will usually be a speed-up, especially
in code that interacts heavily with the module.

The following block of code was run with
`shelve.open <https://docs.python.org/3/library/shelve.html#shelve.open>`_ and ``tshelve.open``.
Both ``tshelve`` and `shelve <https://docs.python.org/3/library/shelve.html#module-shelve>`_ were tested in
the same environment to ensure realistic results.

.. code-block:: python
    
    import shelve
    import tshelve

    sync_open = shelve.open('shell', writeback=True)
    thread_open = tshelve.open('shell', writeback=True)
    
    def speedup(opened):
        opened['testvalue'] = False
        opened['tester'] = 5324
        opened['tester']
        opened.get('testvalue')
        opened['testit'] = 'Hello'
        opened.items()
        opened.keys()
        opened.values()
        del opened['testit']
        'testvalue' in opened
        for _ in opened:
            pass
        opened.popitem()
        opened.sync()
        opened.close()
    
    speedup(sync_open)
    speedup(thread_open)

The difference in execution time between
the two is drastic. ``tshelve`` operations
were, on average, nearly 44% faster than those
found in the  `shelve <https://docs.python.org/3/library/shelve.html#module-shelve>`_ module.

Example
--------------

.. code-block:: python

    import tshelve

    with tshelve.open('shell') as f:
        f['fruit'] = ['apple', 'banana']
        f['language'] = 'Python'
        del f['fruit']
        print(f['language'])

License
---------

This module is currently licensed under the `MIT <https://en.wikipedia.org/wiki/MIT_License>`_ license.
RPi.PIR 0.5.0
PIR sensor state monitor
License: MIT

RPi.PIR
#######

PIR sensor state monitor, completely written in Python.

RPi.PIR is using PIR sensor with Raspberry Pi GPIO.

To connect to Raspberry Pi plug PIR into `GPIO PIN 23 <https://pinout.xyz/pinout/pin16_gpio23#>`_ (Physical pin 16)
and POWER PIN. Install and execute raspi-pir and it should work. Alternatively you can user different PIN and execute
raspi-pir with parameter: ``raspi-pir --pin pin_number``.

.. image:: doc/RPi.PIR.png

RPi.PIR supports number of parameters and also configuration file. For more details see ``raspi-pir --help`` or sample
config.

Sensor is based on `RPi.Sensor <https://github.com/ricco386/RPi.Sensor/>`__ library, which make base for implementing
different types of sensors in Python.

Pre-Installation requirements
-----------------------------

- Update system and install required dependencies::

    sudo apt-get update

- Update system and install required dependencies::

    sudo apt-get install build-essential python3-dev python3-pip


Installation
------------

- Install the latest released version using pip::

    pip install https://github.com/ricco386/RPi.PIR/zipball/master

- Alternatively install latest released version from pypi::

    pip install --upgrade RPi.PIR


Integration as a systemd service
--------------------------------

- Make sure all dependencies (listed below) are installed (done automatically when installing via pip)
- The ``raspi-pir`` command should be installed somewhere in your ``PATH`` (done automatically when installing via pip), make sure `raspi-pir.service` has corect path in `ExecStart` set to `raspi-pir` executable.
- Systemd scripts are available: https://github.com/ricco386/RPi.PIR/tree/master/init.d to install them you will need root privileges, so we execute them as sudo::

    sudo cp init.d/raspi-pir.conf /etc/tmpfiles.d/
    sudo cp init.d/raspi-pir.service /etc/systemd/system/
    sudo systemd-tmpfiles --create /etc/tmpfiles.d/raspi-pir.conf
    sudo systemctl enable raspi-pir.service  # Enable service to start at system boot
    sudo systemctl start raspi-pir.service  # Start

Systemd scripts should be run under **default Raspberry Pi user** (pi), scripts have to be able access GPIO.

**Dependencies:**

- `RPi.Sensor <https://pypi.python.org/pypi/RPi.Sensor>`_ (0.5.3+)


Usage
-----

You have to create a `.sensor.cfg` file and place into `/home/pi/.sensor.cfg` you can find example file in RPi.Sensor repo: https://github.com/ricco386/RPi.Sensor/blob/master/raspi_sensor/sensor.cfg.example and create section `[PIR]` where you can override default values.

`raspi-pir` also support parameters to overwrite config parameters. For more info run::

    raspi-pir --help


Zabbix support
--------------

In directory `zabbix_template` there is a Zabbix template that can be imported to Zabbix and monitor systemd process if it is running and how much memory it consumes. It also supports Zabbix trapper `rpi.pir-state` that can receive a sensor state changes.


License
-------

For more information see the `LICENSE <https://github.com/ricco386/RPi.PIR/blob/master/LICENSE>`_ file.