本文整理汇总了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')