def WebCommand(self): 'Run the web server' from SimpleSeer.Web import WebServer, make_app from SimpleSeer import models as M from pymongo import Connection, DESCENDING, ASCENDING from SimpleSeer.models.Inspection import Inspection, Measurement # Plugins must be registered for queries Inspection.register_plugins('seer.plugins.inspection') Measurement.register_plugins('seer.plugins.measurement') dbName = self.session.database if not dbName: dbName = 'default' db = Connection()[dbName] # Ensure indexes created for filterable fields # TODO: should make this based on actual plugin params or filter data try: db.frame.ensure_index([('results', 1)]) db.frame.ensure_index([('results.measurement_name', 1)]) db.frame.ensure_index([('results.numeric', 1)]) db.frame.ensure_index([('results.string', 1)]) except: self.log.info('Could not create indexes') web = WebServer(make_app()) web.run_gevent_server()
def run(self): 'Run the web server' from SimpleSeer.Web import WebServer, make_app from SimpleSeer import models as M from pymongo import Connection, DESCENDING, ASCENDING from SimpleSeer.models.Inspection import Inspection, Measurement import mongoengine # Plugins must be registered for queries Inspection.register_plugins('seer.plugins.inspection') Measurement.register_plugins('seer.plugins.measurement') db = mongoengine.connection.get_db() # Ensure indexes created for filterable fields # TODO: should make this based on actual plugin params or filter data try: db.frame.ensure_index([('results', 1)]) db.frame.ensure_index([('results.measurement_name', 1)]) db.frame.ensure_index([('results.numeric', 1)]) db.frame.ensure_index([('results.string', 1)]) except: self.log.info('Could not create indexes') web = WebServer(make_app(test = self.options.test)) from SimpleSeer.Backup import Backup Backup.importAll(None, False, True, True) try: web.run_gevent_server() except KeyboardInterrupt as e: print "Interrupted by user"
def OlapCommand(self): try: from SeerCloud.OLAPUtils import ScheduledOLAP, RealtimeOLAP except: print 'Error starting OLAP schedules. This requires Seer Cloud' return 0 from SimpleSeer.models.Inspection import Inspection, Measurement Inspection.register_plugins('seer.plugins.inspection') Measurement.register_plugins('seer.plugins.measurement') so = ScheduledOLAP() gevent.spawn_link_exception(so.runSked) ro = RealtimeOLAP() ro.monitorRealtime()
config_file = "../default.cfg" Session(config_file) from SimpleSeer.models.Inspection import Inspection from SimpleSeer.models.Inspection import Measurement from SimpleSeer.models.OLAP import OLAP from SimpleSeer.models.Chart import Chart system('echo "db.dropDatabase()" | mongo default') insp = Inspection( name= "Motion", method="motion") insp.save() meas = Measurement( name="movement", label="Movement", method = "movement", parameters = dict(), units = "", featurecriteria = dict( index = 0 ), inspection = insp.id ) meas.save() ## Delivery time o = OLAP() o.name = 'Movement' o.maxLen = 1000 o.queryType = 'measurement_id' o.queryId = meas.id o.fields = ['capturetime','numeric', 'measurement_id', 'inspection_id', 'frame_id'] o.since = None o.before = None