本文整理汇总了Python中txtorcon.TorControlProtocol.get_info_single方法的典型用法代码示例。如果您正苦于以下问题:Python TorControlProtocol.get_info_single方法的具体用法?Python TorControlProtocol.get_info_single怎么用?Python TorControlProtocol.get_info_single使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类txtorcon.TorControlProtocol
的用法示例。
在下文中一共展示了TorControlProtocol.get_info_single方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ProtocolTests
# 需要导入模块: from txtorcon import TorControlProtocol [as 别名]
# 或者: from txtorcon.TorControlProtocol import get_info_single [as 别名]
#.........这里部分代码省略.........
self.protocol._set_valid_events('CIRC')
self.protocol.add_event_listener(
'CIRC',
CallbackChecker("1000 EXTENDED moria1,moria2")
)
self.send(b"250 OK")
d = self.protocol.get_info("a")
d.addCallback(CallbackChecker({'a': 'one'})).addErrback(self.fail)
self.send(b"250-a=one")
self.send(b"250 OK")
self.send(b"650 CIRC 1000 EXTENDED moria1,moria2")
return d
def test_notify_error(self):
self.protocol._set_valid_events('CIRC')
self.send(b"650 CIRC 1000 EXTENDED moria1,moria2")
def test_getinfo(self):
d = self.protocol.get_info("version")
d.addCallback(CallbackChecker({'version': '0.2.2.34'}))
d.addErrback(self.fail)
self.send(b"250-version=0.2.2.34")
self.send(b"250 OK")
self.assertEqual(
self.transport.value(),
b"GETINFO version\r\n",
)
return d
def test_getinfo_single(self):
d = self.protocol.get_info_single("version")
d.addCallback(CallbackChecker('0.2.2.34'))
d.addErrback(self.fail)
self.send(b"250-version=0.2.2.34")
self.send(b"250 OK")
self.assertEqual(
self.transport.value(),
b"GETINFO version\r\n",
)
return d
def test_getinfo_for_descriptor(self):
descriptor_info = b"""250+desc/name/moria1=
router moria1 128.31.0.34 9101 0 9131
platform Tor 0.2.5.0-alpha-dev on Linux
protocols Link 1 2 Circuit 1
published 2013-07-05 23:48:52
fingerprint 9695 DFC3 5FFE B861 329B 9F1A B04C 4639 7020 CE31
uptime 1818933
bandwidth 512000 62914560 1307929
extra-info-digest 17D0142F6EBCDF60160EB1794FA6C9717D581F8C
caches-extra-info
onion-key
-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBALzd4bhz1usB7wpoaAvP+BBOnNIk7mByAKV6zvyQ0p1M09oEmxPMc3qD
AAm276oJNf0eq6KWC6YprzPWFsXEIdXSqA6RWXCII1JG/jOoy6nt478BkB8TS9I9
1MJW27ppRaqnLiTmBmM+qzrsgJGwf+onAgUKKH2GxlVgahqz8x6xAgMBAAE=
-----END RSA PUBLIC KEY-----
signing-key
-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBALtJ9uD7cD7iHjqNA3AgsX9prES5QN+yFQyr2uOkxzhvunnaf6SNhzWW