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


Python reflect.namedClass方法代码示例

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


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

示例1: sendRequestToServer

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedClass [as 别名]
def sendRequestToServer(
        self, txn, server, data, stream=None, streamType=None, writeStream=None
    ):
        request = self.conduitRequestClass(
            server, data, stream, streamType, writeStream
        )

        try:
            response = (yield request.doRequest(txn))
        except Exception as e:
            raise FailedCrossPodRequestError(
                "Failed cross-pod request: {}".format(e)
            )

        if response["result"] == "exception":
            raise namedClass(response["class"])(response["details"])
        elif response["result"] != "ok":
            raise FailedCrossPodRequestError(
                "Cross-pod request failed: {}".format(response)
            )
        else:
            returnValue(response.get("value")) 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:24,代码来源:conduit.py

示例2: opt_processor

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedClass [as 别名]
def opt_processor(self, proc):
        """
        `ext=class' where `class' is added as a Processor for files ending
        with `ext'.
        """
        if not isinstance(self['root'], static.File):
            raise usage.UsageError(
                "You can only use --processor after --path.")
        ext, klass = proc.split('=', 1)
        self['root'].processors[ext] = reflect.namedClass(klass) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:12,代码来源:tap.py

示例3: opt_class

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedClass [as 别名]
def opt_class(self, className):
        """
        Create a Resource subclass with a zero-argument constructor.
        """
        classObj = reflect.namedClass(className)
        self['root'] = classObj() 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:8,代码来源:tap.py

示例4: main

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedClass [as 别名]
def main(argv=None):
    log.startLogging(open('child.log', 'w'))

    if argv is None:
        argv = sys.argv[1:]
    if argv:
        klass = reflect.namedClass(argv[0])
    else:
        klass = ConsoleManhole
    runWithProtocol(klass) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:12,代码来源:stdio.py

示例5: test_namedClassLookup

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedClass [as 别名]
def test_namedClassLookup(self):
        """
        L{namedClass} should return the class object for the name it is passed.
        """
        self.assertIs(
            reflect.namedClass("twisted.test.test_reflect.Summer"),
            Summer) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:9,代码来源:test_reflect.py

示例6: opt_protocol

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedClass [as 别名]
def opt_protocol(self, value):
        """
        Protocol
        """
        try:
            protocol = namedClass(value)
        except (ValueError, AttributeError):
            raise UsageError("Unknown protocol: {0}".format(value))

        self["protocol"] = protocol 
开发者ID:apple,项目名称:ccs-twistedextensions,代码行数:12,代码来源:masterchild.py

示例7: wrappedServiceMaker

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedClass [as 别名]
def wrappedServiceMaker(self):
        if not hasattr(self, "_wrappedServiceMaker"):
            makerClass = namedClass(self.className)
            maker = makerClass(*self.args, **self.kwargs)
            self._wrappedServiceMaker = maker

        return self._wrappedServiceMaker 
开发者ID:apple,项目名称:ccs-twistedextensions,代码行数:9,代码来源:masterchild.py

示例8: migrateAutoSchedule

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedClass [as 别名]
def migrateAutoSchedule(config, directory):
    # Fetch the autoSchedule assignments from resourceinfo.sqlite and store
    # the values in augments
    augmentService = None
    serviceClass = {
        "xml": "twistedcaldav.directory.augment.AugmentXMLDB",
    }
    augmentClass = namedClass(serviceClass[config.AugmentService.type])
    try:
        augmentService = augmentClass(**config.AugmentService.params)
    except:
        log.error("Could not start augment service")

    if augmentService:
        augmentRecords = []
        dbPath = os.path.join(config.DataRoot, ResourceInfoDatabase.dbFilename)
        if os.path.exists(dbPath):
            log.warn("Migrating auto-schedule settings")
            resourceInfoDatabase = ResourceInfoDatabase(config.DataRoot)
            results = resourceInfoDatabase._db_execute(
                "select GUID, AUTOSCHEDULE from RESOURCEINFO"
            )
            for uid, autoSchedule in results:
                if uid is not None:
                    record = yield directory.recordWithUID(uid)
                    if record is not None:
                        augmentRecord = (
                            yield augmentService.getAugmentRecord(
                                uid,
                                directory.recordTypeToOldName(record.recordType)
                            )
                        )
                        augmentRecord.autoScheduleMode = (
                            "automatic" if autoSchedule else "default"
                        )
                        augmentRecords.append(augmentRecord)

            if augmentRecords:
                yield augmentService.addAugmentRecords(augmentRecords)
            log.warn("Migrated {len} auto-schedule settings", len=len(augmentRecords)) 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:42,代码来源:upgrade.py

示例9: serviceMakerProperty

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedClass [as 别名]
def serviceMakerProperty(propname):
    def getProperty(self):
        return getattr(reflect.namedClass(self.serviceMakerClass), propname)

    return property(getProperty) 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:7,代码来源:caldav.py

示例10: makeService

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedClass [as 别名]
def makeService(self, options):
        if self._serviceMaker is None:
            self._serviceMaker = reflect.namedClass(self.serviceMakerClass)()

        return self._serviceMaker.makeService(options) 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:7,代码来源:caldav.py

示例11: get_plugins

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedClass [as 别名]
def get_plugins(self):
        if self.sysinfo_plugins is None:
            include = ALL_PLUGINS
        else:
            include = self.get_plugin_names(self.sysinfo_plugins)
        if self.exclude_sysinfo_plugins is None:
            exclude = []
        else:
            exclude = self.get_plugin_names(self.exclude_sysinfo_plugins)
        plugins = [x for x in include if x not in exclude]
        return [namedClass("landscape.sysinfo.%s.%s"
                           % (plugin_name.lower(), plugin_name))()
                for plugin_name in plugins] 
开发者ID:CanonicalLtd,项目名称:landscape-client,代码行数:15,代码来源:deployment.py

示例12: get_plugins

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedClass [as 别名]
def get_plugins(self):
        """Return instances of all the plugins enabled in the configuration."""
        return [namedClass("landscape.client.manager.%s.%s"
                           % (plugin_name.lower(), plugin_name))()
                for plugin_name in self.config.plugin_factories] 
开发者ID:CanonicalLtd,项目名称:landscape-client,代码行数:7,代码来源:service.py

示例13: get_plugins

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedClass [as 别名]
def get_plugins(self):
        return [namedClass("landscape.client.monitor.%s.%s"
                           % (plugin_name.lower(), plugin_name))()
                for plugin_name in self.config.plugin_factories] 
开发者ID:CanonicalLtd,项目名称:landscape-client,代码行数:6,代码来源:service.py

示例14: opt_processor

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedClass [as 别名]
def opt_processor(self, proc):
        """
        `ext=class' where `class' is added as a Processor for files ending
        with `ext'.
        """
        if not isinstance(self['root'], static.File):
            raise usage.UsageError("You can only use --processor after --path.")
        ext, klass = proc.split('=', 1)
        self['root'].processors[ext] = reflect.namedClass(klass) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:11,代码来源:tap.py

示例15: main

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedClass [as 别名]
def main(argv=None):
    log.startLogging(file('child.log', 'w'))

    if argv is None:
        argv = sys.argv[1:]
    if argv:
        klass = reflect.namedClass(argv[0])
    else:
        klass = ConsoleManhole
    runWithProtocol(klass) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:12,代码来源:stdio.py


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