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


Python service.IServiceCollection方法代码示例

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


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

示例1: testSimpleInternet

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceCollection [as 别名]
def testSimpleInternet(self):
        # XXX - replace this test with one that does the same thing, but
        # with no web dependencies.
        if not gotMicrodom:
            raise unittest.SkipTest("Need twisted.web to run this test.")
        s = "(dp0\nS'udpConnectors'\np1\n(lp2\nsS'unixConnectors'\np3\n(lp4\nsS'twisted.internet.app.Application.persistenceVersion'\np5\nI12\nsS'name'\np6\nS'web'\np7\nsS'sslConnectors'\np8\n(lp9\nsS'sslPorts'\np10\n(lp11\nsS'tcpPorts'\np12\n(lp13\n(I8080\n(itwisted.web.server\nSite\np14\n(dp16\nS'resource'\np17\n(itwisted.web.demo\nTest\np18\n(dp19\nS'files'\np20\n(lp21\nsS'paths'\np22\n(dp23\nsS'tmpl'\np24\n(lp25\nS'\\n    Congratulations, twisted.web appears to work!\\n    <ul>\\n    <li>Funky Form:\\n    '\np26\naS'self.funkyForm()'\np27\naS'\\n    <li>Exception Handling:\\n    '\np28\naS'self.raiseHell()'\np29\naS'\\n    </ul>\\n    '\np30\nasS'widgets'\np31\n(dp32\nsS'variables'\np33\n(dp34\nsS'modules'\np35\n(lp36\nsS'children'\np37\n(dp38\nsbsS'logPath'\np39\nNsS'timeOut'\np40\nI43200\nsS'sessions'\np41\n(dp42\nsbI5\nS''\np43\ntp44\nasS'unixPorts'\np45\n(lp46\nsS'services'\np47\n(dp48\nsS'gid'\np49\nI1000\nsS'tcpConnectors'\np50\n(lp51\nsS'extraConnectors'\np52\n(lp53\nsS'udpPorts'\np54\n(lp55\nsS'extraPorts'\np56\n(lp57\nsS'persistStyle'\np58\nS'pickle'\np59\nsS'uid'\np60\nI1000\ns."
        d = pickle.loads(s)
        a = Dummy()
        a.__dict__ = d
        appl = compat.convert(a)
        self.assertEqual(service.IProcess(appl).uid, 1000)
        self.assertEqual(service.IProcess(appl).gid, 1000)
        self.assertEqual(service.IService(appl).name, "web")
        services = list(service.IServiceCollection(appl))
        self.assertEqual(len(services), 1)
        s = services[0]
        self.assertEqual(s.parent, service.IServiceCollection(appl))
        self.assert_(s.privileged)
        self.assert_(isinstance(s, internet.TCPServer))
        args = s.args
        self.assertEqual(args[0], 8080)
        self.assertEqual(args[3], '') 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:24,代码来源:test_application.py

示例2: testSimpleUNIX

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceCollection [as 别名]
def testSimpleUNIX(self):
        # XXX - replace this test with one that does the same thing, but
        # with no web dependencies.
        if not interfaces.IReactorUNIX(reactor, None):
            raise unittest.SkipTest, "This reactor does not support UNIX domain sockets"
        if not gotMicrodom:
            raise unittest.SkipTest("Need twisted.web to run this test.")
        s = "(dp0\nS'udpConnectors'\np1\n(lp2\nsS'unixConnectors'\np3\n(lp4\nsS'twisted.internet.app.Application.persistenceVersion'\np5\nI12\nsS'name'\np6\nS'web'\np7\nsS'sslConnectors'\np8\n(lp9\nsS'sslPorts'\np10\n(lp11\nsS'tcpPorts'\np12\n(lp13\nsS'unixPorts'\np14\n(lp15\n(S'/home/moshez/.twistd-web-pb'\np16\n(itwisted.spread.pb\nBrokerFactory\np17\n(dp19\nS'objectToBroker'\np20\n(itwisted.web.distrib\nResourcePublisher\np21\n(dp22\nS'twisted.web.distrib.ResourcePublisher.persistenceVersion'\np23\nI2\nsS'site'\np24\n(itwisted.web.server\nSite\np25\n(dp26\nS'resource'\np27\n(itwisted.web.static\nFile\np28\n(dp29\nS'ignoredExts'\np30\n(lp31\nsS'defaultType'\np32\nS'text/html'\np33\nsS'registry'\np34\n(itwisted.web.static\nRegistry\np35\n(dp36\nS'twisted.web.static.Registry.persistenceVersion'\np37\nI1\nsS'twisted.python.components.Componentized.persistenceVersion'\np38\nI1\nsS'_pathCache'\np39\n(dp40\nsS'_adapterCache'\np41\n(dp42\nS'twisted.internet.interfaces.IServiceCollection'\np43\n(itwisted.internet.app\nApplication\np44\n(dp45\ng1\ng2\nsg3\ng4\nsg5\nI12\nsg6\ng7\nsg8\ng9\nsg10\ng11\nsg12\ng13\nsg14\ng15\nsS'extraPorts'\np46\n(lp47\nsS'gid'\np48\nI1053\nsS'tcpConnectors'\np49\n(lp50\nsS'extraConnectors'\np51\n(lp52\nsS'udpPorts'\np53\n(lp54\nsS'services'\np55\n(dp56\nsS'persistStyle'\np57\nS'pickle'\np58\nsS'delayeds'\np59\n(lp60\nsS'uid'\np61\nI1053\nsbssbsS'encoding'\np62\nNsS'twisted.web.static.File.persistenceVersion'\np63\nI6\nsS'path'\np64\nS'/home/moshez/public_html.twistd'\np65\nsS'type'\np66\ng33\nsS'children'\np67\n(dp68\nsS'processors'\np69\n(dp70\nS'.php3'\np71\nctwisted.web.twcgi\nPHP3Script\np72\nsS'.rpy'\np73\nctwisted.web.script\nResourceScript\np74\nsS'.php'\np75\nctwisted.web.twcgi\nPHPScript\np76\nsS'.cgi'\np77\nctwisted.web.twcgi\nCGIScript\np78\nsS'.epy'\np79\nctwisted.web.script\nPythonScript\np80\nsS'.trp'\np81\nctwisted.web.trp\nResourceUnpickler\np82\nssbsS'logPath'\np83\nNsS'sessions'\np84\n(dp85\nsbsbsS'twisted.spread.pb.BrokerFactory.persistenceVersion'\np86\nI3\nsbI5\nI438\ntp87\nasg55\ng56\nsg48\nI1053\nsg49\ng50\nsg51\ng52\nsg53\ng54\nsg46\ng47\nsg57\ng58\nsg61\nI1053\nsg59\ng60\ns."
        d = pickle.loads(s)
        a = Dummy()
        a.__dict__ = d
        appl = compat.convert(a)
        self.assertEqual(service.IProcess(appl).uid, 1053)
        self.assertEqual(service.IProcess(appl).gid, 1053)
        self.assertEqual(service.IService(appl).name, "web")
        services = list(service.IServiceCollection(appl))
        self.assertEqual(len(services), 1)
        s = services[0]
        self.assertEqual(s.parent, service.IServiceCollection(appl))
        self.assert_(s.privileged)
        self.assert_(isinstance(s, internet.UNIXServer))
        args = s.args
        self.assertEqual(args[0], '/home/moshez/.twistd-web-pb') 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:25,代码来源:test_application.py

示例3: testSimpleService

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceCollection [as 别名]
def testSimpleService(self):
        a = DummyApp()
        a.__dict__ = {'udpConnectors': [], 'unixConnectors': [],
                      '_listenerDict': {}, 'name': 'dummy',
                      'sslConnectors': [], 'unixPorts': [],
                      '_extraListeners': {}, 'sslPorts': [], 'tcpPorts': [],
                      'services': {}, 'gid': 0, 'tcpConnectors': [],
                      'extraConnectors': [], 'udpPorts': [], 'extraPorts': [],
                      'uid': 0}
        s = service.Service()
        s.setName("lala")
        s.setServiceParent(a)
        appl = compat.convert(a)
        services = list(service.IServiceCollection(appl))
        self.assertEqual(len(services), 1)
        s1 = services[0]
        self.assertEqual(s, s1) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:19,代码来源:test_application.py

示例4: test_applicationComponents

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceCollection [as 别名]
def test_applicationComponents(self):
        """
        Check L{twisted.application.service.Application} instantiation.
        """
        app = Application('app-name')

        self.assertTrue(verifyObject(IService, IService(app)))
        self.assertTrue(
            verifyObject(IServiceCollection, IServiceCollection(app)))
        self.assertTrue(verifyObject(IProcess, IProcess(app)))
        self.assertTrue(verifyObject(IPersistable, IPersistable(app))) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:13,代码来源:test_service.py

示例5: testApplicationAsParent

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceCollection [as 别名]
def testApplicationAsParent(self):
        s = service.Service()
        p = service.Application("")
        s.setServiceParent(p)
        self.assertEqual(list(service.IServiceCollection(p)), [s])
        self.assertEqual(s.parent, service.IServiceCollection(p)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:8,代码来源:test_application.py

示例6: testMultiService

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceCollection [as 别名]
def testMultiService(self):
        self.assertTrue(service.IService.providedBy(service.MultiService()))
        self.assertTrue(service.IServiceCollection.providedBy(
                        service.MultiService())) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:6,代码来源:test_application.py

示例7: testServiceComponent

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceCollection [as 别名]
def testServiceComponent(self):
        a = service.Application("hello")
        self.assertIs(service.IService(a), service.IServiceCollection(a))
        self.assertEqual(service.IService(a).name, "hello")
        self.assertIsNone(service.IService(a).parent) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:7,代码来源:test_application.py

示例8: testApplicationAsParent

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceCollection [as 别名]
def testApplicationAsParent(self):
        s = service.Service()
        p = service.Application("")
        s.setServiceParent(p)
        self.failUnlessEqual(list(service.IServiceCollection(p)), [s])
        self.failUnlessEqual(s.parent, service.IServiceCollection(p)) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:8,代码来源:test_application.py

示例9: testMultiService

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceCollection [as 别名]
def testMultiService(self):
        self.assert_(service.IService.providedBy(service.MultiService()))
        self.assert_(service.IServiceCollection.providedBy(service.MultiService())) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:5,代码来源:test_application.py

示例10: testServiceComponent

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceCollection [as 别名]
def testServiceComponent(self):
        a = service.Application("hello")
        self.assert_(service.IService(a) is service.IServiceCollection(a))
        self.assertEqual(service.IService(a).name, "hello")
        self.assertEqual(service.IService(a).parent, None) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:7,代码来源:test_application.py

示例11: addToApplication

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceCollection [as 别名]
def addToApplication(ser, name, append, procname, type, encrypted, uid, gid):
    if append and os.path.exists(append):
        a = service.loadApplication(append, 'pickle', None)
    else:
        a = service.Application(name, uid, gid)
    if procname:
        service.IProcess(a).processName = procname
    ser.setServiceParent(service.IServiceCollection(a))
    sob.IPersistable(a).setStyle(type)
    passphrase = app.getSavePassphrase(encrypted)
    if passphrase:
        append = None
    sob.IPersistable(a).save(filename=append, passphrase=passphrase) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:15,代码来源:mktap.py

示例12: __init__

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceCollection [as 别名]
def __init__(self, app):
        self.app = service.IServiceCollection(app) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:4,代码来源:compat.py

示例13: convert

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceCollection [as 别名]
def convert(oldApp):
    '''Convert an C{i.app.Application} to a C{application.service.Application}

    @type oldApp: C{twisted.internet.app.Application}
    @rtype C{twisted.application.service.Application}

    This function might damage oldApp beyond repair: services
    that other parts might be depending on might be missing.
    It is not safe to use oldApp after it has been converted.
    In case this behaviour is not desirable, pass a deep copy
    of the old application
    '''
    ret = service.Application(oldApp.name, getattr(oldApp, "uid", None), getattr(oldApp, "gid", None))
    c = service.IServiceCollection(ret)
    service.IProcess(ret).processName = oldApp.processName
    for (pList, klass) in [(oldApp.extraPorts, internet.GenericServer),
                           (oldApp.extraConnectors, internet.GenericClient),]:
        for (portType, args, kw) in pList:
            klass(portType, *args, **kw).setServiceParent(c)
    for (name, klass) in _mapping:
        for args in getattr(oldApp, name):
            klass(*args).setServiceParent(c)
    for s in c:
        if hasattr(s, 'privileged'):
            s.privileged = 1
    for s in oldApp.services.values():
        if not service.IService.providedBy(s):
            s.serviceParent = None
            s = _NewService(s)
            s.setServiceParent(IOldApplication(c))
        else:
            s.serviceParent = None
            s.setServiceParent(c)
    return ret 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:36,代码来源:compat.py

示例14: storeServiceSpecialCase

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceCollection [as 别名]
def storeServiceSpecialCase(st, pups):
    """
    Adapt a store to L{IServiceCollection}.

    @param st: The L{Store} to adapt.
    @param pups: A list of L{IServiceCollection} powerups on C{st}.

    @return: An L{IServiceCollection} which has all of C{pups} as children.
    """
    if st.parent is not None:
        # If for some bizarre reason we're starting a substore's service, let's
        # just assume that its parent is running its upgraders, rather than
        # risk starting the upgrader run twice. (XXX: it *IS* possible to
        # figure out whether we need to or not, I just doubt this will ever
        # even happen in practice -- fix here if it does)
        return serviceSpecialCase(st, pups)
    if st._axiom_service is not None:
        # not new, don't add twice.
        return st._axiom_service

    collection = serviceSpecialCase(st, pups)

    st._upgradeService.setServiceParent(collection)

    if st.dbdir is not None:
        from axiom import batch
        batcher = batch.BatchProcessingControllerService(st)
        batcher.setServiceParent(collection)

    scheduler = iaxiom.IScheduler(st)
    # If it's an old database, we might get a SubScheduler instance.  It has no
    # setServiceParent method.
    setServiceParent = getattr(scheduler, 'setServiceParent', None)
    if setServiceParent is not None:
        setServiceParent(collection)

    return collection 
开发者ID:twisted,项目名称:axiom,代码行数:39,代码来源:store.py


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