From b688ed63b9d0163617d6e7d9d7315ba0a2fffaca Mon Sep 17 00:00:00 2001 From: strahi-linux Date: Tue, 24 Dec 2024 12:47:51 +0100 Subject: [PATCH 1/2] Updated according to new DBP. --- scripts/index.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/index.py b/scripts/index.py index 804c3ff..41a0576 100644 --- a/scripts/index.py +++ b/scripts/index.py @@ -64,17 +64,18 @@ def index_release_to_elasticsearch(es : Elasticsearch, index_name, release_detai 'hidden': False, 'type': 'legacy_sdk', 'version': version, - 'created_at' : asset['created_at'], - 'updated_at' : asset['updated_at'], + 'created_at': asset['created_at'], + 'updated_at': asset['updated_at'], 'category': 'Software Development Kit', 'download_link': asset['url'], # Adjust as needed for actual URL - 'install_location' : f"%APPLICATION_DATA_DIR%/packages/legacy/{name_without_extension.lower()}", - 'package_changed': True + 'install_location': f"%APPLICATION_DATA_DIR%/packages/legacy/{name_without_extension.lower()}", + 'package_changed': True, + 'gh_package_name': f"{name_without_extension}.7z" } # Index the document if doc: - resp = es.index(index=index_name, doc_type='necto_package', id=name_without_extension, body=doc) + resp = es.index(index=index_name, doc_type=None, id=name_without_extension, body=doc) print(f"{resp["result"]} {resp['_id']}") if __name__ == '__main__': @@ -87,18 +88,19 @@ def index_release_to_elasticsearch(es : Elasticsearch, index_name, release_detai # Elasticsearch instance used for indexing num_of_retries = 1 + print(f"Trying to connect to ES") while True: - print(f"Trying to connect to ES. Connection retry: {num_of_retries}") es = Elasticsearch([os.environ['ES_HOST']], http_auth=(os.environ['ES_USER'], os.environ['ES_PASSWORD'])) if es.ping(): break - # Wait for 30 seconds and try again if connection fails + # Wait for 2 seconds and try again if connection fails if 10 == num_of_retries: # Exit if it fails 10 times, something is wrong with the server raise ValueError("Connection to ES failed!") + print(f"Connection retry: {num_of_retries}") num_of_retries += 1 - time.sleep(30) + time.sleep(2) # Now index the new release index_release_to_elasticsearch( From 14f58ee62eddf952ab5c7a17b3aa3108468a5967 Mon Sep 17 00:00:00 2001 From: strahi-linux Date: Tue, 24 Dec 2024 12:57:59 +0100 Subject: [PATCH 2/2] Updated --- scripts/index.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/index.py b/scripts/index.py index 41a0576..be9c031 100644 --- a/scripts/index.py +++ b/scripts/index.py @@ -88,19 +88,19 @@ def index_release_to_elasticsearch(es : Elasticsearch, index_name, release_detai # Elasticsearch instance used for indexing num_of_retries = 1 - print(f"Trying to connect to ES") + print("Trying to connect to ES") while True: es = Elasticsearch([os.environ['ES_HOST']], http_auth=(os.environ['ES_USER'], os.environ['ES_PASSWORD'])) if es.ping(): break - # Wait for 2 seconds and try again if connection fails + # Wait 1 second and try again if connection fails if 10 == num_of_retries: # Exit if it fails 10 times, something is wrong with the server raise ValueError("Connection to ES failed!") print(f"Connection retry: {num_of_retries}") num_of_retries += 1 - time.sleep(2) + time.sleep(1) # Now index the new release index_release_to_elasticsearch(