本文整理汇总了Python中models.Status.get_by_slug方法的典型用法代码示例。如果您正苦于以下问题:Python Status.get_by_slug方法的具体用法?Python Status.get_by_slug怎么用?Python Status.get_by_slug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Status
的用法示例。
在下文中一共展示了Status.get_by_slug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_history_no_errors_boundary
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_by_slug [as 别名]
def test_history_no_errors_boundary(self):
down = Status.get_by_slug("down")
up = Status.get_by_slug("up")
now = datetime(2011, 4, 5)
event = Event(status=down, service=self.service, start=now, message="HEY")
event.put()
history = self.service.history(5, up, start=date(2011, 4, 5))
self.assertEquals(history[0]["information"], False)
示例2: test_history_current_status
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_by_slug [as 别名]
def test_history_current_status(self):
down = Status.get_by_slug("down")
up = Status.get_by_slug("up")
now = datetime(2011, 4, 4, 12, 51)
event = Event(status=down, service=self.service, start=now, message="HEY")
event.put()
history, = self.service.history(1, up, start=date(2011, 4, 5))
self.assertEquals(history["information"], True)
示例3: post
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_by_slug [as 别名]
def post(self, version):
if (self.valid_version(version)):
name = self.request.get('name', default_value=None)
description = self.request.get('description', default_value=None)
image = self.request.get('image', default_value=None)
level = self.request.get('level', default_value=None)
severity = Level.get_severity(level)
if name and description and severity and image:
slug = slugify.slugify(name)
status = Status.get_by_slug(slug)
# Update existing resource
if status:
status.description = description
status.severity = severity
status.image = image
status.name = name
status.put()
self.json(status.rest(self.base_url(version)))
# Create new service
else:
status = Status(name=name, slug=slug, description=description,
severity=severity, image=image)
status.put()
self.json(status.rest(self.base_url(version)))
else:
self.error(400, "Bad Data")
else:
self.error(404, "API Version %s not supported" % version)
示例4: serverisdown
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_by_slug [as 别名]
def serverisdown (service):
# Create a new event with the given status and given service
service = Service.get_by_slug(service)
status = Status.get_by_slug("down")
e = Event(service=service, status=status, message="The server could not be reached")
e.put()
示例5: serverisup
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_by_slug [as 别名]
def serverisup (service):
# Create a new event with the given status and given service
service = Service.get_by_slug(service)
status = Status.get_by_slug("up")
e = Event(service=service, status=status, message="The server is responding.")
e.put()
示例6: call_api
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_by_slug [as 别名]
def call_api(service, data):
'''Submit service status to API'''
service = Service.get_by_slug(service)
status = Status.get_by_slug(data['status'])
e = Event(service=service, status=status, message=data['message'])
print json.dumps(data, sort_keys=True, skipkeys=True)
e.put()
示例7: get
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_by_slug [as 别名]
def get(self, version, status_slug):
logging.debug("CurrentStatusHandler#get")
if (self.valid_version(version)):
status = Status.get_by_slug(status_slug)
if (status):
self.json(status.rest(self.base_url(version)))
else:
self.error(404, "No status %s for Service %s" % status_slug)
else:
self.error(404, "API Version %s not supported" % version)
示例8: update_status
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_by_slug [as 别名]
def update_status(service_slug, status_type, message):
service = Service.get_by_slug(service_slug)
status = Status.get_by_slug(status_type)
cur_event = service.events.order('-start').fetch(1)
if cur_event and cur_event[0].status.slug != status.slug:
e = Event(service=service, status=status,
message=message)
e.put()
invalidate_cache()
示例9: get
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_by_slug [as 别名]
def get(self, version, status_slug):
if not self.valid_version(version):
self.error(404, "API Version %s not supported" % version)
return
status = Status.get_by_slug(status_slug)
if not status:
self.error(404, "No status with the slug %s found" % status_slug)
return
self.json(status.rest(self.base_url(version)))
示例10: get
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_by_slug [as 别名]
def get(self, slug):
status = Status.get_by_slug(slug)
if not status:
self.not_found()
return
td = {
"statuses_selected": True,
"status": status,
}
td.update(site.default_template_data())
self.render(td, 'admin/status_delete.html')
示例11: test_history_order_late_month
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_by_slug [as 别名]
def test_history_order_late_month(self):
start = date(2011, 4, 5)
up = Status.get_by_slug("up")
history = self.service.history(5, up, start=start)
history_days = [ h["day"] for h in history ]
expected = [
date(2011, 4, 4),
date(2011, 4, 3),
date(2011, 4, 2),
date(2011, 4, 1),
date(2011, 3, 31),
]
self.assertEquals(history_days, expected)
示例12: post
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_by_slug [as 别名]
def post(self, version, status_slug):
if not self.valid_version(version):
self.error(404, "API Version %s not supported" % version)
return
status = Status.get_by_slug(status_slug)
if not status:
self.error(404, "No status with the slug %s found" % status_slug)
return
name = self.request.get('name', default_value=None)
image_slug = self.request.get('image', default_value=None)
image = None
default = self.request.get('default', default_value=None)
description = self.request.get('description', default_value=None)
if image_slug is not None:
image = Image.get_by_slug(image_slug)
if image is None:
self.error(400, "An Image with the "
"slug %s doesn't exist" % image_slug)
return
status.image = image.path
if description is not None:
status.description = description
if default is not None and default in ["false", "true"]:
# Reset default status
if default == "true":
for stat in Status.all().filter("default", True):
stat.default = False
stat.put()
status.default = default == "true"
if name is not None:
status.name = name
if description or name or image or default:
status.put()
invalidate_cache()
self.json(status.rest(self.base_url(version)))
示例13: test_history_order
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_by_slug [as 别名]
def test_history_order(self):
start = date(2011, 4, 13)
up = Status.get_by_slug("up")
history = self.service.history(5, up, start=start)
self.assertEquals(len(history), 5)
history_days = [ h["day"] for h in history ]
expected = [
date(2011, 4, 12),
date(2011, 4, 11),
date(2011, 4, 10),
date(2011, 4, 9),
date(2011, 4, 8),
]
self.assertEquals(history_days, expected)
示例14: delete
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_by_slug [as 别名]
def delete(self, version, status_slug):
if not self.valid_version(version):
self.error(404, "API Version %s not supported" % version)
return
status = Status.get_by_slug(status_slug)
if not status:
self.error(404, "Status %s not found" % status_slug)
return
# We may want to think more about this
delete_multi(Event.query().filter(Event.status == status))
status.delete()
self.json(status.rest(self.base_url(version)))
示例15: post
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import get_by_slug [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)))