Skip to content

Commit

Permalink
span timestamp atts
Browse files Browse the repository at this point in the history
  • Loading branch information
dpacheconr committed Nov 14, 2023
1 parent 5a3adcb commit 7e2d9ae
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
32 changes: 30 additions & 2 deletions src/custom_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ def do_fastcore_decode(obj):
def do_time(string):
return (int(round(time.mktime(parse(string).timetuple())) * 1000000000))

def do_time_ms(string):
return (int(round(time.mktime(parse(string).timetuple())) * 1000))

def do_string(string):
return str(string).lower().replace(" ", "")

Expand Down Expand Up @@ -46,20 +49,28 @@ def parse_attributes(obj,att_to_drop):
# except:
# print("Unable to parse GHA_ATTRIBUTES_DROP, check your configuration")

for attribute in obj:
for attribute in list(obj):
attribute_name = str(attribute).lower()
if attribute_name.endswith("_at"):
new_Att_name=attribute_name+"_ms"
obj_atts[new_Att_name]=do_time_ms(obj[attribute])

if attribute_name not in attributes_to_drop:
if do_parse(obj[attribute]):
if type(obj[attribute]) is dict:
for sub_att in obj[attribute]:
attribute_name = do_string(attribute)+"."+do_string(sub_att)
if attribute_name not in attributes_to_drop:
if attribute_name not in attributes_to_drop:
if type(obj[attribute][sub_att]) is dict:
for att in obj[attribute][sub_att]:
attribute_name = do_string(attribute)+"."+do_string(sub_att)+"."+do_string(att)
if attribute_name not in attributes_to_drop:
obj_atts[attribute_name]=str(obj[attribute][sub_att][att])
if attribute_name.endswith("_at"):
new_Att_name=attribute_name+"_ms"
obj_atts[new_Att_name]=do_time_ms(obj[attribute][sub_att][att])


elif type(obj[attribute][sub_att]) is list:
for key in obj[attribute][sub_att]:
if type(key) is dict:
Expand All @@ -68,14 +79,25 @@ def parse_attributes(obj,att_to_drop):
attribute_name = do_string(attribute)+"."+do_string(sub_att)+"."+do_string(att)
if attribute_name not in attributes_to_drop:
obj_atts[attribute_name]=str(key[att])
if attribute_name.endswith("_at"):
new_Att_name=attribute_name+"_ms"
obj_atts[new_Att_name]=do_time_ms(key[att])

else:
attribute_name = do_string(attribute)+"."+do_string(sub_att)
if attribute_name not in attributes_to_drop:
obj_atts[attribute_name]=str(key)
if attribute_name.endswith("_at"):
new_Att_name=attribute_name+"_ms"
obj_atts[new_Att_name]=do_time_ms(key)

else:
attribute_name = do_string(attribute)+"."+do_string(sub_att)
if attribute_name not in attributes_to_drop:
obj_atts[attribute_name]=str(obj[attribute][sub_att])
if attribute_name.endswith("_at"):
new_Att_name=attribute_name+"_ms"
obj_atts[new_Att_name]=do_time_ms(obj[attribute][sub_att])

elif type(obj[attribute]) is list:
for key in obj[attribute]:
Expand All @@ -85,9 +107,15 @@ def parse_attributes(obj,att_to_drop):
attribute_name = do_string(attribute)+"."+do_string(att)
if attribute_name not in attributes_to_drop:
obj_atts[attribute_name]=str(key[att])
if attribute_name.endswith("_at"):
new_Att_name=attribute_name+"_ms"
obj_atts[new_Att_name]=do_time_ms(key[att])
else:
if do_parse(obj[attribute]):
attribute_name = do_string(attribute)
if attribute_name not in attributes_to_drop:
obj_atts[attribute_name]=str(obj[attribute])
if attribute_name.endswith("_at"):
new_Att_name=attribute_name+"_ms"
obj_atts[new_Att_name]=do_time_ms(obj[attribute])
return obj_atts
5 changes: 4 additions & 1 deletion src/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@
except Exception as e:
print("Error exporting log line ERROR: ", e)
except IOError as e:
print("Log file does not exist: "+str(job["name"])+"/"+str(step['number'])+"_"+str(step['name'].replace("/",""))+".txt")
if step['conclusion'] != 'skipped':
print("ERROR: Log file does not exist: "+str(job["name"])+"/"+str(step['number'])+"_"+str(step['name'].replace("/",""))+".txt")
else:
pass

if step['conclusion'] == 'skipped':
child_1.update_name(name=str(step['name']+"-SKIPPED"))
Expand Down

0 comments on commit 7e2d9ae

Please sign in to comment.