Example #1
0
def setProcessStatus(samweb,
                     status,
                     projectnameorurl,
                     processid=None,
                     process_desc=None):
    """ Mark the final status of a process

    Either the processid or the process description must be provided. If the description is
    used it must be unique within the project

    arguments:
        status: completed or bad
        projectnameorurl: project name or url
        processid: process identifier
        process_desc: process description
    """
    if '://' not in projectnameorurl:
        url = '/projects/name/%s' % escape_url_path(projectnameorurl)
    else:
        url = projectnameorurl
    args = {"status": status}
    if processid is not None:
        url += '/processes/%s' % processid
    elif process_desc is not None:
        url += '/process_description/%s' % escape_url_path(process_desc)
    else:
        # assume direct process url
        pass

    return samweb.putURL(url + "/status", args, secure=True).text.rstrip()
Example #2
0
def setProcessStatus(samweb, status, projectnameorurl, processid=None, process_desc=None):
    """ Mark the final status of a process

    Either the processid or the process description must be provided. If the description is
    used it must be unique within the project

    arguments:
        status: completed or bad
        projectnameorurl: project name or url
        processid: process identifier
        process_desc: process description
    """
    if "://" not in projectnameorurl:
        url = "/projects/name/%s" % escape_url_path(projectnameorurl)
    else:
        url = projectnameorurl
    args = {"status": status}
    if processid is not None:
        url += "/processes/%s" % processid
    elif process_desc is not None:
        url += "/process_description/%s" % escape_url_path(process_desc)
    else:
        # assume direct process url
        pass

    return samweb.putURL(url + "/status", args, secure=True).text.rstrip()
Example #3
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())
Example #4
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())
Example #5
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)
Example #6
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)
Example #7
0
def addValue(samweb, vtype, *args, **kwargs):
    """ Add a new value to the database
    arguments:
        vtype: string giving the type of value to add ( ie data_tiers, groups)
        *args: arguments to pass to server
        **kwargs: keyword arguments to pass to server
    """
    # build the provided arguments into a parameter list. The args sequence is turned into multiple
    # "value" parameters
    postdata = dict(kwargs)
    if args: postdata["value"] = [str(i) for i in args]
    try:
        return samweb.postURL('/values/%s' % escape_url_path(vtype), postdata, secure=True, role='*')
    except HTTPNotFound, ex:
        raise Error("Unknown value type '%s'" % vtype)
Example #8
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())
Example #9
0
def addValue(samweb, vtype, *args, **kwargs):
    """ Add a new value to the database
    arguments:
        vtype: string giving the type of value to add ( ie data_tiers, groups)
        *args: arguments to pass to server
        **kwargs: keyword arguments to pass to server
    """
    # build the provided arguments into a parameter list. The args sequence is turned into multiple
    # "value" parameters
    postdata = dict(kwargs)
    if args: postdata["value"] = [str(i) for i in args]
    try:
        return samweb.postURL('/values/%s' % escape_url_path(vtype),
                              postdata,
                              secure=True,
                              role='*')
    except HTTPNotFound, ex:
        raise Error("Unknown value type '%s'" % vtype)
Example #10
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())
Example #11
0
def _describeUser(samweb, username, format=None):
    params = {}
    if format:
        params['format'] = format
    return samweb.getURL('/users/name/%s' % escape_url_path(username), params)
Example #12
0
def _describeUser(samweb, username, format=None):
    params = {}
    if format:
        params['format'] = format
    return samweb.getURL('/users/name/%s' % escape_url_path(username), params)
Example #13
0
def projectSummaryText(samweb, projecturl):
    if not "://" in projecturl:
        projecturl = "/projects/name/%s" % escape_url_path(projecturl)
    return samweb.getURL(projecturl + "/summary", params=dict(format="plain")).text.rstrip()
Example #14
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())
Example #15
0
def modifyUser(samweb, username, **args):
    return samweb.postURL('/users/name/%s' % escape_url_path(username),
                          data=json.dumps(args),
                          content_type='application/json',
                          secure=True).text.rstrip()
Example #16
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())
Example #17
0
def projectSummaryText(samweb, projecturl):
    if not '://' in projecturl:
        projecturl = '/projects/name/%s' % escape_url_path(projecturl)
    return samweb.getURL(projecturl + "/summary",
                         params=dict(format='plain')).text.rstrip()
Example #18
0
def modifyUser(samweb, username, **args):
    return samweb.postURL('/users/name/%s' % escape_url_path(username), data=json.dumps(args), content_type='application/json', secure=True).text.rstrip()