示例#1
0
    def data(self):
        services = []
        dstatus = Status.default()

        for s in Service.all().order("name").fetch(100):
            event = s.current_event()
            if event is not None:
                status = event.status
            else:
                status = dstatus

            service = {
                "slug": s.slug,
                "name": s.name,
                "url": s.url(),
                "status": status,
                "history": s.history(5, dstatus)
                }
            services.append(service)

        return {
            "days": get_past_days(5),
            "statuses": Status.all().fetch(100),
            "services": services,
            }
示例#2
0
    def get(self):
        user = users.get_current_user()
        logging.debug("BasicRootHandler#get")

        q = Service.all()
        q.order("name")
        services = q.fetch(100)
        
        p = Status.all()
        p.order("severity")
        
        past = get_past_days(5)
        
        td = default_template_data()
        td["services"] = q.fetch(100)
        td["statuses"] = p.fetch(100)
        td["past"] = past
        td["default"] = Status.default()

        self.render(td, 'basic','index.html')
示例#3
0
    def get(self):
        user = users.get_current_user()
        logging.debug("BasicRootHandler#get")

        q = Service.all()
        q.order("name")
        services = q.fetch(100)
        
        p = Status.all()
        p.order("severity")
        
        past = get_past_days(5)
        
        td = default_template_data()
        td["services"] = q.fetch(100)
        td["statuses"] = p.fetch(100)
        td["past"] = past
        td["default"] = Status.default()

        self.render(td, 'basic','index.html')
示例#4
0
    def post(self, version, service_slug):
        logging.debug("EventsListHandler#post")

        if (self.valid_version(version)):
            status_slug = self.request.get("status", default_value=None)
            message = self.request.get("message", default_value=None)
            informational = self.request.get("informational",
                                             default_value=None)

            if message:
                service = Service.get_by_slug(service_slug)
                if service:

                    if not status_slug:
                        event = service.current_event()
                        if event:
                            status = event.status
                        else:
                            status = Status.default()
                    else:
                        status = Status.get_by_slug(status_slug)

                    if status:
                        e = Event(status=status,
                                  service=service,
                                  message=message)

                        e.informational = informational and informational == "true"

                        e.put()
                        self.json(e.rest(self.base_url(version)))
                    else:
                        self.error(404, "Status %s not found" % status_slug)
                else:
                    self.error(404, "Service %s not found" % service_slug)
            else:
                self.error(400, "Event message is required")
        else:
            self.error(404, "API Version %s not supported" % version)
示例#5
0
文件: site.py 项目: samn/stashboard
    def get(self):
        user = users.get_current_user()
        logging.debug("BasicRootHandler#get")

        today = datetime.datetime.today()
        end = today
        start = end - timedelta(days=+5)

        start_date = dateparser.parse(self.request.get('start', default_value=str(start)))
        end_date = dateparser.parse(self.request.get('end', default_value=str(end)))

        history_size = config.SITE['history_size']
        if end_date > today or start_date > end_date or \
        today.toordinal() - history_size > start_date.toordinal():
            end_date = today
            start_date = end_date - timedelta(days=5)
        
        q = Service.all()
        q.order("name")
        services = []
        for service in q.fetch(100):
            events = service.events_for_days(start_date, end_date)
            services.append((service, events))
        
        p = Status.all()
        p.order("severity")
        
        past = get_past_days(5, end_date)

        td = default_template_data()
        td["start_date"] = start_date
        td["end_date"] = end_date
        td["services"] = services
        td["statuses"] = p.fetch(100)
        td["past"] = past
        td["default"] = Status.default()

        self.render(td, 'basic','index.html')
示例#6
0
文件: api.py 项目: samn/stashboard
    def post(self, version, service_slug):
        logging.debug("EventsListHandler#post")
        
        if (self.valid_version(version)):
            status_slug = self.request.get("status", default_value=None)
            message = self.request.get("message", default_value=None)
            informational = self.request.get("informational", default_value=None)
            
            if message:
                service = Service.get_by_slug(service_slug)
                if service:
                    
                    if not status_slug:
                        event = service.current_event()
                        if event:
                            status = event.status
                        else:
                            status = Status.default()
                    else:
                        status = Status.get_by_slug(status_slug)

                    if status:
                        e = Event(status=status, service=service,
                                message=message)

                        e.informational = informational and informational == "true"

                        e.put()
                        self.json(e.rest(self.base_url(version)))
                    else:
                        self.error(404, "Status %s not found" % status_slug)
                else:
                    self.error(404, "Service %s not found" % service_slug)
            else:
                self.error(400, "Event message is required")
        else:
            self.error(404, "API Version %s not supported" % version)