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

Errp Update & Global Local to UTC add #476

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
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
44 changes: 32 additions & 12 deletions scripts/artifacts/errp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
from scripts.artifact_report import ArtifactHtmlReport
from scripts.ilapfuncs import logfunc, tsv, timeline, is_platform_windows
from scripts.ilapfuncs import logfunc, tsv, timeline, is_platform_windows, convert_local_to_utc

def get_errp(files_found, report_folder, seeker, wrap_text, time_offset):

Expand All @@ -9,8 +9,8 @@ def get_errp(files_found, report_folder, seeker, wrap_text, time_offset):
if not file_found.endswith('eRR.p'):
continue # Skip all other files

data_list =[]
timestamp = status = info_one = info_two = ''
data_list = []
timestamp = event = code = details = ''
with open(file_found, 'r') as f:
for line in f:
line = line.strip()
Expand All @@ -22,19 +22,39 @@ def get_errp(files_found, report_folder, seeker, wrap_text, time_offset):
pass
else:
line = line.split('|')
timestamp = line[0]
status = line[1]
info_one = line[2]
info_two = line[3]
data_list.append((timestamp, status, info_one, info_two))
timestamp = status = info_one = info_two = ''
if(len(line) == 1):
timestamp = line[0].strip()
timestamp_utc = str(convert_local_to_utc(timestamp))
event = ''
code = ''
details = ''
elif(len(line) == 2):
timestamp = line[0].strip()
timestamp_utc = str(convert_local_to_utc(timestamp))
event = line[1].strip()
code = ''
details = ''
elif(len(line) == 3):
timestamp = line[0].strip()
timestamp_utc = str(convert_local_to_utc(timestamp))
event = line[1].strip()
code = line[2].strip()
details = ''
elif(len(line) == 4):
timestamp = line[0].strip()
timestamp_utc = str(convert_local_to_utc(timestamp))
event = line[1].strip()
code = line[2].strip()
details = line[3].strip()

data_list.append((timestamp_utc,timestamp,event,code,details))
timestamp = event = code = details = ''


if data_list:
report = ArtifactHtmlReport('Samsung eRR.p')
report.start_artifact_report(report_folder, 'Samsung eRR.p')
report.add_script()
data_headers = ('Timestamp', 'Status', 'Info Field', 'Info Field')
data_headers = ('Timestamp','Timestamp (Local)','Event','Code','Details')
report.write_artifact_data_table(data_headers, data_list, file_found)
report.end_artifact_report()

Expand All @@ -49,6 +69,6 @@ def get_errp(files_found, report_folder, seeker, wrap_text, time_offset):
__artifacts__ = {
"Errp": (
"Wipe & Setup",
('*/system/users/service/eRR.p'),
('*/eRR.p'),
get_errp)
}
2 changes: 1 addition & 1 deletion scripts/artifacts/vlcthumbsADB.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get_vlcthumbsADB(files_found, report_folder, seeker, wrap_text, time_offset)
report = ArtifactHtmlReport('VLC Media Lib')
report.start_artifact_report(report_folder, 'VLC Media Lib', description)
report.add_script()
data_headers = ('Modified Timestamp','Thumbnail','Filename','Location' )
data_headers = ('Modified Timestamp','Thumbnail','Filename','Location')
report.write_artifact_data_table(data_headers, data_list_m, filepath, html_escape=False)
report.end_artifact_report()

Expand Down
10 changes: 10 additions & 0 deletions scripts/ilapfuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ def __init__(self, output_folder):

os.makedirs(os.path.join(self.report_folder_base, 'Script Logs'))
os.makedirs(self.temp_folder)

def convert_local_to_utc(local_timestamp_str):
# Parse the timestamp string with timezone offset, ex. 2023-10-27 18:18:29-0400
local_timestamp = datetime.strptime(local_timestamp_str, "%Y-%m-%d %H:%M:%S%z")

# Convert to UTC timestamp
utc_timestamp = local_timestamp.astimezone(timezone.utc)

# Return the UTC timestamp
return utc_timestamp

def convert_time_obj_to_utc(ts):
timestamp = ts.replace(tzinfo=timezone.utc)
Expand Down