Exemplo n.º 1
0
    def status(self):
        watches = Watch.load_all(get_db_connection(self.config))

        data = {}
        for watch in watches:
            data[str(watch.id)] = watch.dict()
            data[str(watch.id)].update(self.worker_set.worker_status_dict(watch.id))

        cherrypy.response.headers['Content-Type'] = "application/json"
        return simplejson.dumps(data)
Exemplo n.º 2
0
    def configure(self, cfg):
        """ Configuration and initialization is delayed to allow working
            with CherryPy configuration API
        """
        self.config = cfg
        create_tables(get_db_connection(self.config))

        self.worker_set = WorkerSet(cfg)
        for w in Watch.load_all(get_db_connection(self.config)):
            self.worker_set.add(w.id)
Exemplo n.º 3
0
    def test_load_all(self):
        w1 = Watch('www.google.com', 10, "go google")
        w1.save(self.connection)
        w2 = Watch('www.codesprinters.com', 10, "go codesprinters")
        w2.save(self.connection)
        w3 = Watch('www.squarewheel.pl', 10, "go google")
        w3.save(self.connection)

        watches = Watch.load_all(self.connection)

        assert_equal(3, len(watches))

        self.compare_watches(w2, watches[0])
        self.compare_watches(w1, watches[1])
        self.compare_watches(w3, watches[2])
Exemplo n.º 4
0
 def index(self):
     watches = Watch.load_all(get_db_connection(self.config))
     return self.render('index.html', watches=watches, worker_set=self.worker_set)