本文整理汇总了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"))
示例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)
示例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()
示例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)
示例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)
示例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
示例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
示例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))
示例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)
示例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)
示例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]
示例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]
示例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]
示例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)
示例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)