Skip to content

Commit

Permalink
Merge pull request #4 from MikroElektronika/topic/switch-to-dbp
Browse files Browse the repository at this point in the history
Updated according to new DBP.
  • Loading branch information
StrahinjaJacimovic authored Dec 24, 2024
2 parents d1785c2 + 14f58ee commit 55809af
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions scripts/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__':
Expand All @@ -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("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 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(30)
time.sleep(1)

# Now index the new release
index_release_to_elasticsearch(
Expand Down

0 comments on commit 55809af

Please sign in to comment.