From 21fa94badec415698dc485e411a4cb93fb6f2af6 Mon Sep 17 00:00:00 2001 From: Milo Date: Sat, 6 Apr 2019 14:35:48 +0200 Subject: [PATCH] stuff --- server/activate.sh | 8 +++----- server/nightr/app.py | 6 ++++-- server/nightr/strategies/miloStrats.py | 6 ++++++ server/requirements.txt | 1 + 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/server/activate.sh b/server/activate.sh index d9583b3..81ffbe1 100755 --- a/server/activate.sh +++ b/server/activate.sh @@ -4,15 +4,13 @@ FIRST_RUN=$? # Create and enter virtual environment if (( $FIRST_RUN )); then echo Creating virtual environment - python3 -m venv venv + python3.7 -m venv venv fi source venv/bin/activate # Install required python packages -if (( $FIRST_RUN )); then - echo Installing required Python packages - pip install -Ur requirements.txt -fi +echo Installing required Python packages +pip install -Ur requirements.txt function run() { python -m nightr diff --git a/server/nightr/app.py b/server/nightr/app.py index 1b4d4b5..18f58d5 100644 --- a/server/nightr/app.py +++ b/server/nightr/app.py @@ -7,8 +7,8 @@ from typing import List import requests_cache from flask import Flask, jsonify -from server.nightr.strategies import dmi, steam -from server.nightr.util import Context +from strategies import dmi, steam, miloStrats +import Context app = Flask(__name__) @@ -19,6 +19,8 @@ strategies = { # name: (weight, probability function) "dmi": (0.5, dmi.probability), "steam": (1.0, steam.probability), + "australia" : (0.5, miloStrats.australiaStrat), + "camera" : (0.5, miloStrats.camImgStrat), } diff --git a/server/nightr/strategies/miloStrats.py b/server/nightr/strategies/miloStrats.py index b53aa9a..6aee18d 100644 --- a/server/nightr/strategies/miloStrats.py +++ b/server/nightr/strategies/miloStrats.py @@ -5,6 +5,9 @@ from server.nightr.util import Context, Prediction def camImgStrat(context : Context) -> Prediction: + """ + The contents of the camera image + """ img = cv2.imread('night.jpg',0) average = img.mean(axis=0).mean(axis=0) print(average) @@ -18,6 +21,9 @@ def camImgStrat(context : Context) -> Prediction: return p def australiaStrat(context : Context) -> Prediction: + """ + Time in Australia + """ australia = timezone('Australia/Melbourne') t = datetime.now().astimezone(australia) hour = t.hour diff --git a/server/requirements.txt b/server/requirements.txt index 031c1c9..ac757ed 100644 --- a/server/requirements.txt +++ b/server/requirements.txt @@ -1,3 +1,4 @@ Flask==1.0.2 requests==2.21.0 requests-cache==0.4.13 +pytz \ No newline at end of file