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


Python System.listing方法代碼示例

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


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

示例1: Data

# 需要導入模塊: from system import System [as 別名]
# 或者: from system.System import listing [as 別名]

#.........這裏部分代碼省略.........
    @property
    def input_to_process(self):
        return [x for x in self.is_input_to if x.name == 'idsvc.process']

    @property
    def output_of_process(self):
        return [x for x in self.is_output_of if x.name == 'idsvc.process']

    def add_project(self, project):
        """ """ 
        self.add_container(project)


    def load_file_info(self):
        if self.system_id is None:
            exception_msg = 'Missing system id, cannot load file info.'
            logger.exception(exception_msg)
            raise Exception(exception_msg)

        if self.path is None:
            exception_msg = 'Missing file path, cannot load file info.'
            logger.exception(exception_msg)
            raise Exception(exception_msg)

        if self.system is None:
            try:
                self.system = System(api_client=self._api_client, system_id=self.system_id)
            except Exception as e:
                exception_msg = 'Unable to access system with system_id=%s.' % self.system_id
                logger.error(exception_msg)
                raise Exception(exception_msg)

        try:
            listing = self.system.listing(self.path)
            file_info = next(iter(listing), None)
        except Exception as e:
            exception_msg = 'The path=%s could not be listed on system=%s. %s' \
                            % (self.path, self.system_id, e)
            logger.error(exception_msg)
            raise Exception(exception_msg)

        try:
            last_mod = file_info['lastModified']
            file_info['lastModified'] = last_mod.strftime('%b %-d %I:%M')
        except:
            warning_msg = 'Listing response does not contain lastModified.'
            logger.warning(warning_msg)

        self.value = file_info

    def _share(self, username, permission):
        """"""
        body=json.dumps({ 'username': username,
                          'permission': permission,
                          'recursive': False })
        self._api_client.files.updatePermissions(
                systemId=self.system_id,
                filePath=self.value['path'],
                body=body )

    def save(self):
        super(Data, self).save()

        if self.path and self.system_id:
            logger.debug('Sharing data with portal user...')
            self._share(username='idsvc_user', permission='READ')
開發者ID:identifier-services,項目名稱:Identifier-Services-Portal,代碼行數:70,代碼來源:data.py


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