Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
LukicMMikroe committed Jun 13, 2024
1 parent f8041f1 commit 7eb2550
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions scripts/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,9 @@ async def package_asset(source_dir, output_dir, arch, entry_name, token, repo, t
'package_changed': package_changed,
'install_location': install_location
}
print(f"DOCUMENT TO INDEX: {doc}")

resp = es.index(index=index_name, doc_type='necto_package', id=name_without_extension, body=doc)
print(f"INDEX RESPONSE: {resp}")

def hash_file(filename):
"""Generate MD5 hash of a file."""
Expand Down Expand Up @@ -707,8 +708,6 @@ async def main(token, repo, tag_name):
""" Main function to orchestrate packaging and uploading assets """
num_of_retries = 1
while True:
print(os.environ['ES_USER'])
print(os.environ['ES_PASSWORD'])
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():
Expand Down Expand Up @@ -780,22 +779,23 @@ async def main(token, repo, tag_name):
clocksGenerator = GenerateClocks(input_directory, output_file)
clocksGenerator.generate()
async with aiohttp.ClientSession() as session:
await upload_release_asset(session, token, repo, tag_name, "clocks.json")
upload_result = await upload_release_asset(session, token, repo, tag_name, "clocks.json")
doc = {
'name': "clocks",
'display_name' : "Clocks file",
'author' : "MIKROE",
'hidden' : True,
'type' : "mcu_clocks",
'version' : release_details['tag_name'],
'created_at': asset['created_at'],
'updated_at': asset['updated_at'],
'version' : tag_name.replace("v", ""),
'created_at': upload_result['created_at'],
'updated_at': upload_result['updated_at'],
'category': "MCU Package",
'download_link': asset['url'],
'download_link': upload_result['url'],
'package_changed' : True,
'install_location' : "%APPLICATION_DATA_DIR%/clocks.json"
}
print(f"CLOCKS DOC: {doc}")
resp = es.index(index=index_name, doc_type='necto_package', id="clocks", body=doc)
print(f"INDEX RESPONSE: {resp}")
# generate schemas.json
input_directory = "./"
output_file = "./schemas.json"
Expand All @@ -809,15 +809,16 @@ async def main(token, repo, tag_name):
'author' : "MIKROE",
'hidden' : True,
'type' : "mcu_schemas",
'version' : release_details['tag_name'],
'created_at': asset['created_at'],
'updated_at': asset['updated_at'],
'version' : tag_name.replace("v", ""),
'created_at': upload_result['created_at'],
'updated_at': upload_result['updated_at'],
'category': "MCU Package",
'download_link': asset['url'],
'download_link': upload_result['url'],
'package_changed' : True,
'install_location' : "%APPLICATION_DATA_DIR%/schemas.json"
}
print(f"SCHEMA DOC: {doc}")
resp = es.index(index=index_name, doc_type='necto_package', id="schemas", body=doc)
print(f"INDEX RESPONSE: {resp}")

if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Upload directories as release assets.")
Expand Down

0 comments on commit 7eb2550

Please sign in to comment.