This commit is contained in:
Mikkel Milo 2019-04-06 14:35:48 +02:00
parent 1399307500
commit 21fa94bade
4 changed files with 14 additions and 7 deletions

View File

@ -4,15 +4,13 @@ FIRST_RUN=$?
# Create and enter virtual environment # Create and enter virtual environment
if (( $FIRST_RUN )); then if (( $FIRST_RUN )); then
echo Creating virtual environment echo Creating virtual environment
python3 -m venv venv python3.7 -m venv venv
fi fi
source venv/bin/activate source venv/bin/activate
# Install required python packages # Install required python packages
if (( $FIRST_RUN )); then
echo Installing required Python packages echo Installing required Python packages
pip install -Ur requirements.txt pip install -Ur requirements.txt
fi
function run() { function run() {
python -m nightr python -m nightr

View File

@ -7,8 +7,8 @@ from typing import List
import requests_cache import requests_cache
from flask import Flask, jsonify from flask import Flask, jsonify
from server.nightr.strategies import dmi, steam from strategies import dmi, steam, miloStrats
from server.nightr.util import Context import Context
app = Flask(__name__) app = Flask(__name__)
@ -19,6 +19,8 @@ strategies = {
# name: (weight, probability function) # name: (weight, probability function)
"dmi": (0.5, dmi.probability), "dmi": (0.5, dmi.probability),
"steam": (1.0, steam.probability), "steam": (1.0, steam.probability),
"australia" : (0.5, miloStrats.australiaStrat),
"camera" : (0.5, miloStrats.camImgStrat),
} }

View File

@ -5,6 +5,9 @@ from server.nightr.util import Context, Prediction
def camImgStrat(context : Context) -> Prediction: def camImgStrat(context : Context) -> Prediction:
"""
The contents of the camera image
"""
img = cv2.imread('night.jpg',0) img = cv2.imread('night.jpg',0)
average = img.mean(axis=0).mean(axis=0) average = img.mean(axis=0).mean(axis=0)
print(average) print(average)
@ -18,6 +21,9 @@ def camImgStrat(context : Context) -> Prediction:
return p return p
def australiaStrat(context : Context) -> Prediction: def australiaStrat(context : Context) -> Prediction:
"""
Time in Australia
"""
australia = timezone('Australia/Melbourne') australia = timezone('Australia/Melbourne')
t = datetime.now().astimezone(australia) t = datetime.now().astimezone(australia)
hour = t.hour hour = t.hour

View File

@ -1,3 +1,4 @@
Flask==1.0.2 Flask==1.0.2
requests==2.21.0 requests==2.21.0
requests-cache==0.4.13 requests-cache==0.4.13
pytz