Revision 49818
Added by Sandro La Bruzzo over 6 years ago
DLI.py | ||
---|---|---|
7 | 7 |
|
8 | 8 |
from logger import dlilogger |
9 | 9 |
|
10 |
DLI_INDEX = 'dli_shadow' |
|
10 |
DLI_INDEX = None |
|
11 |
ES_HOST = None |
|
11 | 12 |
|
12 |
ES_HOST = 'ip-90-147-167-27.ct1.garrservices.it' |
|
13 | 13 |
|
14 |
def read_properies(): |
|
15 |
f = open('api.properties') |
|
16 |
for line in f: |
|
17 |
s = line.strip().split('=') |
|
18 |
if s[0] == 'api.index': |
|
19 |
DLI_INDEX = s[1] |
|
20 |
if s[1] == 'es_index': |
|
21 |
ES_HOST = [x.strip() for x in s[1].split(',')] |
|
14 | 22 |
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
15 | 27 |
class MyJSONEncoder(JSONEncoder): |
16 | 28 |
def default(self, obj): |
17 | 29 |
return obj.__dict__ |
... | ... | |
21 | 33 |
app.debug = False |
22 | 34 |
app.json_encoder = MyJSONEncoder |
23 | 35 |
|
24 |
base_dnet_url = "http://localhost:8280/app"
|
|
36 |
base_dnet_url = "http://aggregator-dli.openaire.eu/dli/"
|
|
25 | 37 |
|
26 | 38 |
|
27 |
# q = QueryResolver("http://localhost:8983/solr/DLIF-index-cleaned_shard1_replica1") |
|
28 |
|
|
29 | 39 |
class InvalidUsage(Exception): |
30 | 40 |
status_code = 400 |
31 | 41 |
|
... | ... | |
81 | 91 |
@app.route('/api/ds_info/', methods=['post', 'get']) |
82 | 92 |
def info(): |
83 | 93 |
raise Exception("Method to be implemented") |
84 |
# q = QueryResolver(host, base_dnet_url) |
|
85 |
# if 'id' in request.form: |
|
86 |
# id = request.form['id'] |
|
87 |
# name = request.form['name'] |
|
88 |
# result = q.get_ds_info(id, name) |
|
89 |
# return jsonify(info=result) |
|
90 |
# result = q.get_all_ds() |
|
91 |
# return jsonify(info=result) |
|
92 | 94 |
|
93 | 95 |
|
96 |
|
|
94 | 97 |
@app.route('/api/stats_detail/', methods=['post', 'get']) |
95 | 98 |
def stats_detail(): |
96 | 99 |
return "" |
97 | 100 |
|
98 |
# q = QueryResolver(host, base_dnet_url) |
|
99 |
# return jsonify(stats=q.get_stats_detail()) |
|
100 | 101 |
|
101 |
|
|
102 | 102 |
@app.route('/api/post/', methods=['post', 'get']) |
103 | 103 |
def query_post(): |
104 | 104 |
action = None |
... | ... | |
117 | 117 |
filter_key = request.form['filter'] |
118 | 118 |
|
119 | 119 |
if action == 'query' and query is not None: |
120 |
connector = DLIESConnector(ES_HOST, DLI_INDEX)
|
|
120 |
connector = DLIESConnector() |
|
121 | 121 |
try: |
122 | 122 |
result = connector.simple_query(query, start=start, user_filter=filter_key) |
123 | 123 |
except Exception as e: |
... | ... | |
128 | 128 |
|
129 | 129 |
|
130 | 130 |
if __name__ == '__main__': |
131 |
|
|
131 | 132 |
app.logger.addHandler(dlilogger) |
132 | 133 |
monitor(app, port=8000) |
133 | 134 |
app.run() |
Also available in: Unified diff
Changed portal to scholexplorer