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


Python Service.save方法代码示例

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


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

示例1: RegisterFile

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import save [as 别名]
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,代码行数:30,代码来源:storageutils.py

示例2: import_services

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import save [as 别名]
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,代码行数:9,代码来源:importer.py

示例3: setUp

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import save [as 别名]
    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,代码行数:28,代码来源:tests.py

示例4: populate_initial_services

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import save [as 别名]
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,代码行数:58,代码来源:populate_database.py

示例5: test_creating_new_services

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import save [as 别名]
    def test_creating_new_services(self):
        service = Service()
        service.name = "test"
        service.description = "Test Service"
        service.port = 8080
        service.protocol = Service.HTTP
        service.save()

        all_services_in_database = Service.objects.all()
        self.assertEquals(len(all_services_in_database), 1)
        only_service_in_database = all_services_in_database[0]
        self.assertEquals(only_service_in_database, service)
        
        self.assertEquals(only_service_in_database.name, "test")
        self.assertEquals(only_service_in_database.description, "Test Service")
        self.assertEquals(only_service_in_database.port, 8080)
开发者ID:saschpe,项目名称:duff.suse.de,代码行数:18,代码来源:tests.py

示例6: create

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import save [as 别名]
 def create(self, validated_data):
     providers_data = validated_data.pop('provider')
     owners_data = validated_data.pop('owner')
     applications_data = validated_data.pop('application')
     clients_data = validated_data.pop('client')
     project_data = validated_data.pop('project')
     service = Service(**validated_data)
     service.project_id = project_data.id #project_data to lista
     service.save()
     for provider_data in providers_data:
         Provider.objects.create(service=service, **provider_data)
     for owner_data in owners_data:
         Owner.objects.create(service=service, **owner_data)
     for application_data in applications_data:
         Application.objects.create(service=service, **application_data)
     for client_data in clients_data:
         Client.objects.create(service=service, **client_data)
     return service
开发者ID:ILoveMuffins,项目名称:SystemSpecyfikacjiWymagan,代码行数:20,代码来源:serializers.py

示例7: create_service_from_endpoint

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import save [as 别名]
def create_service_from_endpoint(endpoint, service_type, title=None, abstract=None):
    """
    Create a service from an endpoint if it does not already exists.
    """
    from models import Service
    if Service.objects.filter(url=endpoint).count() == 0:
        # check if endpoint is valid
        request = requests.get(endpoint)
        if request.status_code == 200:
            print 'Creating a %s service for endpoint %s' % (service_type, endpoint)
            service = Service(
                 type=service_type, url=endpoint, title=title, abstract=abstract
            )
            service.save()
            return service
        else:
            print 'This endpoint is invalid, status code is %s' % request.status_code
    else:
        print 'A service for this endpoint %s already exists' % endpoint
        return None
开发者ID:jmwenda,项目名称:hypermap,代码行数:22,代码来源:utils.py

示例8: services_create

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import save [as 别名]
def services_create(request, competition = None):
	"""
	Create services in the competition
	"""
	c = getAuthValues(request, {})
	if c["auth_name"] != "auth_team_white":
		return HttpResponseRedirect("/")
	c["comp_obj"] = Competition.objects.get(compurl = competition)
	if not bool(len(ServiceModule.objects.all())):
		return HttpResponseRedirect("/admin/competitions/%s/services/" % c["comp_obj"].compurl)
	if request.method != "POST":
		# Serve empty form without acting on any data
		c.update(csrf(request))
		c["form"] = CreateServiceForm()
		c["action"] = "create"
		return render_to_response('CompConfig/services_create-edit.html', c)
	# Prepare post data for validation
	form_dict = request.POST.copy().dict()
	serv_form = CreateServiceForm(form_dict)
	if not serv_form.is_valid():
		print serv_form.errors
		return render_to_response('CompConfig/services_create-edit.html', c)
	# Now prepare post data for service object instantiation
	form_dict.pop('csrfmiddlewaretoken', None)
	form_dict["compid"] = c["comp_obj"].compid
	form_dict["servicemodule"] = ServiceModule.objects.get(servmdulid = form_dict["servicemodule"])
	# Set network connection display
	if int(form_dict["connectip"]) == 1:
		form_dict['connectip'] = True
		form_dict["connect_display"] = "IP Address"
	else:
		form_dict['connectip'] = False
		form_dict["connect_display"] = "Domain Name"
	# Clean machine address value
	if form_dict['connectip'] and form_dict['networkloc'][0] == ".":
		form_dict['networkloc'] = form_dict['networkloc'][1:]
	elif not form_dict['connectip'] and form_dict['networkloc'][-1] == ".":
		form_dict['networkloc'] = form_dict['networkloc'][:-1]
	serv_obj = Service(**form_dict)
	serv_obj.save()
	return HttpResponseRedirect("/admin/competitions/%s/services/" % competition)
开发者ID:bplower,项目名称:cssef,代码行数:43,代码来源:CompConfig.py

示例9: create_service_from_endpoint

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import save [as 别名]
def create_service_from_endpoint(endpoint, service_type, title=None, abstract=None, catalog=None):
    """
    Create a service from an endpoint if it does not already exists.
    """
    from models import Service
    if Service.objects.filter(url=endpoint, catalog=catalog).count() == 0:
        # check if endpoint is valid
        request = requests.get(endpoint)
        if request.status_code == 200:
            LOGGER.debug('Creating a %s service for endpoint=%s catalog=%s' % (service_type, endpoint, catalog))
            service = Service(
                        type=service_type, url=endpoint, title=title, abstract=abstract,
                        csw_type='service', catalog=catalog
                        )
            service.save()
            return service
        else:
            LOGGER.warning('This endpoint is invalid, status code is %s' % request.status_code)
    else:
        LOGGER.warning('A service for this endpoint %s in catalog %s already exists' % (endpoint, catalog))
        return None
开发者ID:JorgeMartinezG,项目名称:HHypermap,代码行数:23,代码来源:utils.py

示例10: ServicesViewsTest

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import save [as 别名]
class ServicesViewsTest(TestCase):
    username = "test"
    password = "password"

    def setUp(self):
        self.group, created = Group.objects.get_or_create(name='test')
        self.user, created = DjangoUser.objects.get_or_create(username=self.username)
        self.user.set_password(self.password)
        self.user.save()
        perspective, created = Perspective.objects.get_or_create(name='default')
        perspective.set_default_user()
        perspective.save()

        ModuleSetting.set('default_perspective', perspective.id)

        self.contact_type = ContactType(name='test')
        self.contact_type.set_default_user()
        self.contact_type.save()

        self.contact = Contact(name='test', contact_type=self.contact_type)
        self.contact.set_default_user()
        self.contact.save()

        self.status = TicketStatus(name='TestStatus')
        self.status.set_default_user()
        self.status.save()

        self.queue = TicketQueue(
            name='TestQueue', default_ticket_status=self.status)
        self.queue.set_default_user()
        self.queue.save()

        self.ticket = Ticket(
            name='TestTicket', status=self.status, queue=self.queue)
        self.ticket.set_default_user()
        self.ticket.save()

        self.agent = ServiceAgent(related_user=self.user.profile, available_from=datetime.time(9),
                                  available_to=datetime.time(17))
        self.agent.set_default_user()
        self.agent.save()

        self.service = Service(name='test')
        self.service.set_default_user()
        self.service.save()

        self.sla = ServiceLevelAgreement(name='test', service=self.service,
                                         client=self.contact, provider=self.contact)
        self.sla.set_default_user()
        self.sla.save()

    ######################################
    # Testing views when user is logged in
    ######################################
    def test_index_login(self):
        "Test index page with login at /services/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('services'))
        self.assertEquals(response.status_code, 200)

    def test_index_owned(self):
        "Test index page with login at /services/owned"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('services_index_owned'))
        self.assertEquals(response.status_code, 200)

    def test_index_assigned(self):
        "Test index page with login at /services/assigned"

        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('services_index_assigned'))
        self.assertEquals(response.status_code, 200)

    # Queues
    def test_queue_add(self):
        "Test page with login at /services/queue/add"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('services_queue_add'))
        self.assertEquals(response.status_code, 200)

    def test_queue_view(self):
        "Test page with login at /services/queue/view/<queue_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('services_queue_view', args=[self.queue.id]))
        self.assertEquals(response.status_code, 200)

    def test_queue_edit(self):
        "Test page with login at /services/queue/edit/<queue_id>"
        response = self.client.post('/accounts/login',
#.........这里部分代码省略.........
开发者ID:tovmeod,项目名称:anaf,代码行数:103,代码来源:tests.py


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