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


Python Service.all方法代码示例

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


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

示例1: sub_command

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import all [as 别名]
    def sub_command(self, message=None):
        """Subscribe the user to XMPP or SMS"""
        user = message.sender.split('/')[0]
	
        plist = message.body.split(' ' )
 	service_name = plist[1]

	if len(plist)>2:
	    type = "sms"
            user = plist[2]
	else:
	    type = "xmpp"
		
        service = Service.all().filter('name = ', service_name).get()

        if service:
            subscription = Subscription.all().filter('address =', user).filter('service = ', service).get()
            if subscription:
                message.reply("user %s is already subscribed to service %s" % (user, service.name))
            else:
                subscription = Subscription(key_name=hashlib.sha1(user).hexdigest(), type=type, address=user, service=service)
                subscription.put()
                message.reply("Subscribed %s to service %s" % (user, service.name))
        else:
            message.reply("Sorry, I couldn't find a service called "
                          "%s" % service_name)
开发者ID:feczo,项目名称:splashmon,代码行数:28,代码来源:xmpp.py

示例2: data

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import all [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

示例3: data

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import all [as 别名]
    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,
            }
开发者ID:kyleconroy,项目名称:stashboard,代码行数:27,代码来源:site.py

示例4: unsms_command

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import all [as 别名]
    def unsms_command(self, message=None):
        """Unsubscribe the user from a service"""
	plist = message.body.split(' ')
	if len(plist)==2:
	        user = message.sender.split('/')[0]
	
	        service_name = plist[1]
	
	        service = Service.all().filter('name = ', service_name).get()
	
	        if service:
		    subscription = Subscription.all().filter('address =', user).filter('service = ', service).get()
		
		    if subscription:
	            	mobile = Mobile.all().filter('subscription = ', subscription).get()
	            	if mobile:
		    	    message.reply("Unsubscribed user %s from backup mobile %s for service %s" % (user, mobile.number,service_name))
	            	    mobile.delete()
			else:
			    message.reply("No backup mobile for user %s on %s service" % (user,service_name))
	 	    else:
	            	message.reply("User %s is not subscribed to service %s" % (user, service.name))
	        else:
	            message.reply("Sorry, I couldn't find a service called "
                          "%s" % service_name)
	else:
		 message.reply("Usege: unsms SERVICE +6112345678")
开发者ID:feczo,项目名称:splashmon,代码行数:29,代码来源:xmpp.py

示例5: unsub_command

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import all [as 别名]
    def unsub_command(self, message=None):
        """Unsubscribe the user from a service"""
        user = message.sender.split('/')[0]

        plist = message.body.split(' ' )
        service_name = plist[1]

	if len(plist)>2:
	    type = "sms"
            user = plist[2]
	else:
	    type = "xmpp"
		
        service = Service.all().filter('name = ', service_name).get()

        if service:
            subscription = Subscription.all().filter('address =', user).filter('service = ', service).filter('type =', type).get()
            if subscription:
                subscription.delete()
		if type == "xmpp":
	            	mobile = Mobile.all().filter('subscription = ', subscription).get()
			if mobile:
				mobile.delete()
                message.reply("Unsubscribed %s from service %s" % (user, service.name))
            else:
                message.reply("user %s is not subscribed to service %s" % (user, service.name))
        else:
            message.reply("Sorry, I couldn't find a service called "
                          "%s" % service_name)
开发者ID:feczo,项目名称:splashmon,代码行数:31,代码来源:xmpp.py

示例6: sms_command

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import all [as 别名]
    def sms_command(self, message=None):
        """Subscribe the user to a offline SMS"""

        plist = message.body.split(' ')
	if len(plist)==3:
	        user = message.sender.split('/')[0]
	 	service_name = plist[1]
	 	number = plist[2]
	
	        service = Service.all().filter('name = ', service_name).get()
	
	        if service:
		 	subscription = Subscription.all().filter('address =', user).filter('service = ', service).get()
		
		        if subscription:
		            mobile = Mobile.all().filter('number =', number).get()
		            if mobile:
		                message.reply("user %s is already registered backup mobile %s for service %s" % (user, mobile.number,service_name))
		            else:
		                mobile = Mobile(number=number, subscription = subscription)
		                mobile.put()
		                message.reply("Subscribed user %s to backup mobile %s for service %s" % (user, number,service_name))
		        else:
		            message.reply("Sorry, I couldn't find a subscription on %s for %s" % (service_name,user))
	        else:
	            message.reply("Sorry, I couldn't find a service called "
	                          "%s" % service_name)
	else:
		message.reply("Usage: sms SERVICE +61412345678")
开发者ID:feczo,项目名称:splashmon,代码行数:31,代码来源:xmpp.py

示例7: data

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import all [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

示例8: get

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import all [as 别名]
 def get(self, version):
     if self.valid_version(version):
         query = Service.all().order("name")
         data = [s.rest(self.base_url(version)) for s in query]
         data = {"services": data}
         self.json(data)
     else:
         self.error(404, "API Version %s not supported" % version)
开发者ID:kyleconroy,项目名称:stashboard,代码行数:10,代码来源:api.py

示例9: get

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import all [as 别名]
    def get(self):
        if not setup_occurred():
            self.redirect("/admin/setup")

        td = default_template_data()
        td["services_selected"] = True
        td["services"] = Service.all().order("name").fetch(1000)
        self.render(td, 'admin/services.html')
开发者ID:Homefinder,项目名称:stashboard,代码行数:10,代码来源:admin.py

示例10: get

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import all [as 别名]
    def get(self):
        user = users.get_current_user()
        logging.debug("RootHandler#get")
        
        q = Service.all()
        q.order("name")
        
        td = default_template_data()
        td["past"] = get_past_days(5)

        self.render(td, 'index.html')
开发者ID:Cdub1704,项目名称:stashboard,代码行数:13,代码来源:site.py

示例11: services_command

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import all [as 别名]
    def services_command(self, message=None):
        """List all services"""
        return_msg = []

        for service in Service.all():
            event = service.current_event()
            if event:
                return_msg.append("%s: %s: %s" % (
                        service.name, event.status.name, event.message))
            else:
                return_msg.append("%s has no events" % service.name)

        return_msg = '\n'.join(return_msg)

        message.reply(return_msg)
开发者ID:feczo,项目名称:splashmon,代码行数:17,代码来源:xmpp.py

示例12: get

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import all [as 别名]
    def get(self, version):
        logging.debug("ServicesListHandler#get")
        if (self.valid_version(version)):
            
            query = Service.all().order('name')
            data = []


            for s in query:
                data.append(s.rest(self.base_url(version)))

            data = { "services": data }

            self.json(data)
            
        else:
            self.error(404, "API Version %s not supported" % version)
开发者ID:johnclarkemills,项目名称:stashboard,代码行数:19,代码来源:api.py

示例13: service_command

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import all [as 别名]
    def service_command(self, message=None):
        """Change status of a service"""
        _, service_name = message.body.split(' ', 1)
        service = Service.all().filter('name = ', service_name).get()

        if service:
            return_msg =["Name: %s" % service.name]
            return_msg.append("Description: %s" % service.description)
            return_msg.append("Recent events:")
            events = service.events.order('-start').run(limit=3)
            for event in events:
                return_msg.append("%s: %s: %s" % (
                        event.start, event.status.name, event.message))
        else:
            return_msg = ["Cannot find service with name: %s" % service_name]

        return_msg = "\n".join(return_msg)
        message.reply(return_msg)
开发者ID:feczo,项目名称:splashmon,代码行数:20,代码来源:xmpp.py

示例14: get

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import all [as 别名]
    def get(self, version):
        logging.debug("ServicesListHandler#get")
        if (self.valid_version(version)):
            region = self.request.get('region', default_value=None)
            
            query = Service.all().order('name')
            if region:
                r = Region.get_by_name(region)
                query.filter("region = ", r)

            data = []
            for s in query:
                data.append(s.rest(self.base_url(version)))

            data = { "services": data }

            self.json(data)
            
        else:
            self.error(404, "API Version %s not supported" % version)
开发者ID:samn,项目名称:stashboard,代码行数:22,代码来源:api.py

示例15: delete

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

        list = List.get_by_slug(list_slug)

        if not list:
            self.error(404, "List %s not found" % list_slug)
            return

        query = Service.all()
        query.filter('list =', list)
        if query:
            for s in query:
                s.list = None
                s.put()

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


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