本文整理汇总了Python中service.Service.upnpAddResponse方法的典型用法代码示例。如果您正苦于以下问题:Python Service.upnpAddResponse方法的具体用法?Python Service.upnpAddResponse怎么用?Python Service.upnpAddResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类service.Service
的用法示例。
在下文中一共展示了Service.upnpAddResponse方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createObject
# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import upnpAddResponse [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"]
示例2: cmsGetCurrentConnectionIDs
# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import upnpAddResponse [as 别名]
def cmsGetCurrentConnectionIDs(event):
if not event:
return False
Service.upnpAddResponse(event, CMSService.SERVICE_CMS_ARG_CONNECTION_IDS, '')
return event['status']
示例3: msrIsValidated
# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import upnpAddResponse [as 别名]
def msrIsValidated(event):
if not event:
return False
# Sends a fake authorization.
Service.upnpAddResponse(event, MSRService.SERVICE_MSR_ARG_RESULT, MSRService.SERVICE_MSR_STATUS_OK)
return event.status
示例4: browse
# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import upnpAddResponse [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']
示例5: cmsGetProtocolInfo
# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import upnpAddResponse [as 别名]
def cmsGetProtocolInfo(event):
if not event:
return False
respText = ''
index = 0
for mimeType in mimeTypeList:
respText = respText + Service.mimeGetProtocol(mimeType)
index = index + 1
if index != len(mimeTypeList):
respText = respText + ","
Service.upnpAddResponse(event, CMSService.SERVICE_CMS_ARG_SOURCE, respText)
Service.upnpAddResponse(event, CMSService.SERVICE_CMS_ARG_SINK, '')
return event['status']
示例6: search
# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import upnpAddResponse [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']
示例7: cdsBrowseMetadata
# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import upnpAddResponse [as 别名]
def cdsBrowseMetadata(event, buf, index, count, entry, _filter):
if entry is None:
return 0,buf
resultCount = 0
if entry.children is None: # File
protocol = ""
dlna = DLNAInterface()
protocol = dlna.dlna_write_protocol_info(dlna.dlna_protocol_info_type_t['DLNA_PROTOCOL_INFO_TYPE_HTTP'],
dlna.dlna_org_play_speed_t['DLNA_ORG_PLAY_SPEED_NORMAL'],
dlna.dlna_org_conversion_t['DLNA_ORG_CONVERSION_NONE'],
dlna.dlna_org_operation_t['DLNA_ORG_OPERATION_RANGE'],
dlna.flags,
entry.dlnaProfile)
buf = CDSService.didlAddHeader(buf)
buf = CDSService.didlAddItem(buf,
entry._id,
entry.parent._id if entry.parent is not None else -1,
"false",
dlna.dlna_profile_upnp_object_item(entry.dlnaProfile),
entry.title,
protocol,
entry.size,
entry.url,
_filter)
buf = CDSService.didlAddFooter(buf)
for a in range(index, min(index+count, -1)):
resultCount += 1
else: #Directory
buf = CDSService.didlAddHeader(buf)
buf = CDSService.didlAddContainer(buf,
entry._id,
entry.parent._id if entry.parent is not None else -1,
len(entry.children),
"true",
"true",
entry.title,
CDSService.CONTAINER_MIME)
buf = CDSService.didlAddFooter(buf)
resultCount = 1
Service.upnpAddResponse(event, CDSService.SERVICE_CDS_DIDL_RESULT, buf)
Service.upnpAddResponse(event, CDSService.SERVICE_CDS_DIDL_NUM_RETURNED, "1")
Service.upnpAddResponse(event, CDSService.SERVICE_CDS_DIDL_TOTAL_MATCH, "1")
return resultCount,buf
示例8: cdsBrowseDirectChildren
# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import upnpAddResponse [as 别名]
def cdsBrowseDirectChildren(event, buf, index, count, entry, _filter):
resultCount = 0
if entry.children is None: #Its a file
return -1,buf
buf = CDSService.didlAddHeader(buf)
#If index = 0 and count = 0 then all children must be returned
if (index is 0) and (count is 0):
count = len(entry.children)
for child in entry.children:
if (count is 0) or (resultCount < count):
if child.children is not None: #Container
buf = CDSService.didlAddContainer(buf, child._id,
child.parent._id if child.parent is not None else -1,
len(child.children), "true", None,
child.title,
CDSService.CONTAINER_MIME)
else: #Item
manager = OneServerManager()
manager.log.debug("child=%s, child.children=%s" % (child,child.children))
manager.log.debug("child.fullpath=%s" % child.fullPath)
manager.log.debug("child.dlnaProfile=%s" % child.dlnaProfile.contents.mime)
dlna = DLNAInterface()
protocol = dlna.dlna_write_protocol_info(dlna.dlna_protocol_info_type_t['DLNA_PROTOCOL_INFO_TYPE_HTTP'],
dlna.dlna_org_play_speed_t['DLNA_ORG_PLAY_SPEED_NORMAL'],
dlna.dlna_org_conversion_t['DLNA_ORG_CONVERSION_NONE'],
dlna.dlna_org_operation_t['DLNA_ORG_OPERATION_RANGE'],
dlna.flags,
child.dlnaProfile)
buf = CDSService.didlAddItem(buf, child._id,
child.parent._id if child.parent is not None else -1,
"true", dlna.dlna_profile_upnp_object_item(child.dlnaProfile),
child.title, protocol,
child.size, child.url, _filter)
resultCount = resultCount + 1
buf = CDSService.didlAddFooter(buf)
Service.upnpAddResponse(event, CDSService.SERVICE_CDS_DIDL_RESULT, buf)
Service.upnpAddResponse(event, CDSService.SERVICE_CDS_DIDL_NUM_RETURNED, str(resultCount))
Service.upnpAddResponse(event, CDSService.SERVICE_CDS_DIDL_TOTAL_MATCH, str(len(entry.children)))
return resultCount, buf
示例9: cdsSearchDirectChildren
# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import upnpAddResponse [as 别名]
def cdsSearchDirectChildren(event, buf, index, count, entry, _filter, searchCriteria):
if entry.children is None:
return -1,buf
resultCount = 0
buf = CDSService.didlAddHeader(buf)
if (index is 0) and (count is 0):
count = len(entry.children)
for child in entry.children:
if(count is 0) or (resultCount < count):
if child.children is not None: #Container
temp,buf = CDSService.cdsSearchDirectChildrenRecursive(buf,
0 if count is 0 else count - resultCount,
child, _filter, searchCriteria)
resultCount += temp
else: #File
if CDSService.matchesSearch(searchCriteria, child):
dlna = libDLNA.DLNAInterface()
protocol = dlna.dlna_write_protocol_info(dlna.dlna_protocol_info_type_t['DLNA_PROTOCOL_INFO_TYPE_HTTP'],
dlna.dlna_org_play_speed_t['DLNA_ORG_PLAY_SPEED_NORMAL'],
dlna.dlna_org_conversion_t['DLNA_ORG_CONVERSION_NONE'],
dlna.dlna_org_operation_t['DLNA_ORG_OPERATION_RANGE'],
dlna.flags,
entry.dlnaProfile)
buf = CDSService.didlAddItem(buf, child._id,
child.parent._id if child.parent is not None else -1,
"true", dlna.dlna_profile_upnp_object_item(child.dlnaProfile),
child.title, protocol,
child.size, child.url, _filter)
resultCount += 1
buf = CDSService.didlAddFooter(buf)
Service.upnpAddResponse(event, CDSService.SERVICE_CDS_DIDL_RESULT, buf)
Service.upnpAddResponse(event, CDSService.SERVICE_CDS_DIDL_NUM_RETURNED, str(resultCount))
Service.upnpAddResponse(event, CDSService.SERVICE_CDS_DIDL_TOTAL_MATCH, str(resultCount))
return resultCount,buf
示例10: getSystemUpdateId
# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import upnpAddResponse [as 别名]
def getSystemUpdateId(event):
Service.upnpAddResponse(event, CDSService.SERVICE_CDS_ARG_UPDATE_ID, CDSService.SERVICE_CDS_ROOT_OBJECT_ID)
return event['status']
示例11: getSortCapabilities
# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import upnpAddResponse [as 别名]
def getSortCapabilities(event):
Service.upnpAddResponse(event, CDSService.SERVICE_CDS_ARG_SORT_CAPS, "")
return event['status']
示例12: getSearchCapabilities
# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import upnpAddResponse [as 别名]
def getSearchCapabilities(event):
manager = OneServerManager()
manager.log.debug("getSearchCapabilities event=%s" % event)
Service.upnpAddResponse(event, CDSService.SERVICE_CDS_ARG_SEARCH_CAPS, "")
manager.log.debug("left addResponse")
return event['status']
示例13: cmsGetCurrentConnectionInfo
# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import upnpAddResponse [as 别名]
def cmsGetCurrentConnectionInfo(event):
if not event:
return False
Service.upnpAddResponse(event, CMSService.SERVICE_CMS_ARG_CONNECTION_ID, CMSService.SERVICE_CMS_DEFAULT_CON_ID)
Service.upnpAddResponse(event, CMSService.SERVICE_CMS_ARG_RCS_ID, CMSService.SERVICE_CMS_UNKNOWN_ID)
Service.upnpAddResponse(event, CMSService.SERVICE_CMS_ARG_TRANSPORT_ID, CMSService.SERVICE_CMS_UNKNOWN_ID)
for i in range(len(mimeTypeList)):
mimeType = mimeTypeList[i]
protocol = Service.mimeGetProtocol(mimeType)
Service.upnpAddResponse(event, CMSService.SERVICE_CMS_ARG_PROT_INFO, protocol)
Service.upnpAddResponse(event, CMSService.SERVICE_CMS_ARG_PEER_CON_MANAGER, '')
Service.upnpAddResponse(event, CMSService.SERVICE_CMS_ARG_PEER_CON_ID, CMSService.SERVICE_CMS_UNKNOWN_ID)
Service.upnpAddResponse(event, CMSService.SERVICE_CMS_ARG_DIRECTION, CMSService.SERVICE_CMS_OUTPUT)
Service.upnpAddResponse(event, CMSService.SERVICE_CMS_ARG_STATUS, CMSService.SERVICE_CMS_STATUS_OK)
return event['status']