本文整理汇总了Python中twisted.python.filepath.FilePath.get_child方法的典型用法代码示例。如果您正苦于以下问题:Python FilePath.get_child方法的具体用法?Python FilePath.get_child怎么用?Python FilePath.get_child使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.python.filepath.FilePath
的用法示例。
在下文中一共展示了FilePath.get_child方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestContentDirectoryServer
# 需要导入模块: from twisted.python.filepath import FilePath [as 别名]
# 或者: from twisted.python.filepath.FilePath import get_child [as 别名]
class TestContentDirectoryServer(unittest.TestCase):
def setUp(self):
self.tmp_content = FilePath('tmp_content_coherence-%d'%os.getpid())
f = self.tmp_content.get_child()('content')
audio = f.get_child()('audio')
f.get_child()('images').makedirs()
f.get_child()('video').makedirs()
album = audio.get_child()('album-1')
album.makedirs()
album.get_child()('track-1.mp3').touch()
album.get_child()('track-2.mp3').touch()
album = audio.get_child()('album-2')
album.makedirs()
album.get_child()('track-1.ogg').touch()
album.get_child()('track-2.ogg').touch()
louie.reset()
self.coherence = Coherence({'unittest':'yes','logmode':'debug','subsystem_log':{'controlpoint':'error',
'action':'error',
'soap':'error'},'controlpoint':'yes'})
self.uuid = UUID()
p = self.coherence.add_plugin('FSStore',
name='MediaServer-%d'%os.getpid(),
content=self.tmp_content.path,
uuid=str(self.uuid))
def tearDown(self):
self.tmp_content.remove()
def cleaner(r):
self.coherence.clear()
return r
dl = self.coherence.shutdown()
dl.addBoth(cleaner)
return dl
def test_Browse(self):
""" tries to find the activated FSStore backend
and browses its root.
"""
d = Deferred()
def the_result(mediaserver):
try:
self.assertEqual(str(self.uuid), mediaserver.udn)
except:
d.errback()
def got_second_answer(r,childcount):
try:
self.assertEqual(int(r['TotalMatches']), childcount)
d.callback(None)
except:
d.errback()
def got_first_answer(r):
try:
self.assertEqual(int(r['TotalMatches']), 1)
except:
d.errback()
didl = DIDLLite.DIDLElement.fromString(r['Result'])
item = didl.getItems()[0]
try:
self.assertEqual(item.childCount, 3)
except:
d.errback()
call = mediaserver.client.content_directory.browse(object_id=item.id,
process_result=False)
call.addCallback(got_second_answer,item.childCount)
return call
call = mediaserver.client.content_directory.browse(process_result=False)
call.addCallback(got_first_answer)
self.coherence.ctrl.add_query(DeviceQuery('uuid', str(self.uuid), the_result, timeout=10, oneshot=True))
return d
def test_Browse_Metadata(self):
""" tries to find the activated FSStore backend
and requests metadata for ObjectID 0.
"""
d = Deferred()
def the_result(mediaserver):
try:
self.assertEqual(str(self.uuid), mediaserver.udn)
except:
d.errback()
def got_first_answer(r):
try:
self.assertEqual(int(r['TotalMatches']), 1)
except:
d.errback()
return
didl = DIDLLite.DIDLElement.fromString(r['Result'])
item = didl.getItems()[0]
#.........这里部分代码省略.........