Ejemplo n.º 1
0
 def __init__(self, projpath, config_subfolder=""):
     self._projpath=projpath
     self._subfolder=config_subfolder
     self._system_config   = odict()
     self._modules_config  = odict()
     self._devices_config  = odict()
     self._commands_config = odict()
     try:
         self._mainfolder=os.path.join (self._projpath, "config")
         if not os.path.exists(self._mainfolder):  raise ConfigError("Main config folder doesn't exist")
         self._cfgcmdpath=os.path.join (self._mainfolder,"commands.{0}".format(self.extension))
         if not os.path.exists(self._cfgcmdpath):  raise ConfigError("Default config file '{0}' doesn't exist".format(self._cfgcmdpath))
         self._cfgdevpath=os.path.join (self._mainfolder,"devices.{0}".format(self.extension))
         if not os.path.exists(self._cfgdevpath):  raise ConfigError("Default config file '{0}' doesn't exist".format(self._cfgdevpath))
         self._cfgmodpath=os.path.join (self._mainfolder,"modules.{0}".format(self.extension))
         if not os.path.exists(self._cfgmodpath):  raise ConfigError("Default config file '{0}' doesn't exist".format(self._cfgmodpath))
         self._cfgsyspath=os.path.join (self._mainfolder,"system.{0}".format(self.extension))
         if not os.path.exists(self._cfgsyspath):  raise ConfigError("Default config file '{0}' doesn't exist".format(self._cfgsyspath))
         if self._subfolder:
             p=os.path.join (self._mainfolder,self._subfolder,"commands.{0}".format(self.extension))
             if os.path.exists(p): self._cfgcmdpath=p
             p=os.path.join (self._mainfolder,self._subfolder,"devices.{0}".format(self.extension))
             if os.path.exists(p): self._cfgdevpath=p
             p=os.path.join (self._mainfolder,self._subfolder,"modules.{0}".format(self.extension))
             if os.path.exists(p): self._cfgmodpath=p
             p=os.path.join (self._mainfolder,self._subfolder,"system.{0}".format(self.extension))
             if os.path.exists(p): self._cfgsyspath=p    
         self.load_config()
     except Exception, err:
         raise ConfigError(err)
Ejemplo n.º 2
0
def set_descriptors(container_name, descr_klass, bases, class_dict):
    temp = []
    for attrname, attr in class_dict.items():
        if isinstance(attr, descr_klass):
            temp.append((attrname, attr))
    temp.sort(key=lambda x: x[1].counter_num)
    for base in bases[::-1]:
        if hasattr(base, container_name):
            if hasattr(base, container_name):
                base_container = getattr(base, container_name).copy()
                for name, _ in temp:
                    if name in base_container:
                        del base_container[name]
                temp = base_container.items() + temp
    temp = odict(temp)
    return temp
Ejemplo n.º 3
0
 def __init__(self):
     self._objects=odict()
     self._names=odict()