-
Notifications
You must be signed in to change notification settings - Fork 3
/
manage.py
56 lines (48 loc) · 1.46 KB
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from flask import Flask, url_for
from flask.ext.script import Manager, Command, Option
from lablog import config
from lablog.app import App
from lablog import db
import humongolus
import logging
logging.basicConfig(level=logging.INFO)
app = App()
manager = Manager(app)
MONGO = db.init_mongodb()
humongolus.settings(logging, MONGO)
class RunWorker(Command):
def run(self):
logging.info("command!")
class InitApplication(Command):
def run(self):
logging.info("Initializing Application...")
app.configure_dbs()
from lablog.triggers.node import CO2
from lablog.triggers.lab import Presence
from lablog.triggers.energy import InputFrequency
try:
c = CO2()
c.name = 'notify slack c02'#unique
c.key = 'node.co2'
c.save()
logging.info(c.key)
logging.info(c.name)
except: pass
try:
c = Presence()
c.name = 'notify slack presence'#unique
c.key = 'presence'
c.save()
except: pass
try:
c = InputFrequency()
c.name = 'check input frequency'#unique
c.key = 'energy.ups.input_frequency'
c.save()
except: pass
logging.info("Initialization Complete.")
manager.add_command('command', RunWorker())
manager.add_command('init_app', InitApplication())
#python manager.py command
if __name__ == "__main__":
manager.run()