Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated according to new DBP. #4

Merged
merged 2 commits into from
Dec 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading