Пример #1
0
 def set_module_time(self, mod):
     try:
         sfile = get_source(mod)
         if os.path.exists(sfile):
             self.__mixins_funcs_time__[sfile] = os.path.getmtime(sfile)
             #self.__mixins_funcs_time__[f] = os.path.getmtime(sfile)
     except:
         error.traceback()
Пример #2
0
 def set_func_time(self, f):
     try:
         mod = sys.modules[f.__module__]
         sfile = get_source(mod)
         if os.path.exists(sfile):
             self.__mixins_funcs_time__[f] = (os.path.getmtime(sfile),sfile)
     except:
         error.traceback()
Пример #3
0
 def set_module_time(self, mod):
     try:
         sfile = get_source(mod)
         if os.path.exists(sfile):
             self.__mixins_funcs_time__[sfile] = os.path.getmtime(sfile)
             #self.__mixins_funcs_time__[f] = os.path.getmtime(sfile)
     except:
         error.traceback()
Пример #4
0
 def set_func_time(self, f):
     try:
         mod = sys.modules[f.__module__]
         sfile = get_source(mod)
         if os.path.exists(sfile):
             self.__mixins_funcs_time__[f] = (os.path.getmtime(sfile),
                                              sfile)
     except:
         error.traceback()
Пример #5
0
 def need_reinstall_func(self, f, mod):
     try:
         sfile = get_source(mod)
         if os.path.getmtime(sfile) > self.__mixins_funcs_time__.get(f)[0]:
             return True
         else:
             return False
     except:
         error.traceback()
         return False
Пример #6
0
 def need_reinstall_func(self, f, mod):
     try:
         sfile = get_source(mod)
         if os.path.getmtime(sfile) > self.__mixins_funcs_time__.get(f)[0]:
             return True
         else:
             return False
     except:
         error.traceback()
         return False
Пример #7
0
def setPlugin(mixinname, name, value, kind=MIDDLE, nice=-1):
    if not ENABLE:
        return

    if MUST_FUNC and not callable(value):
        print "name=%s, value=%r" % (name, value)
        raise Exception, 'The value should be a callable object'

    if not __mixins_funcs_time_set__.has_key(mixinname):
        __mixins_funcs_time_set__[mixinname] = {}
    
    
    if __mixinset__.has_key(mixinname):
        plugins = __mixinset__[mixinname][1]
        mixins_funcs_time = __mixins_funcs_time_set__[mixinname]
    else:
        __mixinset__[mixinname] = ({}, {})
        plugins = __mixinset__[mixinname][1]
        __mixins_funcs_time_set__[mixinname] = {}
        mixins_funcs_time = __mixins_funcs_time_set__[mixinname]

    if nice == -1:
        if kind == MIDDLE:
            nice = 500
        elif kind == HIGH:
            nice = 100
        else:
            nice = 900
    if plugins.has_key(name):
        plugins[name].append((nice, value))
    else:
        plugins[name] = [(nice, value)]
    if  RELOAD_MIXINS:
        if  get_name(value) not in RELOAD_NAME:
            f = value
            mod = sys.modules[f.__module__]

            if  mixins_funcs_time.get(f, None) is None:

                try:
                    sfile = get_source(mod)
                    if os.path.exists(sfile):
                        mixins_funcs_time[f] = os.path.getmtime(sfile),sfile
                except:
                    error.traceback()
                
                if  mixins_funcs_time.get(sfile, None) is None:
                    try:
                        sfile = get_source(mod)
                        if os.path.exists(sfile):
                            mixins_funcs_time[sfile] = os.path.getmtime(sfile)
                    except:
                        error.traceback()
Пример #8
0
def setPlugin(mixinname, name, value, kind=MIDDLE, nice=-1):
    if not ENABLE:
        return

    if MUST_FUNC and not callable(value):
        print "name=%s, value=%r" % (name, value)
        raise Exception, 'The value should be a callable object'

    if not __mixins_funcs_time_set__.has_key(mixinname):
        __mixins_funcs_time_set__[mixinname] = {}

    if __mixinset__.has_key(mixinname):
        plugins = __mixinset__[mixinname][1]
        mixins_funcs_time = __mixins_funcs_time_set__[mixinname]
    else:
        __mixinset__[mixinname] = ({}, {})
        plugins = __mixinset__[mixinname][1]
        __mixins_funcs_time_set__[mixinname] = {}
        mixins_funcs_time = __mixins_funcs_time_set__[mixinname]

    if nice == -1:
        if kind == MIDDLE:
            nice = 500
        elif kind == HIGH:
            nice = 100
        else:
            nice = 900
    if plugins.has_key(name):
        plugins[name].append((nice, value))
    else:
        plugins[name] = [(nice, value)]
    if RELOAD_MIXINS:
        if get_name(value) not in RELOAD_NAME:
            f = value
            mod = sys.modules[f.__module__]

            if mixins_funcs_time.get(f, None) is None:

                try:
                    sfile = get_source(mod)
                    if os.path.exists(sfile):
                        mixins_funcs_time[f] = os.path.getmtime(sfile), sfile
                except:
                    error.traceback()

                if mixins_funcs_time.get(sfile, None) is None:
                    try:
                        sfile = get_source(mod)
                        if os.path.exists(sfile):
                            mixins_funcs_time[sfile] = os.path.getmtime(sfile)
                    except:
                        error.traceback()