コード例 #1
0
def create(args, FIELDS_URL):
    """create a field"""

    data = parse_opts(args)
    for arg in ('name', 'field_type'):
        if arg not in data:
            raise Exception("Creating a Field requires a " + arg)

    rsp = json_http(FIELDS_URL, method='POST', data=data)
    print "Created New Field: " + data['name'] + " at: " + FIELDS_URL
コード例 #2
0
def update(args, FIELDS_URL):
    """modify properties of a Field"""

    data = parse_opts(args)
    if 'name' not in data:
        raise Exception("Updating a Field requires a name")
    name = data['name']
    del data['name']

    json_http(FIELDS_URL + "/" + name, method='PUT', data=data)
    print "Updated Field: " + name
コード例 #3
0
ファイル: ds.py プロジェクト: dhirajforyou/lws-financial-demo
def update(args, DS_URL):
    """modify properties of a datasource"""

    data = parse_opts(args)
    i = get_id(data)
    if i is None:
        raise Exception(
            "Updating a DataSource requires either an id or a name")

    json_http(DS_URL + "/" + i, method='PUT', data=data)
    print "Updated DataSource #" + i
コード例 #4
0
ファイル: ds.py プロジェクト: dhirajforyou/lws-financial-demo
def schedule(args, DS_URL):
    """modify the schedule of a datasource"""

    data = parse_opts(args)
    i = get_id(data)
    if i is None:
        raise Exception(
            "Modifying the schedule of a DataSource requires either an id or a name"
        )

    json_http(DS_URL + "/" + i + '/schedule', method='PUT', data=data)
    print "Updated Schedule of DataSource #" + i
コード例 #5
0
ファイル: ds.py プロジェクト: dhirajforyou/lws-financial-demo
def delete(args, DS_URL):
    """remove a datasource"""

    if 1 != len(args):
        raise Exception("wrong number of args for deleting a DataSource")

    i = get_id(parse_opts(args))
    if i is None:
        raise Exception(
            "Must supply either an id or a name for a DataSource to delete it")

    json_http(DS_URL + '/' + i, method='DELETE')
    print "Deleted DataSource #" + i
コード例 #6
0
ファイル: ds.py プロジェクト: dhirajforyou/lws-financial-demo
def create(args, DS_URL, added_data=None):
    """create a datasource"""

    data = parse_opts(args)
    if 'name' not in data:
        raise Exception("Creating a DataSource requires a name")
    if 'type' not in data:
        raise Exception("Creating a DataSource requires a type")
    if 'crawler' not in data:
        raise Exception("Creating a DataSource requires a crawler")
    if added_data:
        data.update(added_data)
    rsp = json_http(DS_URL, method='POST', data=data)
    print "Created New DataSource: " + str(
        rsp['id']) + " with name: " + data['name'] + " at " + DS_URL
    return rsp['id']
コード例 #7
0
ファイル: ds.py プロジェクト: dhirajforyou/lws-financial-demo
def history(args, DS_URL):
    """display the indexing history of a datasource"""

    if 1 != len(args):
        raise Exception("wrong number of args for showing a DataSource")

    i = get_id(parse_opts(args))
    if i is None:
        raise Exception(
            "Must supply either an id or a name to view the indexing history of a DataSource"
        )

    url = DS_URL + "/" + i + '/history'
    data = json_http(url)
    print "History of DataSource #" + i + ": " + url + " => " + pretty_json(
        data)
コード例 #8
0
ファイル: ds.py プロジェクト: dhirajforyou/lws-financial-demo
def status(args, DS_URL):
    """display status of datasources"""
    if 1 < len(args):
        raise Exception("wrong number of args for showing DataSource status")

    i = get_id(parse_opts(args))

    if (i is not None):
        url = DS_URL + '/' + i + '/status'
        data = json_http(url)
        print "Status of DataSource #" + i + ": " + url + " => " + pretty_json(
            data)

    else:
        url = DS_URL + "/all/status"
        data = json_http(url)
        print "Status of All DataSources: " + url + " => " + pretty_json(data)
コード例 #9
0
ファイル: ds.py プロジェクト: dhirajforyou/lws-financial-demo
def show(args, DS_URL):
    """display current datasources"""
    if 1 < len(args):
        raise Exception("wrong number of args for showing a DataSource")

    i = get_id(parse_opts(args))

    if (i is None):
        print 'Data Sources: ' + DS_URL
        data = json_http(DS_URL)

        if 0 == len(data):
            print '  (none)'
        else:
            for ds in data:
                print_ds(ds, '  ')
    else:
        print_ds(json_http(DS_URL + '/' + i))
コード例 #10
0
def update(args, SETTINGS_URL):
    """modify settings"""

    data = parse_opts(args)
    json_http(SETTINGS_URL, method='PUT', data=data)
    print "Updated Settings"