Ejemplo n.º 1
0
            'name': 'Data',
            'description': 'Data Folder',
            'public': 'true'
        })
        c.post('folder', parameters={
            'parentType': 'collection',
            'parentId': collection['_id'],
            'name': 'Analyses',
            'description': 'Analysis folder',
            'public': 'true'
        })
    else:
        collection = collection_search['collection'][0]

    # Get the 'Analyses' folder for this collection.
    analysis_folder = c.load_or_create_folder('Analyses', collection['_id'], 'collection')
    folder_id = analysis_folder['_id']

    # Read this analysis into a Python dictionary and upload it to Girder.
    analysis = {}
    with open (fullpath, "r") as analysis_file:
        analysis_str = analysis_file.read()
    try:
      analysis['analysis'] = json.loads(analysis_str)
    except ValueError:
      print "Could not read valid JSON from %s" % analysis_filename
      continue
    item = c.createItem(folder_id, analysis_name, analysis_name)
    c.addMetadataToItem(item['_id'], analysis)
    print "%s successfully uploaded to %s" % (analysis_filename, collection_name)