Giter Site home page Giter Site logo

mikaponics / mikaponics-back Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 1.0 1.53 MB

Home Page: https://api.mikaponics.com

License: BSD 3-Clause "New" or "Revised" License

Shell 0.28% Python 72.97% CSS 1.36% JavaScript 8.49% HTML 12.11% Go 0.62% Dockerfile 0.07% PHP 4.10%
django python iot aquaponics hydroponics backend

mikaponics-back's Introduction

Mikaponics Backend

Documentation Status

Introduction

Online aquaponics / hydroponic device monitoring portal implemented in Python and powered by Django.

Instructions

Prerequisites

You must have the following applications installed before proceeding. If you are missing any one of these then you cannot begin.

  • Python 3.7
  • virtualenv
  • redis
  • Postgres 10

Installation

The following section explains how to setup the application.

  1. Clone a copy of the project somewhere on your machine, we'll be saving to the following locaiton.
mkdir ~/python/github.com/mikaponics;
cd ~/python/github.com/mikaponics;
git clone https://github.com/mikaponics/mikaponics-back.git;
cd mikaponics-back
  1. Setup our virtual environment
virtualenv -p python3.7 env
  1. Now lets activate virtual environment
source env/bin/activate
  1. Now lets install the libraries this project depends on.
pip install -r requirements.txt

Database Setup

This project uses the PostGres database and as a result requires setup before running. The following instructions are to be run in your PostGres console:

drop database mikaponics_db;
create database mikaponics_db;
\c mikaponics_db;
CREATE USER django WITH PASSWORD '123password';
GRANT ALL PRIVILEGES ON DATABASE mikaponics_db to django;
ALTER USER django CREATEDB;
ALTER ROLE django SUPERUSER;
CREATE EXTENSION postgis;

Environment Variables Setup

  1. Populate the environment variables for our project.
./setup_credentials.sh
  1. Go inside the environment variables.
vi ./mikaponics/mikaponics/.env
  1. Edit the file to suite your needs.

Finalization.

  1. Run the following. Please change the password to your own.
redis-cli FLUSHDB;
python manage.py makemigrations
python manage.py migrate
python manage.py init_mikaponics
python manage.py init_crop_data_sheets
python manage.py init_problem_data_sheets
python manage.py create_admin_user "[email protected]" "123password" "Bart" "Mika";
python manage.py setup_resource_server_authorization
python manage.py collectstatic
  1. Register the app with the following social-auth services. Also read this tutorial on setting these up.

    https://github.com/settings/applications/new
    https://apps.twitter.com/
    https://facebook.com/
    
  2. If you would like to have some random test data available for your app, feel free to run any of theses.

    # Smallest dataset
    python manage.py seed_database 1 1 1000
    
    # Small dataset
    python manage.py seed_database 5 10 2500
    
    # Medium dataset
    python manage.py seed_database 25 20 5000
    
    # Large dataset
    python manage.py seed_database 100 30 10000
    
    # Gigantic dataset
    python manage.py seed_database 10000 50 100000
    
    # Epic dataset
    python manage.py seed_database 100000 75 1000000
    
  3. If you would like to have some random test data to a specific user, feel free to run:

    python manage.py seed_user "[email protected]" 1 2500
    

mikaponics-back's People

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

bhagirath20

mikaponics-back's Issues

instrument.tasks.run_instruments_handling_func()

16:17:08 AttributeError: 'Device' object has no attribute 'last_measured_at'
Traceback (most recent call last):
  File "/Users/bmika/python/github.com/mikaponics/mikaponics-back/env/lib/python3.6/site-packages/rq/worker.py", line 812, in perform_job
    rv = job.perform()
  File "/Users/bmika/python/github.com/mikaponics/mikaponics-back/env/lib/python3.6/site-packages/rq/job.py", line 588, in perform
    self._result = self._execute()
  File "/Users/bmika/python/github.com/mikaponics/mikaponics-back/env/lib/python3.6/site-packages/rq/job.py", line 594, in _execute
    return self.func(*self.args, **self.kwargs)
  File "/Users/bmika/python/github.com/mikaponics/mikaponics-back/mikaponics/device/tasks.py", line 21, in run_devices_handling_func
    call_command('check_devices',device.id,verbosity=0)
  File "/Users/bmika/python/github.com/mikaponics/mikaponics-back/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 148, in call_command
    return command.execute(*args, **defaults)
  File "/Users/bmika/python/github.com/mikaponics/mikaponics-back/env/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 53, in inner
    return func(*args, **kwds)
  File "/Users/bmika/python/github.com/mikaponics/mikaponics-back/mikaponics/device/management/commands/check_devices.py", line 51, in handle
    self.process_device(device, utc_today_minus_some_minutes)
  File "/Users/bmika/python/github.com/mikaponics/mikaponics-back/mikaponics/device/management/commands/check_devices.py", line 62, in process_device
    self.process_offline_status(device, utc_today_minus_some_minutes)
  File "/Users/bmika/python/github.com/mikaponics/mikaponics-back/mikaponics/device/management/commands/check_devices.py", line 69, in process_offline_status
    last_measured_utc_timestamp = device.last_measured_at
AttributeError: 'Device' object has no attribute 'last_measured_at'
Traceback (most recent call last):
  File "/Users/bmika/python/github.com/mikaponics/mikaponics-back/env/lib/python3.6/site-packages/rq/worker.py", line 812, in perform_job
    rv = job.perform()
  File "/Users/bmika/python/github.com/mikaponics/mikaponics-back/env/lib/python3.6/site-packages/rq/job.py", line 588, in perform
    self._result = self._execute()
  File "/Users/bmika/python/github.com/mikaponics/mikaponics-back/env/lib/python3.6/site-packages/rq/job.py", line 594, in _execute
    return self.func(*self.args, **self.kwargs)
  File "/Users/bmika/python/github.com/mikaponics/mikaponics-back/mikaponics/device/tasks.py", line 21, in run_devices_handling_func
    call_command('check_devices',device.id,verbosity=0)
  File "/Users/bmika/python/github.com/mikaponics/mikaponics-back/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 148, in call_command
    return command.execute(*args, **defaults)
  File "/Users/bmika/python/github.com/mikaponics/mikaponics-back/env/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 53, in inner
    return func(*args, **kwds)
  File "/Users/bmika/python/github.com/mikaponics/mikaponics-back/mikaponics/device/management/commands/check_devices.py", line 51, in handle
    self.process_device(device, utc_today_minus_some_minutes)
  File "/Users/bmika/python/github.com/mikaponics/mikaponics-back/mikaponics/device/management/commands/check_devices.py", line 62, in process_device
    self.process_offline_status(device, utc_today_minus_some_minutes)
  File "/Users/bmika/python/github.com/mikaponics/mikaponics-back/mikaponics/device/management/commands/check_devices.py", line 69, in process_offline_status
    last_measured_utc_timestamp = device.last_measured_at
AttributeError: 'Device' object has no attribute 'last_measured_at'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.