本文整理汇总了Python中girder_client.GirderClient.sendRestRequest方法的典型用法代码示例。如果您正苦于以下问题:Python GirderClient.sendRestRequest方法的具体用法?Python GirderClient.sendRestRequest怎么用?Python GirderClient.sendRestRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类girder_client.GirderClient
的用法示例。
在下文中一共展示了GirderClient.sendRestRequest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: import_calc
# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import sendRestRequest [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)
示例2: GirderClient
# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import sendRestRequest [as 别名]
from girder_client import GirderClient
c = GirderClient(host="localhost", port=9000)
# Create an admin user if there isn't one
try:
c.authenticate("girder", "girder")
except:
c.sendRestRequest(
"POST",
"user",
{
"login": "girder",
"password": "girder",
"email": "[email protected]",
"firstName": "Girder",
"lastName": "Admin",
},
)
c.authenticate("girder", "girder")
# Create a tangelo hub collection if there isn't one
coll_search = c.get("resource/search", parameters={"q": "Default", "types": '["collection"]'})
if len(coll_search["collection"]) == 0:
collection = c.post(
"collection", parameters={"name": "Default", "description": "Default workspace", "public": "true"}
)
c.post(
"folder",
parameters={
"parentType": "collection",