本文整理汇总了Python中twisted.python.rebuild.rebuild函数的典型用法代码示例。如果您正苦于以下问题:Python rebuild函数的具体用法?Python rebuild怎么用?Python rebuild使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rebuild函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: privmsg
def privmsg(self, user, channel, msg):
"""Handles user messages from channels
This hooks every privmsg sent to the channel and sends the commands off
to cmds.dispatch to process, then replies to the channel accordingly.
The @reload command needs to be handled here though, as it allows edits
to be made to trailbot without disconnecting from IRC. It should get a
list from cmds.dispatch if it needs to pm someone, otherwise it gets a
string back and msgs the channel.
"""
user = user.split('!', 1)[0]
if msg == '%reload':
rebuild.rebuild(cmds)
rebuild.rebuild(voice)
self.msg(channel, 'reloaded and ready to go')
else:
reply = cmds.dispatch(user, msg)
if type(reply) is types.StringType:
self.msg(channel, reply)
else:
if len(reply):
self.msg(channel, reply[0])
for trip in reply[1:]:
self.msg(user, trip)
示例2: loadModule
def loadModule(self, name):
for module in getPlugins(IBotModule, heufybot.modules):
if module.name and module.name.lower() == name.lower():
rebuild(importlib.import_module(module.__module__))
self._loadModuleData(module)
return module.name
raise ModuleLoaderError(name, "The module could not be found.", ModuleLoadType.LOAD)
示例3: testRebuildInteraction
def testRebuildInteraction(self):
from twisted.persisted import dirdbm
from twisted.python import rebuild
s = dirdbm.Shelf("dirdbm.rebuild.test")
s["key"] = "value"
rebuild.rebuild(dirdbm)
示例4: irc_PRIVMSG
def irc_PRIVMSG(self, line):
msg = line.args[1]
if line.args[0].startswith("#"):
if msg[1:].startswith(self.nick):
if msg[1+len(self.nick)+1:].strip() == "pointer":
answerURI = self.factory.rootURI + line.args[0][1:].lower() + '/' + line.ztime.rstrip("Z").replace("T", "#")
answer = "That line is " + answerURI
self.sendLine(Line("NOTICE", [line.args[0], answer]))
if line.args[0] != self.nick:
return False # not to us
if parseprefix(line.prefix)[0] != self.factory.admin:
return False # not from admin
if msg == "+rebuild":
try:
rebuild(sioclogbot)
info("rebuilt")
except:
print_exc()
elif msg.startswith("+do "):
try:
self.sendLine(Line(linestr=msg[len("+do "):]))
except:
print_exc()
return False # log
示例5: remote_registerClasses
def remote_registerClasses(self, *args):
"""
Instructs my broker to register the classes specified by the
argument(s).
The classes will be registered for B{all} jobs, and are specified by
their string representations::
<package(s).module.class>
"""
modules = []
for stringRep in args:
# Load the class for the string representation
cls = reflect.namedObject(stringRep)
# Register instances of the class, including its type and module
pb.setUnjellyableForClass(stringRep, cls)
if cls.__module__ not in modules:
modules.append(cls.__module__)
# Try to build the modules for the classes in case they've changed
# since the last run
for module in modules:
try:
rebuild(reflect.namedModule(module), doLog=False)
except:
pass
示例6: loadModule
def loadModule(self, name):
for module in getPlugins(IBotModule, heufybot.modules):
if not module.name:
raise ModuleLoaderError("???", "Module did not provide a name")
if module.name == name:
rebuild(importlib.import_module(module.__module__))
self._loadModuleData(module)
break
示例7: reload
def reload(self, request):
request.redirect("..")
x = []
write = x.append
for module in self.modules:
rebuild.rebuild(module)
write('<li>reloaded %s<br />' % module.__name__)
return x
示例8: bot_rebuild
def bot_rebuild(self, sender, message, metadata):
self.loadBotList()
from twisted.words import botbot
from twisted.python.rebuild import rebuild
from twisted.python.reflect import namedModule
if message:
rebuild(namedModule(message))
else:
rebuild(botbot)
示例9: reload
def reload(self, request):
request.setHeader("location", "..")
request.setResponseCode(http.MOVED_PERMANENTLY)
x = []
write = x.append
for module in self.modules:
rebuild.rebuild(module)
write('<li>reloaded %s<br>' % module.__name__)
return x
示例10: loadModule
def loadModule(self, name):
for module in getPlugins(IModule, pymoronbot.modules):
if module.__class__.__name__ and module.__class__.__name__.lower() == name.lower():
rebuild(importlib.import_module(module.__module__))
self._loadModuleData(module)
print('-- {} loaded'.format(module.__class__.__name__))
return module.__class__.__name__
示例11: call_from_console
def call_from_console(self):
if len(self.args.split(' ')) < 2:
return "[Command] Invalid usage. (Usage: reloadplugin <Plugin Name>)"
modulearg = self.args.split(' ')[1]
if modulearg not in sys.modules.keys():
return "That plugin (%s) is not loaded." % modulearg
output = "[ShipProxy] Reloading plugin: %s..." % modulearg
rebuild.rebuild(sys.modules[modulearg])
output += "[ShipProxy] Plugin reloaded!\n"
return output
示例12: loadModule
def loadModule(self, name: str, rebuild_: bool=True) -> str:
for module in getPlugins(IModule, desertbot.modules):
if module.__class__.__name__ and module.__class__.__name__.lower() == name.lower():
if rebuild_:
rebuild(importlib.import_module(module.__module__))
self._loadModuleData(module)
self.logger.info('Module {} loaded'.format(module.__class__.__name__))
return module.__class__.__name__
示例13: do_reload
def do_reload(self, *modules):
""" try to reload one or more python modules.
KNOW WHAT YOU ARE DOING!
"""
self.sendLine("reloading module(s) %s" % ", ".join(modules))
for m in modules:
try:
m_ = import_module(m)
rebuild.rebuild(m_)
except Exception, e:
self.sendLine("reloading module %s threw Exception %s" % (m, e))
示例14: child_rebuild
def child_rebuild(self, ctx):
import pages_base
rebuild(pages_base)
import pages_index
rebuild(pages_index)
import pages_rooms
rebuild(pages_rooms)
import pages_edit
rebuild(pages_edit)
import pages_exits
rebuild(pages_exits)
self.goback(ctx)
return self
示例15: rebuildPackage
def rebuildPackage(package):
"""Recursively rebuild all loaded modules in the given package"""
rebuild.rebuild(package)
# If this is really a package instead of a module, look for children
try:
f = package.__file__
except AttributeError:
return
if package.__file__.find("__init__") >= 0:
for item in package.__dict__.itervalues():
# Is it a module?
if type(item) == type(package):
rebuildPackage(item)