Esempio n. 1
0
    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"
Esempio n. 2
0
 def run(self):
     from SimpleSeer.Backup import Backup
     
     listen = self.options.listen
     
     Backup.exportAll()
     
     if listen.upper() == 'TRUE': 
         gevent.spawn_link_exception(Backup.listen())
Esempio n. 3
0
 def run(self):
     from SimpleSeer.Backup import Backup
     
     if self.options.subsubcommand != 'import' and self.options.subsubcommand != 'export':
         self.log.info("Valid subcommands are import and export.  Ignoring \"{}\".".format(self.options.subsubcommand))
     if self.options.subsubcommand == "export" and self.options.clean:
         self.log.info("Clean option not applicable when exporting.  Ignoring")
     if self.options.subsubcommand == "import" and self.options.listen:
         self.log.info("Listen option not applicable when importing.  Ignorning")
     
     if self.options.subsubcommand == "export":
         Backup.exportAll()
         if self.options.listen: 
             gevent.spawn_link_exception(Backup.listen())
     elif self.options.subsubcommand == "import":
         Backup.importAll(self.options.file, self.options.clean, self.options.skipbackfill)
Esempio n. 4
0
 def run(self):
     from SimpleSeer.Backup import Backup
     
     filename = self.options.file
     Backup.importAll(filename)