Esempio n. 1
0
    def _mount(self):
        if self._children:
            self._mode |= MODE_VIRT

        if self._mode & MODE_VIRT or self._index == None:
            mode = None
            freq = None
            prof = None
        else:
            mode = self._mode
            freq = self._freq
            prof = self.d_profile
            path = get_mnt_path(self._uid, self._name)
            if os.path.exists(path):
                loader = Loader(self._uid)
                curr_prof = loader.get_profile(self._name)
                if curr_prof['type'] == prof['type']:
                    curr_mode = loader.get_attr(self._name, ATTR_MODE, int)
                    if ((curr_mode | MODE_SYNC) == (mode | MODE_SYNC)
                        ) and curr_prof.get('spec') == prof.get('spec'):
                        mode = None
                        freq = None
                        prof = None
                    else:
                        if not (curr_mode & MODE_SYNC):
                            mode &= ~MODE_SYNC
                        else:
                            mode |= MODE_SYNC
                        freq = loader.get_attr(self._name, ATTR_FREQ, float)
Esempio n. 2
0
 def __init__(self, uid, channel, core, addr=PROC_ADDR):
     self._uid = uid
     self._queue = []
     self._paths = {}
     self._hidden = {}
     self._core = core
     self._addr = addr
     self._visible = {}
     self._scheduler = None
     self._dispatchers = {}
     self._channel = channel
     self._lock = NamedLock()
     self._loader = Loader(self._uid)
     if ASYNC and QUEUE_LEN:
         self._scheduler = DispatcherScheduler(core)
Esempio n. 3
0
 def __init__(self, uid):
     self._timeout = {}
     self._loader = Loader(uid)
Esempio n. 4
0
 def __init__(self, uid, addr=PROC_ADDR):
     self._addr = addr
     self._filters = {}
     self._loader = Loader(uid)
Esempio n. 5
0
 def __init__(self, uid):
     self._parent = {}
     self._loader = Loader(uid)
Esempio n. 6
0
 def __init__(self, uid):
     self._mode = {}
     self._loader = Loader(uid)
Esempio n. 7
0
 def __init__(self, uid, addr=PROC_ADDR):
     self._handlers = {}
     self._loader = Loader(uid)
     self._addr = addr
Esempio n. 8
0
    def create(self, uid, name, mode, vrtx, parent, freq, prof, hndl, filt, disp, typ, timeout):
        if not typ:
            log_err(self, 'failed to create device, no type')
            raise Exception('Error: failed to create device')

        if mode & MODE_CLONE:
            if not parent:
                log_err(self, 'failed to create device, no parent')
                raise Exception('Error: failed to create device')
            prof = Loader(uid).get_profile(parent)
            typ = prof['type']

        if not mode & MODE_VIRT:
            timeout = None

        if not prof:
            if typ:
                driver = load_driver(typ)
                if not driver:
                    log_err(self, 'failed to create device, no %s driver' % str(typ))
                    raise Exception('Error: failed to create device')
                if mode & MODE_CLONE:
                    mode = driver.get_mode() | MODE_CLONE
                else:
                    mode = driver.get_mode()
                freq = driver.get_freq()
                prof = driver.get_profile()

        self._data.initialize(uid, name)
        self._attr.initialize(uid, name, ATTR_MODE, mode)

        if freq:
            self._attr.initialize(uid, name, ATTR_FREQ, freq)

        if filt:
            self._attr.initialize(uid, name, ATTR_FILTER, filt)

        if hndl:
            self._attr.initialize(uid, name, ATTR_HANDLER, hndl)

        if prof:
            self._attr.initialize(uid, name, ATTR_PROFILE, prof)

        if disp:
            self._attr.initialize(uid, name, ATTR_DISPATCHER, disp)

        if timeout:
            self._attr.initialize(uid, name, ATTR_TIMEOUT, timeout)

        if mode & MODE_CLONE:
            self._attr.initialize(uid, name, ATTR_PARENT, parent)

        if vrtx:
            if mode & MODE_CLONE:
                log_err(self, 'failed to create device, cannot set vertex for a cloned device')
                raise Exception('Error: failed to create device')
            self._vrtx.initialize(uid, name, vrtx)
            for v in vrtx:
                self._edge.initialize(uid, (v, name), hidden=True)

        self._manager.create(device_name(typ, name, mode), init=False)
Esempio n. 9
0
 def __init__(self, uid):
     self._freq = {}
     self._loader = Loader(uid)
Esempio n. 10
0
 def setup(self):
     self._active = False
     self._loader = Loader(self.get_uid())
     Thread(target=create_server, args=(LO_ADDR, LO_PORT, LoServer)).start()