示例#1
0
def listParameterValues(samweb, param):
    """ list the values for the given parameter
    arguments:
        param: parameter name
    """
    result = samweb.getURL('/values/parameters/%s?format=json' % escape_url_path(param))
    return convert_from_unicode(result.json())
示例#2
0
def getMultipleMetadata(samweb, filenameorids, locations=False, asJSON=False):
    """ Return a list of metadata dictionaries
    (This method does not return an error if a
    file does not exist; instead it returns no
    result for that file)
    arguments:
        list of file names or ids
        locations: if True include location information
        asJSON: return the undecoded JSON string instead of python objects
    """
    file_names = []
    file_ids = []
    for filenameorid in filenameorids:
        try:
            file_ids.append(long(filenameorid))
        except ValueError:
            file_names.append(filenameorid)

    params = {}
    if file_names: params["file_name"] = file_names
    if file_ids: params["file_id"] = file_ids
    if locations: params["locations"] = 1
    response = samweb.getURL("/files/metadata", params=params)
    if asJSON:
        return response.text.rstrip()
    else:
        return convert_from_unicode(response.json())
示例#3
0
def descDefinitionDict(samweb, defname):
    """ Describe a dataset definition
    arguments:
        definition name
    """
    result = samweb.getURL(_descDefinitionURL(defname))
    return convert_from_unicode(result.json())
示例#4
0
def getMultipleMetadata(samweb, filenameorids, locations=False, asJSON=False):
    """ Return a list of metadata dictionaries
    (This method does not return an error if a
    file does not exist; instead it returns no
    result for that file)
    arguments:
        list of file names or ids
        locations: if True include location information
        asJSON: return the undecoded JSON string instead of python objects
    """
    file_names = []
    file_ids = []
    for filenameorid in filenameorids:
        try:
            file_ids.append(long(filenameorid))
        except ValueError:
            file_names.append(filenameorid)
    
    params = {}
    if file_names: params["file_name"] = file_names
    if file_ids: params["file_id"] = file_ids
    if locations: params["locations"] = 1
    response = samweb.getURL("/files/metadata", params=params)
    if asJSON:
        return response.text.rstrip()
    else:
        return convert_from_unicode(response.json())
示例#5
0
def descDefinitionDict(samweb, defname):
    """ Describe a dataset definition
    arguments:
        definition name
    """
    result = samweb.getURL(_descDefinitionURL(defname))
    return convert_from_unicode(result.json())
示例#6
0
def listParameterValues(samweb, param):
    """ list the values for the given parameter
    arguments:
        param: parameter name
    """
    result = samweb.getURL('/values/parameters/%s?format=json' %
                           escape_url_path(param))
    return convert_from_unicode(result.json())
示例#7
0
def locateFile(samweb, filenameorid):
    """ return locations for this file
    arguments:
        name or id of file
    """
    url = _make_file_path(filenameorid) + '/locations'
    result = samweb.getURL(url)
    return convert_from_unicode(result.json())
示例#8
0
def getFileLineage(samweb, lineagetype, filenameorid):
    """ Return lineage information for a file
    arguments:
        lineagetype (ie "parents", "children")
        name or id of file
    """
    result = samweb.getURL(_make_file_path(filenameorid) + '/lineage/' + escape_url_component(lineagetype))
    return convert_from_unicode(result.json())
示例#9
0
def locateFile(samweb, filenameorid):
    """ return locations for this file
    arguments:
        name or id of file
    """
    url = _make_file_path(filenameorid) + '/locations'
    result = samweb.getURL(url)
    return convert_from_unicode(result.json())
示例#10
0
def listValues(samweb, vtype):
    """ list values from database. This method tries to be generic, so vtype is
    passed directly to the web server
    arguments:
        vtype: string with values to return (ie data_tiers, groups)
    """
    try:
        return convert_from_unicode(samweb.getURL('/values/%s' % escape_url_path(vtype)).json())
    except HTTPNotFound, ex:
        raise Error("Unknown value type '%s'" % vtype)
示例#11
0
def listFilesSummary(samweb, dimensions=None, defname=None):
    """ return summary of files matching either a dataset definition or a dimensions string
    arguments:
      dimensions: string (default None)
      defname: string definition name (default None)"""
    if defname is not None:
        result = samweb.getURL('/definitions/name/%s/files/summary' % escape_url_component(defname))
    else:
        result = samweb._callDimensions('/files/summary', dimensions)
    return convert_from_unicode(result.json())
示例#12
0
def getMetadata(samweb, filenameorid, locations=False):
    """ Return metadata as a dictionary 
    arguments:
        name or id of file
        locations: if True, also return file locations
    """
    params = {}
    if locations: params['locations'] = True
    response = samweb.getURL(_make_file_path(filenameorid) + '/metadata', params=params)
    return convert_from_unicode(response.json())
示例#13
0
def getFileLineage(samweb, lineagetype, filenameorid):
    """ Return lineage information for a file
    arguments:
        lineagetype (ie "parents", "children")
        name or id of file
    """
    result = samweb.getURL(
        _make_file_path(filenameorid) + '/lineage/' +
        escape_url_component(lineagetype))
    return convert_from_unicode(result.json())
示例#14
0
def listFilesSummary(samweb, dimensions=None, defname=None):
    """ return summary of files matching either a dataset definition or a dimensions string
    arguments:
      dimensions: string (default None)
      defname: string definition name (default None)"""
    if defname is not None:
        result = samweb.getURL('/definitions/name/%s/files/summary' %
                               escape_url_component(defname))
    else:
        result = samweb._callDimensions('/files/summary', dimensions)
    return convert_from_unicode(result.json())
示例#15
0
def listValues(samweb, vtype):
    """ list values from database. This method tries to be generic, so vtype is
    passed directly to the web server
    arguments:
        vtype: string with values to return (ie data_tiers, groups)
    """
    try:
        return convert_from_unicode(
            samweb.getURL('/values/%s' % escape_url_path(vtype)).json())
    except HTTPNotFound, ex:
        raise Error("Unknown value type '%s'" % vtype)
示例#16
0
def getMetadata(samweb, filenameorid, locations=False):
    """ Return metadata as a dictionary 
    arguments:
        name or id of file
        locations: if True, also return file locations
    """
    params = {}
    if locations: params['locations'] = True
    response = samweb.getURL(_make_file_path(filenameorid) + '/metadata',
                             params=params)
    return convert_from_unicode(response.json())
示例#17
0
def getFileAccessUrls(samweb, filenameorid, schema, locationfilter=None):
    """ return urls by which this file may be accessed
    arguments:
        name or id of file
        schema
        locationfilter (default None)
    """
    params = { "schema": schema }
    if locationfilter:
        params["location"] = locationfilter
    response = samweb.getURL(_make_file_path(filenameorid) + '/locations/url', params=params)
    return convert_from_unicode(response.json())
示例#18
0
def getFileAccessUrls(samweb, filenameorid, schema, locationfilter=None):
    """ return urls by which this file may be accessed
    arguments:
        name or id of file
        schema
        locationfilter (default None)
    """
    params = {"schema": schema}
    if locationfilter:
        params["location"] = locationfilter
    response = samweb.getURL(_make_file_path(filenameorid) + '/locations/url',
                             params=params)
    return convert_from_unicode(response.json())
示例#19
0
def projectRecoveryDimension(samweb, projectnameorurl, useFileStatus=None, useProcessStatus=None):
    """Get the dimensions to create a recovery dataset
    arguments:
        projectnameorurl : name or url of the project
        useFileStatus : use the status of the last file seen by a process (default unset)
        useProcessStatus : use the status of the process (default unset)
    """
    if not "://" in projectnameorurl:
        projectnameorurl = "/projects/name/%s" % escape_url_path(projectnameorurl)
    params = {"format": "plain"}
    if useFileStatus is not None:
        params["useFiles"] = useFileStatus
    if useProcessStatus is not None:
        params["useProcess"] = useProcessStatus
    return convert_from_unicode(samweb.getURL(projectnameorurl + "/recovery_dimensions", params=params).text.rstrip())
示例#20
0
def locateFiles(samweb, filenameorids):
    """ return the locations of multiple files
    The return value is a dictionary of { file_name_or_id : location } pairs
    """

    file_names = []
    file_ids = []
    for filenameorid in filenameorids:
        try:
            file_ids.append(long(filenameorid))
        except ValueError:
            file_names.append(filenameorid)

    params = {}
    if file_names: params["file_name"] = file_names
    if file_ids: params["file_id"] = file_ids
    response = samweb.getURL("/files/locations", params=params)
    return convert_from_unicode(response.json())
示例#21
0
def locateFiles(samweb, filenameorids):
    """ return the locations of multiple files
    The return value is a dictionary of { file_name_or_id : location } pairs
    """

    file_names = []
    file_ids = []
    for filenameorid in filenameorids:
        try:
            file_ids.append(long(filenameorid))
        except ValueError:
            file_names.append(filenameorid)

    params = {}
    if file_names: params["file_name"] = file_names
    if file_ids: params["file_id"] = file_ids
    response = samweb.getURL("/files/locations", params=params)
    return convert_from_unicode(response.json())
示例#22
0
def projectRecoveryDimension(samweb,
                             projectnameorurl,
                             useFileStatus=None,
                             useProcessStatus=None):
    """Get the dimensions to create a recovery dataset
    arguments:
        projectnameorurl : name or url of the project
        useFileStatus : use the status of the last file seen by a process (default unset)
        useProcessStatus : use the status of the process (default unset)
    """
    if not '://' in projectnameorurl:
        projectnameorurl = "/projects/name/%s" % escape_url_path(
            projectnameorurl)
    params = {"format": "plain"}
    if useFileStatus is not None: params['useFiles'] = useFileStatus
    if useProcessStatus is not None: params['useProcess'] = useProcessStatus
    return convert_from_unicode(
        samweb.getURL(projectnameorurl + "/recovery_dimensions",
                      params=params).text.rstrip())
示例#23
0
def listParameters(samweb):
    """ list defined parameters """
    return convert_from_unicode(samweb.getURL('/values/parameters').json())
示例#24
0
def projectSummary(samweb, projecturl):
    if not "://" in projecturl:
        projecturl = "/projects/name/%s" % escape_url_path(projecturl)
    return convert_from_unicode(samweb.getURL(projecturl + "/summary").json())
示例#25
0
def listDataDisks(samweb):
    """ list defined data disks """
    return convert_from_unicode(samweb.getURL('/values/data_disks').json())
示例#26
0
def projectSummary(samweb, projecturl):
    if not '://' in projecturl:
        projecturl = '/projects/name/%s' % escape_url_path(projecturl)
    return convert_from_unicode(samweb.getURL(projecturl + "/summary").json())
示例#27
0
def listApplications(samweb, **queryCriteria):
    result = samweb.getURL('/values/applications', queryCriteria)
    return convert_from_unicode(result.json())
示例#28
0
def getAvailableDimensions(samweb):
    """ List the available dimensions """
    result = samweb.getURL('/files/list/dimensions?format=json&descriptions=1')
    return convert_from_unicode(result.json())
示例#29
0
def listApplications(samweb, **queryCriteria):
    result = samweb.getURL('/values/applications', queryCriteria)
    return convert_from_unicode(result.json())
示例#30
0
def getAvailableValues(samweb):
    """ get the available names that can be used with listValues, addValues """
    return convert_from_unicode(samweb.getURL('/values?list=generic').json())
示例#31
0
def describeUser(samweb, username):
    result = samweb._describeUser(username)
    return convert_from_unicode(result.json())
示例#32
0
def listUsers(samweb):
    result = samweb.getURL('/users')
    return convert_from_unicode(result.json())
示例#33
0
def describeUser(samweb, username):
    result = samweb._describeUser(username)
    return convert_from_unicode(result.json())
示例#34
0
def getAvailableDimensions(samweb):
    """ List the available dimensions """
    result = samweb.getURL('/files/list/dimensions?format=json&descriptions=1')
    return convert_from_unicode(result.json())
示例#35
0
def listParameters(samweb):
    """ list defined parameters """
    return convert_from_unicode(samweb.getURL('/values/parameters').json())
示例#36
0
def listUsers(samweb):
    result = samweb.getURL('/users')
    return convert_from_unicode(result.json())
示例#37
0
def listDataDisks(samweb):
    """ list defined data disks """
    return convert_from_unicode(samweb.getURL('/values/data_disks').json())
示例#38
0
def getAvailableValues(samweb):
    """ get the available names that can be used with listValues, addValues """
    return convert_from_unicode(samweb.getURL('/values?list=generic').json())