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


Python Service.get方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import get [as 别名]
    def post(self):
        """Notify subscribers that a service changed status."""

        address = self.request.get('address')
        service = Service.get(self.request.get('service'))
        oldstatus = Status.get(self.request.get('oldstatus'))
        number = self.request.get('number')

        logging.info("Service: %s" % service)
        logging.info("Service name: %s" % service.name)

        msg = "%s changed state from %s to %s (%s)" % (
                service.name, oldstatus.name,
                service.current_event().status.name,
                service.current_event().message)

        user = Subscription.get_by_email(address)
        if user.status == "available" or not number:
        	status_code = xmpp.send_message(address, msg)
    		chat_message_sent = (status_code == xmpp.NO_ERROR)
		logging.info("Notified: %s\nmessage: %s code: %d" % (address, msg, status_code))
        elif user.status == "unavailable" and number:
		sms = smsgw(to = number, msg = msg)
		sms.send()
		logging.info("Offline SMS: %s\nmessage: %s" % (number, msg))
开发者ID:feczo,项目名称:splashmon,代码行数:27,代码来源:xmpp.py

示例2: test_post_update

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import get [as 别名]
    def test_post_update(self):
        response = self.post("/admin/api/v1/services/foo",
            data={"name": "bar"})
        self.assertEquals(response.headers["Content-Type"], "application/json")
        self.assertEquals(response.status_code, 200)

        service = Service.get(self.service.key())
        self.assertEquals(service.name, "bar")
开发者ID:BillTheBest,项目名称:stashboard,代码行数:10,代码来源:test_services.py

示例3: test_post_update_desc

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import get [as 别名]
    def test_post_update_desc(self):
        response = self.post("/admin/api/v1/services/foo",
                data={"description": "hello"})
        self.assertEquals(response.headers["Content-Type"], "application/json")
        self.assertEquals(response.status_code, 200)

        service = Service.get(self.service.key())
        self.assertEquals(service.description, "hello")
开发者ID:BillTheBest,项目名称:stashboard,代码行数:10,代码来源:test_services.py

示例4: test_post_update_list

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import get [as 别名]
    def test_post_update_list(self):
        response = self.post("/admin/api/v1/services/foo",
                data={"list": "foo"})

        print response.content

        self.assertEquals(response.headers["Content-Type"], "application/json")
        self.assertEquals(response.status_code, 200)

        service = Service.get(self.service.key())
        self.assertEquals(service.list.name, "Foo")
开发者ID:2do,项目名称:stashboard,代码行数:13,代码来源:test_services.py

示例5: services_edit

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import get [as 别名]
def services_edit(request):
    id = int(request.GET.get('id'))
    service = Service.get(db.Key.from_path('Service', id))
    if request.method != 'POST':
            form = ServiceForm(instance=service)
            return respond(request, 'service_edit.html', {'form': form, 'id': id })
    
    form = ServiceForm(request.POST,instance=service)
    if form.is_valid():
        entity = form.save()
        entity.put()
        return HttpResponseRedirect(reverse(services))
    else:
        return respond(request, 'service_edit.html', {'form': form })
开发者ID:krukmat,项目名称:HOD,代码行数:16,代码来源:views.py

示例6: get_service_or_404

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import get [as 别名]
def get_service_or_404(host, port):
    try:
        service = Service.get(host, port)
    except ServiceDoesNotExist:
        restful.abort(404, message="Service {}:{} doesn't exist".format(host, port))
    return service
开发者ID:DockerLab,项目名称:playground,代码行数:8,代码来源:api.py

示例7: services_delete

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import get [as 别名]
def services_delete(request):
    id = int(request.GET.get('id'))
    service = Service.get(db.Key.from_path('Service', id))
    service.active = False
    service.put()
    return HttpResponseRedirect(reverse(services))
开发者ID:krukmat,项目名称:HOD,代码行数:8,代码来源:views.py


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