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


Python Service.upnpGetString方法代码示例

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


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

示例1: browse

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import upnpGetString [as 别名]
	def browse(event):
		if not event:
			return False

		if not event['status']:
			return False

		metadata = False

		index         = Service.upnpGetUI4(event['request'], CDSService.SERVICE_CDS_ARG_START_INDEX)
		count         = Service.upnpGetUI4(event['request'], CDSService.SERVICE_CDS_ARG_REQUEST_COUNT)
		_id           = Service.upnpGetUI4(event['request'], CDSService.SERVICE_CDS_ARG_OBJECT_ID)
		flag          = Service.upnpGetString(event['request'], CDSService.SERVICE_CDS_ARG_BROWSE_FLAG)
		_filter       = Service.upnpGetString(event['request'], CDSService.SERVICE_CDS_ARG_FILTER)
		sort_criteria = Service.upnpGetUI4(event['request'], CDSService.SERVICE_CDS_ARG_SORT_CRIT)
		manager = OneServerManager()
		manager.log.debug("index=%s, count=%s, _id=%s, flag=%s, _filter=%s, sort_criteria=%s" % (index,count, _id, flag,_filter, sort_criteria))
		if not flag or not _filter:
			return False

		# Validation checking.
		if flag == CDSService.SERVICE_CDS_BROWSE_METADATA:
			if index != 0:
				return False

			metadata = True
		elif flag == CDSService.SERVICE_CDS_BROWSE_CHILDREN:
			metadata = False
		else:
			return False
		
		entry = manager.rootEntry.getChild(_id)

		if not entry and _id < 0:
			manager.error("Invalid id {0}, defaulting to root".format(_id))
			entry = manager.rootEntry

		if not entry:
			return False

		out = ""

		result_count = 0
		if metadata:
			result_count,out = CDSService.cdsBrowseMetadata(event, out, index, count, entry, _filter) 
		else:
			result_count,out = CDSService.cdsBrowseDirectChildren(event, out, index, count, entry, _filter)

		if result_count < 0:
			return False

		Service.upnpAddResponse(event, CDSService.SERVICE_CDS_DIDL_UPDATE_ID, CDSService.SERVICE_CDS_ROOT_OBJECT_ID)

		return event['status']
开发者ID:1Server,项目名称:OneServer,代码行数:56,代码来源:cds.py

示例2: createObject

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import upnpGetString [as 别名]
	def createObject(event):
		if not event:
			return False

		if not event['status']:
			return False
				
		#Get args
		containerId = Service.upnpGetUI4(event['request'], "ContainerID")
		elements = Service.upnpGetString(event['request'], "Elements")
		elements = parseString(elements)
		
		#Get information out of elements
		item = elements.getElementsByTagName("item")[0]
		title = (item.getElementsByTagName("dc:title")[0]).childNodes
		mediaClass = (item.getElementsByTagName("upnp:class")[0]).childNodes
		
		#Create Entry Object
		entry = Entry("/upload/"+title, mediaClass, OneServerManager().uploadRoot, None, title, "", -1, None)
		
		#Create Response
		response = ""
		CDSService.didlAddHeader(response)
		CDSService.didlAddItem(response, entry._id, entry.parent._id, "false", entry.dlnaProfile, entry.title, "*:*:*:*", "0", entry.url, "")
		CDSService.didlAddFooter(response)
		
		Service.upnpAddResponse(event, CDSService.SERVICE_DIDL_RESULT, response)
		Service.upnpAddResponse(event, CDSService.SERVICE_CDS_ARG_OBJECT_ID, entry._id)
		
		return event["status"]
开发者ID:1Server,项目名称:OneServer,代码行数:32,代码来源:cds.py

示例3: search

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import upnpGetString [as 别名]
	def search(event):
		if not event:
			return False

		if not event['status']:
			return False

		index = Service.upnpGetUI4(event['request'], CDSService.SERVICE_CDS_ARG_START_INDEX)
		count = Service.upnpGetUI4(event['request'], CDSService.SERVICE_CDS_ARG_REQUEST_COUNT)
		_id = Service.upnpGetUI4(event['request'], CDSService.SERVICE_CDS_ARG_OBJECT_ID)
		search_criteria = Service.upnpGetString(event['request'], CDSService.SERVICE_CDS_ARG_SEARCH_CRIT)
		_filter = Service.upnpGetString(event['request'], CDSService.SERVICE_CDS_ARG_FILTER)
		sort_criteria = Service.upnpGetUI4(event['request'], CDSService.SERVICE_CDS_ARG_SORT_CRIT)

		if not search_criteria or not _filter:
			return False

		_core = OneServerManager()
		entry = _core.rootEntry.getChild(_id)

		if not entry and _id < 0:
			entry = _core.rootEntry

		if not entry:
			return False

		out = ""

		result_count,out = CDSService.cdsSearchDirectChildren(event, out, index, count, entry, _filter, search_criteria)

		if result_count < 0:
			return False

		Service.upnpAddResponse(event, CDSService.SERVICE_CDS_DIDL_UPDATE_ID)

		return event['status']
开发者ID:1Server,项目名称:OneServer,代码行数:38,代码来源:cds.py


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