diff --git a/phytopi/__init__.py b/phytopi/__init__.py index ee384c0..51df99e 100644 --- a/phytopi/__init__.py +++ b/phytopi/__init__.py @@ -3,7 +3,6 @@ from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate from phytopi.config import Config -# from phytopi.camera.camera_pi import Camera app = Flask(__name__, instance_relative_config=True) @@ -11,6 +10,11 @@ app.config.from_object(Config) db = SQLAlchemy(app) migrate = Migrate(app, db) -# camera = Camera(app=app) + +from phytopi.errors import bp as errors_bp +from phytopi.camera import bp as camera_bp + +app.register_blueprint(errors_bp) +app.register_blueprint(camera_bp) from phytopi import routes, models diff --git a/phytopi/camera/__init__.py b/phytopi/camera/__init__.py index e69de29..9614332 100644 --- a/phytopi/camera/__init__.py +++ b/phytopi/camera/__init__.py @@ -0,0 +1,5 @@ +from flask import Blueprint + +bp = Blueprint('camera', __name__) + +from phytopi.camera import camera \ No newline at end of file diff --git a/phytopi/camera/camera.py b/phytopi/camera/camera.py index bfac410..2e001f6 100644 --- a/phytopi/camera/camera.py +++ b/phytopi/camera/camera.py @@ -8,7 +8,8 @@ import signal from time import sleep from enum import Enum from PIL import Image -from phytopi import db, models, app +from phytopi import db, models +from phytopi.models import CameraSettings class CameraActionError(Exception): pass @@ -21,13 +22,12 @@ class CameraStatus(Enum): SHOT = 4 class CameraWorker(object): - def __init__(self, pidfile='/tmp/raspimjpeg.pid', executable='/usr/local/bin/raspimjpeg', fifo='/dev/shm/mjpeg/FIFO', app=None): + def __init__(self, pidfile='/tmp/raspimjpeg.pid', executable='/usr/local/bin/raspimjpeg', fifo='/dev/shm/mjpeg/FIFO'): self.pidfile = pidfile self.executable = executable self.fifo = fifo self.proc = None self.pid = None - self.app = app self.status = CameraStatus.STOPPED def start(self): diff --git a/phytopi/errors/__init__.py b/phytopi/errors/__init__.py new file mode 100644 index 0000000..5d1beb0 --- /dev/null +++ b/phytopi/errors/__init__.py @@ -0,0 +1,5 @@ +from flask import Blueprint + +bp = Blueprint('errors', __name__) + +from phytopi.errors import handlers \ No newline at end of file diff --git a/phytopi/errors/handlers.py b/phytopi/errors/handlers.py new file mode 100644 index 0000000..e69de29 diff --git a/phytopi/models.py b/phytopi/models.py index b49e45f..828ddc2 100644 --- a/phytopi/models.py +++ b/phytopi/models.py @@ -1,6 +1,8 @@ from datetime import datetime from phytopi import db + + class Dataset(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True) title = db.Column(db.String(64), index=True) @@ -29,17 +31,16 @@ class CameraSettings(db.Model): fps = db.Column(db.Integer, default=5) width = db.Column(db.Integer, default=3280) height = db.Column(db.Integer, default=2464) - fix_shutter = db.Column(db.Boolean, default=False) - fix_wb = db.Column(db.Boolean, default=False) + exposure_mode = db.Column(db.String(64), default='auto') - def __init__(self, name, iso=100, fps=5, width=3280, height=2464, fix_shutter=False, fix_wb=False): + def __init__(self, name, iso=100, fps=5, width=3280, height=2464, exposure_mode='auto'): self.name = name self.iso = iso self.fps = fps self.width = width self.height = height - self.fix_shutter = fix_shutter - self.fix_wb = fix_wb + self.exposure_mode = exposure_mode + def __repr__(self): return ''.format(self.name) \ No newline at end of file