本文整理匯總了Python中girder_client.GirderClient.listResource方法的典型用法代碼示例。如果您正苦於以下問題:Python GirderClient.listResource方法的具體用法?Python GirderClient.listResource怎麽用?Python GirderClient.listResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類girder_client.GirderClient
的用法示例。
在下文中一共展示了GirderClient.listResource方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: import_calc
# 需要導入模塊: from girder_client import GirderClient [as 別名]
# 或者: from girder_client.GirderClient import listResource [as 別名]
def import_calc(config):
try:
target_port = None
if config.port:
target_port = config.port
target_scheme = None
if config.scheme:
target_scheme = config.scheme
target_apiroot = None
if config.apiroot:
target_apiroot = config.apiroot
client = GirderClient(host=config.host, port=target_port,
scheme=target_scheme, apiRoot=target_apiroot)
client.authenticate(apiKey=config.apiKey)
me = client.get('/user/me')
if not me:
print('Error: Girder token invalid, please verify')
return
folderParams = {
'parentId': me['_id'],
'parentType': 'user',
'name': 'Private'
}
# Get the private folder id first
folder = next(client.listResource('folder', folderParams))
folder = next(client.listFolder(me['_id'], 'user', 'Private'))
for file_name in config.datafile:
print ('\nUploading ' + file_name)
file_id = {}
with open(file_name, 'r') as fp:
fileNameBase = os.path.basename(file_name)
size = os.path.getsize(file_name)
file_id = client.uploadFile(folder['_id'], fp, fileNameBase,
size, 'folder')
body = {
'fileId': file_id['_id']
}
if config.public:
body['public'] = True
mol = client.sendRestRequest('POST', 'molecules', data=json.dumps(body))
if mol and '_id' in mol:
config.moleculeId = mol['_id']
print('Molecule ID: ' + mol['_id'])
else:
print(mol)
except HttpError as error:
print(error.responseText, file=sys.stderr)