本文整理汇总了Python中twisted.python.rebuild.rebuild函数的典型用法代码示例。如果您正苦于以下问题:Python rebuild函数的具体用法?Python rebuild怎么用?Python rebuild使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rebuild函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:nibalizer,项目名称:alphabot,代码行数:28,代码来源:client.py
示例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)
开发者ID:Heufneutje,项目名称:PyHeufyBot,代码行数:7,代码来源:modulehandler.py
示例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)
开发者ID:ssilverek,项目名称:kodb,代码行数:7,代码来源:test_dirdbm.py
示例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
开发者ID:tuukka,项目名称:sioclog,代码行数:28,代码来源:sioclogbot.py
示例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
开发者ID:D3f0,项目名称:txscada,代码行数:26,代码来源:jobs.py
示例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
开发者ID:HubbeKing,项目名称:PyHeufyBot,代码行数:8,代码来源:modulehandler.py
示例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
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:8,代码来源:widgets.py
示例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)
开发者ID:fxia22,项目名称:ASM_xf,代码行数:9,代码来源:botbot.py
示例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
开发者ID:lhl,项目名称:songclub,代码行数:9,代码来源:widgets.py
示例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__
开发者ID:MatthewCox,项目名称:PyMoronBot,代码行数:9,代码来源:modulehandler.py
示例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
开发者ID:Daikui,项目名称:PSO2Proxy,代码行数:10,代码来源:commands.py
示例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__
开发者ID:DesertBot,项目名称:DesertBot,代码行数:10,代码来源:modulehandler.py
示例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))
开发者ID:serpent-project,项目名称:serpent,代码行数:11,代码来源:console.py
示例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
开发者ID:cryptixman,项目名称:tzmud,代码行数:13,代码来源:pages_base.py
示例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)
开发者ID:Kays,项目名称:cia-vc,代码行数:13,代码来源:Debug.py
示例16: test_hashException
def test_hashException(self):
"""
Rebuilding something that has a __hash__ that raises a non-TypeError
shouldn't cause rebuild to die.
"""
global unhashableObject
unhashableObject = HashRaisesRuntimeError()
def _cleanup():
global unhashableObject
unhashableObject = None
self.addCleanup(_cleanup)
rebuild.rebuild(rebuild)
self.assertEqual(unhashableObject.hashCalled, True)
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:13,代码来源:test_rebuild.py
示例17: reload
def reload(self, name, event_src_path=None):
""" Try to fully rebuild an app """
# Don't reload the same app if we did it within last the 5 sec
if time.time() - self._last_reload.get(name, 0) < 5:
return
self._last_reload[name] = time.time()
if name not in self:
return False
if hasattr(self[name], 'pre_reload'):
self[name].pre_reload()
try:
if event_src_path:
if event_src_path.endswith('.py'):
path, f = os.path.split(event_src_path)
pyc = path + '/' + f[:-3] + '.pyc'
if os.path.isfile(pyc):
os.remove(pyc)
targets = []
for mname, module in sys.modules.items():
if module:
if hasattr(module, '__file__'):
if event_src_path in module.__file__:
targets.append(module)
for target in targets:
rebuild(target, False)
else:
# generally try to reload the app
self[name] = rebuild(self[name], False)
except:
sage._log.msg("Error reloading '%s'" % name)
sage._log.err()
return False
gc.collect()
if hasattr(self[name], 'post_reload'):
self[name].post_reload()
sage._log.msg("Reloaded app '%s'" % self.meta[name].name)
return True
开发者ID:spicerack,项目名称:sage,代码行数:51,代码来源:app.py
示例18: testRebuild
def testRebuild(self):
"""Rebuilding an unchanged module."""
# This test would actually pass if rebuild was a no-op, but it
# ensures rebuild doesn't break stuff while being a less
# complex test than testFileRebuild.
x = crash_test_dummy.X('a')
rebuild.rebuild(crash_test_dummy, doLog=False)
# Instance rebuilding is triggered by attribute access.
x.do()
self.failUnlessIdentical(x.__class__, crash_test_dummy.X)
self.failUnlessIdentical(f, crash_test_dummy.foo)
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:14,代码来源:test_rebuild.py
示例19: check_and_reload
def check_and_reload(self, subOptions):
modules_changed = code_changed()
if modules_changed:
for module in modules_changed:
try:
rebuild(module)
except Exception as e:
self.logger.critical("Error reloading %s: %s", module.__name__, e)
self.app = NoResource("There was an error reloading the app.")
break
else:
self.logger.critical("Reloaded %s (%d modules loaded)", module.__name__, len(sys.modules))
else:
self.attach_app(subOptions)
开发者ID:tehasdf,项目名称:txdevserver,代码行数:15,代码来源:service.py
示例20: reloadPluginModule
def reloadPluginModule(self, stuff, filepath, mask):
# Get the actual filepath
afpath = os.path.abspath(filepath.path).replace('.conf', '.py')
# See if we need to reload a plugin, load a new plugin, or ignore
if mask == inotify.IN_MODIFY and afpath in self.modules:
try:
self.modules[afpath] = rebuild(self.modules[afpath])
self.loadPluginObject(self.modules[afpath], reloading=True)
if self.logging:
log.msg('Reloaded {}'.format(filepath))
except:
if self.logging:
log.err('Failed to reload {} | {} | {}'.\
format( filepath
, sys.exc_info()[0]
, traceback.format_exc()
)
)
elif mask == inotify.IN_CREATE and afpath.endswith('.py'):
plugin = afpath.split('/')[-1].rstrip('.py')
self.modules[afpath] = import_module('plugins.{}'.format(plugin))
else:
return
开发者ID:Hasimir,项目名称:eventsdb,代码行数:26,代码来源:BaneBot.py
注:本文中的twisted.python.rebuild.rebuild函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论