當前位置: 首頁>>代碼示例>>Python>>正文


Python plugin.IPlugin方法代碼示例

本文整理匯總了Python中twisted.plugin.IPlugin方法的典型用法代碼示例。如果您正苦於以下問題:Python plugin.IPlugin方法的具體用法?Python plugin.IPlugin怎麽用?Python plugin.IPlugin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在twisted.plugin的用法示例。


在下文中一共展示了plugin.IPlugin方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _testCache

# 需要導入模塊: from twisted import plugin [as 別名]
# 或者: from twisted.plugin import IPlugin [as 別名]
def _testCache(self):
        cache = plugin.getCache(plugins)

        dropin = cache['testplugin']
        self.assertEquals(dropin.moduleName, 'twisted.plugins.testplugin')
        self.assertNotEquals(dropin.description.find("I'm a test drop-in."), -1)

        # Note, not the preferred way to get a plugin by its interface.
        p1 = [p for p in dropin.plugins if plugin.ITestPlugin in p.provided][0]
        self.assertIdentical(p1.dropin, dropin)
        self.assertEquals(p1.name, "TestPlugin")
        self.assertEquals(
            p1.description.strip(),
            "A plugin used solely for testing purposes.")
        self.assertEquals(p1.provided, [plugin.ITestPlugin, plugin.IPlugin])
        realPlugin = p1.load()
        self.assertIdentical(realPlugin,
                             sys.modules['twisted.plugins.testplugin'].TestPlugin)

        import twisted.plugins.testplugin as tp
        self.assertIdentical(realPlugin, tp.TestPlugin) 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:23,代碼來源:test_plugin.py

示例2: test_cache

# 需要導入模塊: from twisted import plugin [as 別名]
# 或者: from twisted.plugin import IPlugin [as 別名]
def test_cache(self):
        """
        Check that the cache returned by L{plugin.getCache} hold the plugin
        B{testplugin}, and that this plugin has the properties we expect:
        provide L{TestPlugin}, has the good name and description, and can be
        loaded successfully.
        """
        cache = plugin.getCache(self.module)

        dropin = cache[self.originalPlugin]
        self.assertEqual(dropin.moduleName,
                          'mypackage.%s' % (self.originalPlugin,))
        self.assertIn("I'm a test drop-in.", dropin.description)

        # Note, not the preferred way to get a plugin by its interface.
        p1 = [p for p in dropin.plugins if ITestPlugin in p.provided][0]
        self.assertIs(p1.dropin, dropin)
        self.assertEqual(p1.name, "TestPlugin")

        # Check the content of the description comes from the plugin module
        # docstring
        self.assertEqual(
            p1.description.strip(),
            "A plugin used solely for testing purposes.")
        self.assertEqual(p1.provided, [ITestPlugin, plugin.IPlugin])
        realPlugin = p1.load()
        # The plugin should match the class present in sys.modules
        self.assertIs(
            realPlugin,
            sys.modules['mypackage.%s' % (self.originalPlugin,)].TestPlugin)

        # And it should also match if we import it classicly
        import mypackage.testplugin as tp
        self.assertIs(realPlugin, tp.TestPlugin) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:36,代碼來源:test_plugin.py

示例3: test_cacheRepr

# 需要導入模塊: from twisted import plugin [as 別名]
# 或者: from twisted.plugin import IPlugin [as 別名]
def test_cacheRepr(self):
        """
        L{CachedPlugin} has a helpful C{repr} which contains relevant
        information about it.
        """
        cachedDropin = plugin.getCache(self.module)[self.originalPlugin]
        cachedPlugin = list(p for p in cachedDropin.plugins
                            if p.name == 'TestPlugin')[0]
        self.assertEqual(
            repr(cachedPlugin),
            "<CachedPlugin 'TestPlugin'/'mypackage.testplugin' "
            "(provides 'ITestPlugin, IPlugin')>"
        ) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:15,代碼來源:test_plugin.py

示例4: pluginFileContents

# 需要導入模塊: from twisted import plugin [as 別名]
# 或者: from twisted.plugin import IPlugin [as 別名]
def pluginFileContents(name):
    return (
        "from zope.interface import provider\n"
        "from twisted.plugin import IPlugin\n"
        "from twisted.test.test_plugin import ITestPlugin\n"
        "\n"
        "@provider(IPlugin, ITestPlugin)\n"
        "class {0}(object):\n"
        "    pass\n"
    ).format(name).encode('ascii') 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:12,代碼來源:test_plugin.py

示例5: test_cache

# 需要導入模塊: from twisted import plugin [as 別名]
# 或者: from twisted.plugin import IPlugin [as 別名]
def test_cache(self):
        """
        Check that the cache returned by L{plugin.getCache} hold the plugin
        B{testplugin}, and that this plugin has the properties we expect:
        provide L{TestPlugin}, has the good name and description, and can be
        loaded successfully.
        """
        cache = plugin.getCache(self.module)

        dropin = cache[self.originalPlugin]
        self.assertEquals(dropin.moduleName,
                          'mypackage.%s' % (self.originalPlugin,))
        self.assertIn("I'm a test drop-in.", dropin.description)

        # Note, not the preferred way to get a plugin by its interface.
        p1 = [p for p in dropin.plugins if ITestPlugin in p.provided][0]
        self.assertIdentical(p1.dropin, dropin)
        self.assertEquals(p1.name, "TestPlugin")

        # Check the content of the description comes from the plugin module
        # docstring
        self.assertEquals(
            p1.description.strip(),
            "A plugin used solely for testing purposes.")
        self.assertEquals(p1.provided, [ITestPlugin, plugin.IPlugin])
        realPlugin = p1.load()
        # The plugin should match the class present in sys.modules
        self.assertIdentical(
            realPlugin,
            sys.modules['mypackage.%s' % (self.originalPlugin,)].TestPlugin)

        # And it should also match if we import it classicly
        import mypackage.testplugin as tp
        self.assertIdentical(realPlugin, tp.TestPlugin) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:36,代碼來源:test_plugin.py

示例6: pluginFileContents

# 需要導入模塊: from twisted import plugin [as 別名]
# 或者: from twisted.plugin import IPlugin [as 別名]
def pluginFileContents(name):
    return (
        "from zope.interface import classProvides\n"
        "from twisted.plugin import IPlugin\n"
        "from twisted.test.test_plugin import ITestPlugin\n"
        "\n"
        "class %s(object):\n"
        "    classProvides(IPlugin, ITestPlugin)\n") % (name,) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:10,代碼來源:test_plugin.py

示例7: __new__

# 需要導入模塊: from twisted import plugin [as 別名]
# 或者: from twisted.plugin import IPlugin [as 別名]
def __new__(cls, name, bases, attrs):
        newcls = type.__new__(cls, name, bases, attrs)
        alsoProvides(newcls, IPlugin, IAxiomaticCommand)
        return newcls 
開發者ID:twisted,項目名稱:axiom,代碼行數:6,代碼來源:axiomatic.py

示例8: makeService

# 需要導入模塊: from twisted import plugin [as 別名]
# 或者: from twisted.plugin import IPlugin [as 別名]
def makeService(self, options):
        """
        Construct a TCPServer from a factory defined in myproject.
        """
        return HpeFactory(options["cfg"]).start_service()


# Now construct an object which *provides* the relevant interfaces
# The name of this variable is irrelevant, as long as there is *some*
# name bound to a provider of IPlugin and IServiceMakera 
開發者ID:hpe-storage,項目名稱:python-hpedockerplugin,代碼行數:12,代碼來源:hpedockerplugin_plugin.py

示例9: verify_signature

# 需要導入模塊: from twisted import plugin [as 別名]
# 或者: from twisted.plugin import IPlugin [as 別名]
def verify_signature(fname, system_gpg=False):

    verify_command = ['gpg', '--quiet']
    td = None
    status = False              # pessimism!

    try:
        if not system_gpg:
            # create temporary homedir
            td = tempfile.mkdtemp()
            verify_command.extend(['--homedir', td])

            # add Tor project-people keys to it (the ones who
            # sign releases, anyway)
            keys = []
            keys_path = os.path.join(td, 'keys')
            os.mkdir(keys_path)
            for k in pkg_resources.resource_listdir('carml', 'keys'):
                if k.endswith('.asc'):
                    keys.append(pkg_resources.resource_filename('carml', os.path.join('keys', k)))

            if len(keys) == 0:
                raise RuntimeError('Internal error: failed to find shipped keys.')

            try:
                if subprocess.check_call(['gpg', '--quiet', '--homedir', td, '--import'] + keys):
                    raise RuntimeError("Key import failed.")
            except IOError:
                raise RuntimeError("GPG verification failed; is GnuPG installed?")

        verify_command.extend(['--verify', fname])
        try:
            subprocess.check_call(verify_command)
            status = True

        except subprocess.CalledProcessError:
            print(util.colors.bold(util.colors.red("Signature verification failed.")))
            status = False

    finally:
        if td:
            shutil.rmtree(td)
    return status


# the IPlugin/getPlugin stuff from Twisted picks up any object from
# here than implements ICarmlCommand -- so we need to instantiate one 
開發者ID:meejah,項目名稱:carml,代碼行數:49,代碼來源:downloadbundle.py


注:本文中的twisted.plugin.IPlugin方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。