Installation
============

This page describes an installation of the package ``dm`` and how to integrate it into the project.


Getting the source code
-----------------------

``Contact project manager (project no. TH02010845: IotCloud - Intelligence for IoT systems) to obtain source code.``

Requirements
------------

Ubuntu packages
^^^^^^^^^^^^^^^
Use the command below to install the required Ubuntu packages.

.. code-block:: bash

   apt install python3-tk python3-venv


A Python virtual environment (optional)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It is suitable to create a Python virtual environment.

.. code-block:: bash

   python3 -m venv env

After successful creation, it is necessary to activate the environment.

.. code-block:: bash

   source env/bin/activate # for activate env


Python dependencies
^^^^^^^^^^^^^^^^^^^

**List of used packages**

.. literalinclude:: ../../requirements.txt
   :language: python

Install Python dependencies using the command below.
The installation should be done in the virtual environment.

.. code-block:: bash

   pip install -r requirements.txt


Documentation dependencies (optional)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code-block:: bash

   apt-get install latexmk texlive-latex-recommended \
                   texlive-latex-extra texlive-fonts-recommended

To generate the documentation, it is required to go to the ``docs`` folder.
The documentation can be generated either in HTML form or in PDF form.
If the documentation is generated in PDF form, it is open in the Opera browser after
a successful generation.

.. code-block:: bash

   cd docs
   make latex && \
   cd build/latex/ && \
   make && \
   opera modulesforhealthyenvironment.pdf && \
   cd - make html \
   && opera build/html/index.html


.. _installation.config_file:

Configuration file
------------------

The configuration file ``config.ini`` has to be placed in the ``/etc/dp/`` folder.
The example of a configuration file follows.

.. literalinclude:: ../../config.ini
   :language: ini


Other tools
-----------

The following command can be used for API key generation on the server.
It is only required to enter an arbitrary email in the right form.

.. code-block:: bash

   echo `pwgen 80 1` "= namea@example.org" >> /etc/beeeon/server/apikeys.properties
