示例#1
0
文件: irc.py 项目: dpk/duxlot
    def reload(self, sender=None, nick=None):
        import imp

        def error(msg):
            if sender and nick:
                self.public.msg(sender, nick + ": " + msg)

        duxlot.clear()

        sys.path[:0] = [duxlot.path]
        imp.reload(api)
        sys.path[:1] = []

        for (directory, module_name), module in self.modules.items():
            sys.path[:0] = [directory, duxlot.path]

            try: reloaded = imp.reload(module)
            except Exception as err:
                message = "%s: %s" % (err.__class__.__name__, err)
                debug(message)
                error(message)

                return False
            else:
                self.modules[(directory, module_name)] = reloaded
            finally:
                sys.path[:2] = []

        return True
示例#2
0
文件: irc.py 项目: dpk/duxlot
    def reload(self, sender=None, nick=None):
        import imp

        def error(msg):
            if sender and nick:
                self.public.msg(sender, nick + ": " + msg)

        duxlot.clear()

        sys.path[:0] = [duxlot.path]
        imp.reload(api)
        sys.path[:1] = []

        for (directory, module_name), module in self.modules.items():
            sys.path[:0] = [directory, duxlot.path]

            try:
                reloaded = imp.reload(module)
            except Exception as err:
                message = "%s: %s" % (err.__class__.__name__, err)
                debug(message)
                error(message)

                return False
            else:
                self.modules[(directory, module_name)] = reloaded
            finally:
                sys.path[:2] = []

        return True