Wrote two functions, 1. uploads a gzip file to Artifactory
and 2. listens to the Kafka topic
.
As further steps, wanted to validate whether the upload is successful within 5 minutes by listening to the Kafka topic for the keyword - push_status: True
, else fail the script.
I'm kind of stumped with the logic that is more elegant and pythonic on the else
part.
Code snippet:
upload_status = fetch_kafka_topic("topic", "brokers") #Returns messages from particular topic.
if bool(upload_status) == True: #Checks if the returned dictionary is empty or not
if upload_status['file_sha'] == EXPECTED_SHA: # CHeck if the SHA Values matches with the one I've in prior.
if upload_status['push_status'] == True:
print("upload is successful ...")
else:
Monitor and query the kafka topic again for the keyword for 5 mins and fail the build if it exceeds the timeout.