Skip to content

Commit 55809af

Browse files
Merge pull request #4 from MikroElektronika/topic/switch-to-dbp
Updated according to new DBP.
2 parents d1785c2 + 14f58ee commit 55809af

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

scripts/index.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,18 @@ def index_release_to_elasticsearch(es : Elasticsearch, index_name, release_detai
6464
'hidden': False,
6565
'type': 'legacy_sdk',
6666
'version': version,
67-
'created_at' : asset['created_at'],
68-
'updated_at' : asset['updated_at'],
67+
'created_at': asset['created_at'],
68+
'updated_at': asset['updated_at'],
6969
'category': 'Software Development Kit',
7070
'download_link': asset['url'], # Adjust as needed for actual URL
71-
'install_location' : f"%APPLICATION_DATA_DIR%/packages/legacy/{name_without_extension.lower()}",
72-
'package_changed': True
71+
'install_location': f"%APPLICATION_DATA_DIR%/packages/legacy/{name_without_extension.lower()}",
72+
'package_changed': True,
73+
'gh_package_name': f"{name_without_extension}.7z"
7374
}
7475

7576
# Index the document
7677
if doc:
77-
resp = es.index(index=index_name, doc_type='necto_package', id=name_without_extension, body=doc)
78+
resp = es.index(index=index_name, doc_type=None, id=name_without_extension, body=doc)
7879
print(f"{resp["result"]} {resp['_id']}")
7980

8081
if __name__ == '__main__':
@@ -87,18 +88,19 @@ def index_release_to_elasticsearch(es : Elasticsearch, index_name, release_detai
8788

8889
# Elasticsearch instance used for indexing
8990
num_of_retries = 1
91+
print("Trying to connect to ES")
9092
while True:
91-
print(f"Trying to connect to ES. Connection retry: {num_of_retries}")
9293
es = Elasticsearch([os.environ['ES_HOST']], http_auth=(os.environ['ES_USER'], os.environ['ES_PASSWORD']))
9394
if es.ping():
9495
break
95-
# Wait for 30 seconds and try again if connection fails
96+
# Wait 1 second and try again if connection fails
9697
if 10 == num_of_retries:
9798
# Exit if it fails 10 times, something is wrong with the server
9899
raise ValueError("Connection to ES failed!")
100+
print(f"Connection retry: {num_of_retries}")
99101
num_of_retries += 1
100102

101-
time.sleep(30)
103+
time.sleep(1)
102104

103105
# Now index the new release
104106
index_release_to_elasticsearch(

0 commit comments

Comments
 (0)