Skip to content

Social-projects-Rivne/Rv-041WebUI-python

Repository files navigation

RV-041WebUI/Python

Project requires Python 2.7

Install instructions on ubuntu:

  1. Install essential for pip

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

  1. Install virtualenv

sudo pip install --upgrade virtualenv

  1. Create virtualenv

virtualenv ~/venv/<Your venv name>

  1. Install posgresql

sudo apt-get install postgresql postgresql-contrib

  1. Configure posgres db
sudo -u postgres psql
>>>CREATE USER admin WITH ENCRYPTED PASSWORD "12345678";
>>>CREATE DATABASE easyrest OWNER admin;

Or in /etc/postgresql/9.x/main/pg_hba.conf add lines to the bottom of the file:

local   <dbname>    <usrname>                                    peer
host    <dbname>   <usrname>            127.0.0.1        md5 (edited)

and then restart postqresql service

sudo service postgresql restart

  1. Install pip packeges inside virtual env

(venv) pip install -e ".[testing]"

  1. Initialize db(with example data):

(venv) initialize_easyrest_db --fill development.ini

Drop and create empty database

(venv) initialize_easyrest_db --reset development.ini

Drop derivative models from Base

(venv) initialize_easyrest_db --drop development.ini

Reset and fill database

(venv) initialize_easyrest_db --reset --fill development.ini

--drop - Drop derivative models from Base
--fill - Create tables with test data (without create empty tables)
--reset - Drop and create empty database
  1. Run tests

(venv) pytest

  1. Run project

(venv) pserve --reload development.ini

For convinience you can add aliases below (to your .bash_aliases):

alias envoff=`deactivate`
alias envon=`source ~/venv/<Your venv name>/bin/activate`

Alias to run pyramid and node serve in single comand

To run this you also need to specify your venv path in scripts/pyramidrun.sh and node version to use in scripts/noderun.sh (if you don't use nvm delete this line)

alias reston='gnome-terminal --tab -e "$(pwd)/scripts/pyramidrun.sh" --tab -e "$(pwd)/scripts/noderun.sh"'

Deploying via Docker

  1. Install Docker and Docker Compose

Install Docker

Install Docker Compose

  1. Change the database connection in the development.ini to this form.
# sqlalchemy.url = postgresql://localhost/easyrest?user=admin&password=123

# Connection for Docker environment
sqlalchemy.url = postgresql://admin:12345678@db/easyrest
  1. Change the server url in the development.ini to this form.
# listen = localhost:6543

# Url for Docker environment
listen = 0.0.0.0:6543
  1. Run ./smanager up

Services links:

Frontend Backend Adminer


Install instructions on windows:

  1. Make sure that you have python version 2.7

python --version

After installation Python append paths to python.exe (i.e. C:\Python27) and path to directory Scripts (i.e. C:\Python27\Scripts) in the PATH environment variable.

  1. If you are using Python 2 >=2.7.9 downloaded from python.org just make sure to upgrade pip:

python -m pip install -U pip

  1. Install virtualenv

pip install virtualenv

  1. Create virtualenv

virtualenv %VENV%

  1. Activate virtualenv

%VENV%\Scripts\activate

  1. Upgrade packaging tools in the virtual environment

(%VENV%) pip install --upgrade pip setuptools

  1. Install pip packeges inside virtual env

(%VENV%) pip install -e ".[testing]"

  1. Install posgresql and create database

  2. Initialize db

(%VENV%) initialize_easyrest_db --fill development.ini

Drop and create empty database

(%VENV%) initialize_easyrest_db --reset development.ini

Drop derivative models from Base

(%VENV%) initialize_easyrest_db --drop development.ini

Reset and fill database

(%VENV%) initialize_easyrest_db --reset --fill development.ini

--drop - Drop derivative models from Base
--fill - Create tables with test data (without create empty tables)
--reset - Drop and create empty database
  1. Run tests

(%VENV%) pytest

  1. Run project

pserve development.ini

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 7