gd_retrieve

Retrieves a file, variable or metadata from the archive to the local machine.

   

Syntax

filename = gd_retrieve(ID,localpath=None,datatype=None,

                       prompt='')

metadata = gd_retrieve(ID,localpath=None,datatype='')

v = gd_retrieve(ID)

 

Description

The ID needed to retrieve some data can be found in its metadata as ['standard']['ID'], and is also returned by gd_archive.

 

filename = gd_retrieve(ID,filename) retrieves a file from the archive based on its unique identifier (ID) and saves it to a local file specified by the filename string. The function returns the retrieved file’s new location as a string, which is equal to the filename argument in this case. If a file exists with the same name a prompt will appear asking whether to overwrite it.

 

filename = gd_retrieve(ID,directory) retrieves a file from the archive based on its unique identifier (ID) and saves it to a local directory specified by the directory string. The original name of the file will be used, which is determined by the ['standard']['localName'] property in the file’s metadata, see gd_archive and gd_query. The function returns the retrieved file’s new location as a string.

 

filename = gd_retrieve(ID,filename,prompt='overwrite') will retrieve a file and save it to the local file system. If a file exists with the same name it will be overwritten without prompting. This is also the case when a directory is given as the second argument.

 

 metadata = gd_retrieve (ID,datatype='metadata') will return a metadata structure which corresponds to the file, variable or datagroup identified by ID. This is a shortcut, as the same result can be achieved using gd_query.

 

v = gd_retrieve(ID) returns a variable from the archive to the Jython workspace based on its unique identifier (ID).

 

 

Examples

 

Retrieve a file and save it with a specific file name.

           

from gddatabase import *

fileID = gd_archive('C:/file.dat')

gd_retrieve(fileID,'C:/filesdir/myfile.dat')

 

'C:/filesdir/myfile.dat'

 

Retrieve a file to a directory and use its original name.

 

gd_retrieve(fileID,'C:/filesdir')

 

'C:\\filesdir\\file.dat'

 

Retrieve a variable to the Jython workspace.

 

v = {'width': 12, 'height': 6}

varID = gd_archive(v)

x = gd_retrieve(varID)

print x

 

{'height': 6, 'width': 12}

 

Retrieve some metadata about a file.

 

m = gd_retrieve(fileID,datatype='metadata')

 

Notes

You can only retrieve data that you archived or that someone else has given you permission to access.

 

A valid proxy certificate is required to retrieve a file, variable or metadata (see gd_createproxy from the Geodise Compute Toolbox).

 

You must have access to the host machine the files will be retrieved from. Your certificate subject must be added to the gridmap file on the host and to the authorisation database.

 

See also

gd_archive, gd_datagroup, gd_datagroupadd, gd_query, gd_createproxy



gd_querydeleted

contents

gd_unmarkfordeletion

Copyright © 2005, The Geodise Project, University of Southampton