• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Service类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: RegisterFile

def RegisterFile(Service=None, FileName=None, ProvisionedSpace="10G"):

    if Service  is None:
	raise StorageError('RegisterFile(): Service can not be None')

    if FileName is None:
	raise StorageError('RegisterFile(): FileName can not be None')

    vfilespace = StringSizeToBytes(ProvisionedSpace)
    
    if Service.freespace - vfilespace > 0:
	NewFile = File()
	NewFile.vfilename 	= FileName
        NewFile.ufid		= GetUniqueFileID(FileName)
	NewFile.pfilesize	= 0
        NewFile.vfilesize	= vfilespace
	NewFile.service		= Service
	NewFile.pfilename	= GetPhysicalFileName(Service.localpath, FileName)
	NewFile.status		= 'O'
	NewFile.save()
	
	SFreeSpace = CalculateFreeSpace(Service)
	Service.freespace = SFreeSpace
	Service.save()

	return NewFile
    else:
	raise StorageError('RegisterFile(): No have left space')
开发者ID:emilianobilli,项目名称:tacho,代码行数:28,代码来源:storageutils.py


示例2: service_add

def service_add(request, response_format='html'):
    "Service add"

    if not request.user.profile.is_admin('anaf.services'):
        return user_denied(request,
                           message="You don't have administrator access to the Service Support module")

    if request.POST:
        if 'cancel' not in request.POST:
            service = Service()
            form = ServiceForm(
                request.user.profile, request.POST, instance=service)
            if form.is_valid():
                service = form.save()
                service.set_user_from_request(request)
                return HttpResponseRedirect(reverse('services_service_view', args=[service.id]))
        else:
            return HttpResponseRedirect(reverse('services'))
    else:
        form = ServiceForm(request.user.profile)

    context = _get_default_context(request)
    context.update({'form': form})

    return render_to_response('services/service_add', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:tovmeod,项目名称:anaf,代码行数:26,代码来源:views.py


示例3: post

    def post(self, version, service_slug):
        logging.debug("ServiceInstanceHandler#post")
        name = self.request.get('name', default_value=None)
        description = self.request.get('description', default_value=None)
        region = self.request.get('region', default_value=None)
        
        if (self.valid_version(version)):
            service = Service.get_by_slug(service_slug)
            if service:
                if description:
                    service.description = description
                
                if name:
                    service.name = name

                if region:
                    service.region = Region.get_by_name(region)
                
                if name or description or region:
                    service.slug = Service.slugify(service.name, service.region.name)
                    service.put()
                    
                self.json(service.rest(self.base_url(version)))   
            else:
                self.error(404, "Service %s does not exist" % service_slug)
        else:
            self.error(404, "API Version %s not supported" % version)
开发者ID:samn,项目名称:stashboard,代码行数:27,代码来源:api.py


示例4: test_modify_entity

    def test_modify_entity(self):
        # TODO: test erroneous cases (required field deleted, field type
        # mismatch etc.)
        test_srv = Service.by_property(
            'name', u'Предоставление земельного участка многодетной семье')
        required_srv = Service.by_property(
            'name', u'Регистрация по месту жительства')
        kmplks_to_remove = Kompleks.by_property('name', u'Рождение ребенка')

        test_srv.prerequisite_description = u"это нужно будет удалить"
        test_srv.put()

        req_data = [
            {'name': 'short_description', 'value': u'тест тест тест'},
            {'name': "dependencies", 'edits': [
                {'values': [required_srv.urlsafe()], 'method': 'add'}]},
            {'name': 'related_komplekses', 'edits': [
                {'values': [kmplks_to_remove.urlsafe()],
                 'method': 'subtract'}]},
            {'name': 'prerequisite_description', 'value': None}]
        req_url = '/admin/api/entities/' + test_srv.urlsafe()

        response = self.testapp.put_json(req_url, req_data)
        self.assertEqual(response.status_int, 200)

        test_srv = from_urlsafe(test_srv.urlsafe())

        self.assertEqual(test_srv.prerequisite_description, None)
        self.assertNotIn(
            from_urlsafe(kmplks_to_remove.urlsafe(),key_only=True),
            test_srv.related_komplekses)
        self.assertIn(from_urlsafe(required_srv.urlsafe(), key_only=True),
                      test_srv.dependencies)
        self.assertEqual(test_srv.short_description, u'тест тест тест')
开发者ID:vleseg,项目名称:kmplks,代码行数:34,代码来源:test_app.py


示例5: search_service

    def search_service(self, pkg):
        """For HTTP, a service if not found by conventional method,
        the 'host' header can be used to determine destiny URL.

        The Service from 'host' header is searched the same way as a DNS cache answered.
        """

        service = super().search_service(pkg)

        if service:
            return service

        if hasattr(pkg.http, 'host'):
            # When header host is IP addr, create service 'Unknown (IP)'. 
            # If not, service will have name of the IP
            # The name must have info of the IP for the equals btw services
            if is_ipaddress(pkg.http.host):
                return Service.from_ip_only(pkg.http.host)
            else:
                name = get_significant_name_from_url(pkg.http.host)
                service = self.environment.service_analyzer.find_service_from_absolute_url(
                    pkg.http.host
                ) or self.environment.service_analyzer.find_service_from_url(
                    pkg.http.host) or Service.from_name(name)
                service.hosts.add(pkg.http.host)
                return service
        else:
            return None
开发者ID:SonarWAN,项目名称:sonarwan,代码行数:28,代码来源:handlers.py


示例6: post

    def post(self, version):
        if not self.valid_version(version):
            self.error(404, "API Version %s not supported" % version)
            return

        name = self.request.get('name', default_value=None)
        description = self.request.get('description', default_value=None)

        if not name or not description:
            self.error(400, "Bad Data: Name: %s, Description: %s" \
                           % (name, description))
            return

        slug = slugify.slugify(name)
        existing_s = Service.get_by_slug(slug)

        if existing_s:
            self.error(404, "A sevice with this name already exists")
            return

        s = Service(name=name, slug=slug, description=description)
        s.put()

        invalidate_cache()

        self.response.set_status(201)
        self.json(s.rest(self.base_url(version)))
开发者ID:BillTheBest,项目名称:stashboard,代码行数:27,代码来源:api.py


示例7: import_services

def import_services(service_list):
    """Add any services from file to django database"""
    current_services = read_current_services()
    for service in service_list:
        if service not in current_services:
            new_service = Service(service_name=service)
            new_service.save()
开发者ID:makrohn,项目名称:rba_tool,代码行数:7,代码来源:importer.py


示例8: post

    def post(self, version):
        logging.debug("ServicesListHandler#post")

        if (self.valid_version(version)):
            
            name = self.request.get('name', default_value=None)
            description = self.request.get('description', default_value=None)
            serviceurl = self.request.get('serviceurl', default_value=None)
            pattern = self.request.get('pattern', default_value=None)
            freq = self.request.get('freq', default_value=None)
            
            if name and description:
                slug = slugify.slugify(name)
                existing_s = Service.get_by_slug(slug)

                # Update existing resource
                if existing_s:
                    existing_s.description = description
                    existing_s.serviceurl = serviceurl
                    existing_s.pattern = pattern
                    existing_s.freq = freq
                    existing_s.put()
                    self.json(existing_s.rest(self.base_url(version)))
                # Create new service
                else:
                    s = Service(name=name, slug=slug, description=description, serviceurl=serviceurl)
                    s.put()
                    self.json(s.rest(self.base_url(version)))
            else:
                self.error(400, "Bad Data: Name: %s, Description: %s" % (name, description))
        else:
            self.error(404, "API Version %s not supported" % version)
开发者ID:johnclarkemills,项目名称:stashboard,代码行数:32,代码来源:api.py


示例9: setUp

    def setUp(self):

        for s in range(0, SERVICE_NUMBER):
            service = Service(
                url='http://%s.fakeurl.com' % s,
                title='Title %s' % s,
                type='OGC_WMS',
            )
            service.save()
            for l in range(0, 20):
                layer = Layer(
                    name='Layer %s, from service %s' % (l, s),
                    bbox_x0=-179,
                    bbox_x1=179,
                    bbox_y0=-89,
                    bbox_y1=89,
                    service=service
                )
                layer.save()
                service.layer_set.add(layer)
        for c in range(0, TIMES_TO_CHECK):
            for s in range(0, SERVICE_NUMBER):
                service = Service.objects.all()[s]
                service.check()
                for layer in service.layer_set.all():
                    layer.check()
开发者ID:jmwenda,项目名称:hypermap,代码行数:26,代码来源:tests.py


示例10: addservice_command

    def addservice_command(self, message=None):
        """Create a new service"""

        service_name = message.body.split(' ')[1]
        service = Service(key_name=service_name, name=service_name)
        service.put()

        message.reply("Added service %s" % service_name)
开发者ID:feczo,项目名称:splashmon,代码行数:8,代码来源:xmpp.py


示例11: api_get_services

def api_get_services(*, page='1'):
    page_index = get_page_index(page)
    num = yield from Service.findNumber('count(id)')
    p = Page(num, page_index)
    if num == 0:
        return dict(page=p, service=())
    service = yield from Service.findAll(limit=(p.offset, p.limit))
    return dict(page=p, service=service)
开发者ID:chenyanglong,项目名称:ideal,代码行数:8,代码来源:handlers.py


示例12: ServiceInstanceTest

class ServiceInstanceTest(StashboardTest):

    def setUp(self):
        super(ServiceInstanceTest, self).setUp()
        self.service = Service(name="Foo", slug="foo", description="foo")
        self.service.put()

    @patch("handlers.api.invalidate_cache")
    def test_delete_service(self, mock):
        response = self.delete("/admin/api/v1/services/foo")
        self.assertEquals(response.status_code, 200)

    def test_delete_wrong_service(self):
        response = self.delete("/admin/api/v1/services/bar")
        self.assertEquals(response.status_code, 404)

    def test_delete_wrong_version(self):
        response = self.delete("/admin/api/foo/services/foo")
        self.assertEquals(response.status_code, 404)

    def test_post_wrong_service(self):
        response = self.post("/admin/api/v1/services/bar")
        self.assertEquals(response.status_code, 404)

    def test_post_wrong_version(self):
        response = self.post("/admin/api/foo/services/foo")
        self.assertEquals(response.status_code, 404)

    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")

    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")

    def test_get_wrong_service(self):
        response = self.get("/admin/api/v1/services/bar")
        self.assertEquals(response.status_code, 404)

    def test_get_wrong_version(self):
        response = self.get("/admin/api/foo/services/foo")
        self.assertEquals(response.status_code, 404)

    def test_get_service(self):
        response = self.get("/admin/api/v1/services/foo")
        self.assertEquals(response.status_code, 200)
        self.assertEquals(response.headers["Content-Type"], "application/json")
开发者ID:BillTheBest,项目名称:stashboard,代码行数:58,代码来源:test_services.py


示例13: service_create

def service_create():
    name = request.form.get('name', '').strip()
    icon = request.form.get('icon', '').strip()
    if not name:
        return jsonify(Error.ARGUMENT_MISSING('name'))
    srv = Service(name, icon)
    db.session.add(srv)
    db.session.commit()
    return jsonify({"service": srv.as_dict(True)})
开发者ID:leeming,项目名称:Pushjet-Server-Api,代码行数:9,代码来源:service.py


示例14: populate_initial_services

def populate_initial_services():
    """
    Populate a fresh installed Hypermap instances with basic services.
    """
    services_list = (
        (
            'Harvard WorldMap',
            'Harvard WorldMap open source web geospatial platform',
            'WM',
            'http://worldmap.harvard.edu'
        ),
        (
            'NYPL MapWarper',
            'The New York Public Library (NYPL) MapWarper web site',
            'WARPER',
            'http://maps.nypl.org/warper/maps'
        ),
        (
            'Map Warper',
            'The MapWarper web site developed, hosted and maintained by Tim Waters',
            'WARPER',
            'http://mapwarper.net/maps'
        ),
        (
            'WorldMap Warp',
            'The MapWarper instance part of the Harvard WorldMap project',
            'WARPER',
            'http://warp.worldmap.harvard.edu/maps'
        ),
        (
            'WFP GeoNode',
            'World Food Programme GeoNode',
            'OGC_WMS',
            'http://geonode.wfp.org/geoserver/ows?'
        ),
        (
            'NASA EARTHDATA',
            'NASA EARTHDATA, powered by EOSDIS',
            'OGC_WMTS',
            'http://map1.vis.earthdata.nasa.gov/wmts-geo/1.0.0/WMTSCapabilities.xml'
        ),
    )

    esri_endpoint = 'https://gis.ngdc.noaa.gov/arcgis/rest/services'
    print '*** Importing esri endpoint: %s' % esri_endpoint
    create_services_from_endpoint(esri_endpoint)

    for service in services_list:
        print '*** Importing %s' % service[0]
        service = Service(
            title=service[0],
            abstract=service[1],
            type=service[2],
            url=service[3]
        )
        service.save()
开发者ID:jmwenda,项目名称:hypermap,代码行数:56,代码来源:populate_database.py


示例15: test_create_event

    def test_create_event(self):
        s = Service(slug=u"hey", name=u"you", description=u"lol")
        s.put()

        stat = Status(name=u"you", slug=u"leave", description=u"why",
                      image=u"cry")
        stat.put()

        e = Event(status=stat, service=s, message=u"¨¥¨œ∑´æ")
        e.put()

        data = e.rest("/api")
开发者ID:2do,项目名称:stashboard,代码行数:12,代码来源:test_unicode.py


示例16: delete

    def delete(self, version, service_slug, sid):
        if not self.valid_version(version):
            self.error(404, "API Version %s not supported" % version)
            return

        service = Service.get_by_slug(service_slug)

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

 
        try:
            event = Event.get(db.Key(sid))
        except datastore_errors.BadKeyError:
            self.error(404, "Event %s not found" % sid)
            return

        if not event or service.key() != event.service.key():
            self.error(404, "No event for Service %s with sid = %s" \
                           % (service_slug, sid))
            return

        event.delete()
        invalidate_cache()

        # Why not JSON?
        self.success(event.rest(self.base_url(version)))
开发者ID:Tradeshift,项目名称:stashboard,代码行数:28,代码来源:api.py


示例17: serverisup

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()
开发者ID:StrataLabs,项目名称:status.justbooksclc.com,代码行数:7,代码来源:stashboard.py


示例18: setUp

 def setUp(self):
     super(ServiceListInstanceTest, self).setUp()
     self.service_list = List(slug="foo", name="Foo", description="Bar")
     self.service_list.put()
     self.service = Service(list=self.service_list, name="Foo", slug="foo",
                            description="foo")
     self.service.put()
开发者ID:2do,项目名称:stashboard,代码行数:7,代码来源:test_service_lists.py


示例19: unsms_command

    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,代码行数:27,代码来源:xmpp.py


示例20: unsub_command

    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,代码行数:29,代码来源:xmpp.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Session类代码示例发布时间:2022-05-27
下一篇:
Python models.Server类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap