当前位置: 首页>>代码示例>>Python>>正文


Python Status.get_default方法代码示例

本文整理汇总了Python中models.Status.get_default方法的典型用法代码示例。如果您正苦于以下问题:Python Status.get_default方法的具体用法?Python Status.get_default怎么用?Python Status.get_default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Status的用法示例。


在下文中一共展示了Status.get_default方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: data

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_default [as 别名]
    def data(self):
        services = []
        default_status = Status.get_default()

        query = Service.all().filter("list =", self.list).order("name")

        for service in query.fetch(100):
            event = service.current_event()
            if event is not None:
                status = event.status
            else:
                status = default_status

            today = date.today() + timedelta(days=1)
            current, = service.history(1, default_status, start=today)
            has_issues = (current["information"] and
                          status.key() == default_status.key())

            service_dict = {
                "slug": service.slug,
                "name": service.name,
                "url": service.url(),
                "status": status,
                "has_issues": has_issues,
                "history": service.history(5, default_status),
                }
            services.append(service_dict)

        return {
            "days": get_past_days(5),
            "statuses": Status.all().fetch(100),
            "services": services,
            }
开发者ID:Open-Source-GIS,项目名称:stashboard,代码行数:35,代码来源:site.py

示例2: data

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_default [as 别名]
    def data(self):
        services = []
        default_status = Status.get_default()

        lists = []
        for list in self.lists:
            l = List.get_by_slug(list)
            if l is not None:
                lists.append(l)

        for service in Service.all().filter("list IN", lists).order("name").fetch(100):
            event = service.current_event()
            if event is not None:
                status = event.status
            else:
                status = default_status

            if len(self.statuses) and not status.slug in self.statuses:
                continue

            today = date.today() + timedelta(days=1)
            current, = service.history(1, default_status, start=today)
            has_issues = current["information"] and status.key() == default_status.key()

            service_dict = {
                "slug": service.slug,
                "name": service.name,
                "url": service.url(),
                "status": status,
                "has_issues": has_issues,
                "history": service.history(5, default_status),
            }
            services.append(service_dict)

        return {"days": get_past_days(5), "statuses": Status.all().fetch(100), "services": services}
开发者ID:azenk,项目名称:stashboard,代码行数:37,代码来源:site.py

示例3: data

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_default [as 别名]
    def data(self):
        default_status = Status.get_default()

        lists = []
        for list in self.lists:
            l = List.get_by_slug(list)
            if l is not None:
                lists.append(l)

        @ndb.toplevel
        def get_services():
            services = []
            for service in Service.query().filter(Service.list in lists).order(Service.name).fetch(100):
                event = yield service.current_event_async()
                if event is not None:
                    status = event.status
                else:
                    status = default_status

                if len(self.statuses) and not status.slug in self.statuses: continue

                today = datetime.today() + timedelta(days=1)
                current = yield service.history_async(1, default_status, start=today)
                
                current = current[0]

                has_issues = current["information"] and status.key == default_status.key

                history = yield service.history_async(5, default_status)

                service_dict = {
                    "slug": service.slug,
                    "name": service.name,
                    "url": service.url(),
                    "status": status,
                    "has_issues": has_issues,
                    "history": history,
                    }
                services.append(service_dict)

            raise ndb.Return(services)

        return {
            "days": get_past_days(5),
            "statuses": Status.query().fetch(100),
            "services": get_services(),
            }
开发者ID:Labgoo,项目名称:stashboard,代码行数:49,代码来源:site.py

示例4: post

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_default [as 别名]
    def post(self, version, service_slug):
        if not self.valid_version(version):
            self.error(404, "API Version %s not supported" % version)
            return

        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 not message:
            self.error(400, "Event message is required")
            return

        service = Service.get_by_slug(service_slug)

        if not service:
            self.error(404, "Service %s not found" % service_slug)
            return

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

        if not status:
            self.error(404, "Status %s not found" % status_slug)
            return

        e = Event(status=status, service=service, message=message)
        e.informational = informational and informational == "true"
        e.put()

        # Queue up a task that calls the Twitter API to make a tweet.
        if self.request.get('tweet'):
            logging.info('Attempting to post a tweet for the latest event via async GAE task queue.')
            taskqueue.add(url='/admin/tweet', params={'service_name': service.name, 'status_name': status.name, 'message': message})

        #TODO - insert Hipchat notification here
        logging.info('*** Sending update to Hipchat room')
        taskqueue.add(url='/admin/hipchat', params={'service_name': service.name, 'status_name': status.name, 'message': message})

        invalidate_cache()
        self.json(e.rest(self.base_url(version)))
开发者ID:Homefinder,项目名称:stashboard,代码行数:49,代码来源:api.py

示例5: check_service

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_default [as 别名]
    def check_service(self, service, tries_count=0, last_status_slug="", options=None, schedule=True):
        if not options:
            options = {}

        self.log("Checking %(service_name)s" % {"service_name": service.name})
        check = self.check_host(options)

        if check["is_ok"]:
            tries_count = 0
            status_slug = "up"
            countdown = settings.CHECK_SERVICES_NORMAL_CHECK_INTERVAL
        else:
            countdown = settings.CHECK_SERVICES_ERROR_CHECK_INTERVAL
            tries_count = int(tries_count) + 1
            self.log(
                "Check count: %(count)s, limit is %(limit)s"
                % {"count": tries_count, "limit": settings.CHECK_SERVICES_MAX_TRIES}
            )

            if check["is_unknown"]:
                status_slug = "unknown"
            else:
                status_slug = "down"

        if tries_count >= settings.CHECK_SERVICES_MAX_TRIES or check["is_ok"]:
            if not last_status_slug:
                last_event = service.current_event()
                if last_event:
                    last_status_slug = last_event.status.slug
                else:
                    last_status_slug = Status.get_default().slug

        if last_status_slug != status_slug:
            status = Status.get_by_slug(status_slug)
            logging.info(
                "%(service_name)s is : %(status)s (was %(last_status)s)"
                % {"service_name": service.name, "status": status_slug, "last_status": last_status_slug}
            )
            self.update_service(service, status, check["message"])
            self.log("invalidate_cache")
            api.invalidate_cache()
            self.notify_admin(service, status, check["notification_message"])
            last_status_slug = status_slug

        if schedule:
            self.schedule_check(service.slug, countdown, tries_count, last_status_slug)
开发者ID:tucknet,项目名称:status.tucksaun.net,代码行数:48,代码来源:serviceChecks.py

示例6: post

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_default [as 别名]
    def post(self, version, service_slug):
        if not self.valid_version(version):
            self.error(404, "API Version %s not supported" % version)
            return

        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 not message:
            self.error(400, "Event message is required")
            return

        service = Service.get_by_slug(service_slug)

        if not service:
            self.error(404, "Service %s not found" % service_slug)
            return

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

        if not status:
            self.error(404, "Status %s not found" % status_slug)
            return

        e = Event(status=status, service=service, message=message)
        e.informational = informational and informational == "true"
        e.put()

        invalidate_cache()
        self.json(e.rest(self.base_url(version)))
开发者ID:Tradeshift,项目名称:stashboard,代码行数:40,代码来源:api.py

示例7: post

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_default [as 别名]
    def post(self, version, service_slug):
        if not self.valid_version(version):
            self.error(404, "API Version %s not supported" % version)
            return

        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 not message:
            self.error(400, "Event message is required")
            return

        service = Service.get_by_slug(service_slug)

        if not service:
            self.error(404, "Service %s not found" % service_slug)
            return

        last_event = service.current_event()
        if last_event:
            old_status = last_event.status

        if not status_slug:
            if last_event:
                status = old_status
            else:
                status = Status.get_default()
        else:
            status = Status.get_by_slug(status_slug)

        if not status:
            self.error(404, "Status %s not found" % status_slug)
            return

        e = Event(status=status, service=service, message=message)
        e.informational = informational and informational == "true"
        e.put()

        # Queue up a task that calls the Twitter API to make a tweet.
        if self.request.get('tweet'):
            logging.info('Attempting to post a tweet for the latest event via async GAE task queue.')
            taskqueue.add(url='/admin/tweet', params={'service_name': service.name, 'status_name': status.name, 'message': message})
        # Queue up tasks for notifing subscribers via XMPP
        if service.subscriptions:
	    for subscription in service.subscriptions.filter("type =","xmpp"):
	        mobile = Mobile.all().filter('subscription = ', subscription).get()
		if mobile:
			mobile_number = mobile.number
		else:
			mobile_number = False
                params={'address': subscription.address, 'service':
                        service.key(), 'oldstatus': old_status.key(), 'number': mobile_number}
                logging.info("Adding deferred task: %s %s" % (
                    subscription.type, params))
                taskqueue.add(url='/notify/' + subscription.type, params=params)
        else:
            logging.info("No subscriptions for %s" % service.name)

        invalidate_cache()
        self.json(e.rest(self.base_url(version)))
开发者ID:feczo,项目名称:splashmon,代码行数:63,代码来源:api.py


注:本文中的models.Status.get_default方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。