當前位置: 首頁>>代碼示例>>Python>>正文


Python Loader.get_profile方法代碼示例

本文整理匯總了Python中lib.loader.Loader.get_profile方法的典型用法代碼示例。如果您正苦於以下問題:Python Loader.get_profile方法的具體用法?Python Loader.get_profile怎麽用?Python Loader.get_profile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在lib.loader.Loader的用法示例。


在下文中一共展示了Loader.get_profile方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _mount

# 需要導入模塊: from lib.loader import Loader [as 別名]
# 或者: from lib.loader.Loader import get_profile [as 別名]
    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)

        if not self._children:
            api_mount(self._uid, name=self.d_name, mode=mode, freq=freq, prof=prof)
            self._log('mount %s [%s*]' % (self.d_type, self.d_name[:8]))
開發者ID:virtdev,項目名稱:virtdev,代碼行數:34,代碼來源:udo.py

示例2: Lo

# 需要導入模塊: from lib.loader import Loader [as 別名]
# 或者: from lib.loader.Loader import get_profile [as 別名]
class Lo(UDI):
    def get_name(self, device, child=None):
        return _get_name(device)

    def get_mode(self, device):
        return _get_mode(device)

    def setup(self):
        self._active = False
        self._loader = Loader(self.get_uid())
        Thread(target=create_server, args=(LO_ADDR, LO_PORT, LoDaemon)).start()

    def _get_device(self, name):
        mode = self._core.get_mode(name)
        prof = self._loader.get_profile(name)
        if prof:
            return device_name(prof['type'], name, mode)

    def scan(self):
        device_list = []
        if not self._active:
            self._active = True
            names = get_devices(self._uid, sort=True)
            if names:
                for name in names:
                    device = self._get_device(name)
                    if device and device not in _devices:
                        device_list.append(device)
        return device_list

    def connect(self, device):
        return (connect(device), True)

    @property
    def compute_unit(self):
        if not _devices:
            return
        keys = _devices.keys()
        length = len(keys)
        i = randint(0, length - 1)
        for _ in range(length):
            device = _devices[keys[i]]
            if device.get_mode() & MODE_CTRL:
                return device
            i += 1
            if i == length:
                i = 0
開發者ID:virtdev,項目名稱:virtdev,代碼行數:49,代碼來源:lo.py


注:本文中的lib.loader.Loader.get_profile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。