本文整理汇总了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)
示例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,
}
示例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,
}
示例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")
示例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)
示例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")
示例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}
示例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)
示例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')
示例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')
示例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)
示例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)
示例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)
示例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)
示例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)))