Skip to content

Commit

Permalink
More refinement
Browse files Browse the repository at this point in the history
  • Loading branch information
cscollett committed Aug 30, 2024
1 parent e6fa590 commit 2a83799
Showing 1 changed file with 28 additions and 19 deletions.
47 changes: 28 additions & 19 deletions summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ def analyze_logs(log_content):
python_version = None
issues_found = False

# Improved patterns to capture actual output content
id_pattern = re.compile(r'ID: (.+)')
version_id_pattern = re.compile(r'VERSION_ID: "?(.+?)"?')
version_codename_pattern = re.compile(r'VERSION_CODENAME: (.+)')
full_version_pattern = re.compile(r'FULL VERSION: (.+)')
python_version_pattern = re.compile(r'LANGUAGE VERSION: (.+)')
# Refined patterns to capture actual output content
id_pattern = re.compile(r'^#\d+ \d+\.\d+ ID: (.+)')
version_id_pattern = re.compile(r'^#\d+ \d+\.\d+ VERSION_ID: "?(.+?)"?')
version_codename_pattern = re.compile(r'^#\d+ \d+\.\d+ VERSION_CODENAME: (.+)')
full_version_pattern = re.compile(r'^#\d+ \d+\.\d+ FULL VERSION: (.+)')
python_version_pattern = re.compile(r'^#\d+ \d+\.\d+ LANGUAGE VERSION: (.+)')

# Patterns to capture possible errors
error_patterns = [
Expand All @@ -57,25 +57,34 @@ def analyze_logs(log_content):
re.compile(r'.*critical.*', re.IGNORECASE),
]

# Flag to only start capturing after seeing the environment start marker
in_environment_output = False
log_lines = log_content.splitlines()

for line in log_lines:
line = line.strip() # Remove leading/trailing spaces

if os_id is None and id_pattern.search(line):
os_id = id_pattern.search(line).group(1)

if version_id is None and version_id_pattern.search(line):
version_id = version_id_pattern.search(line).group(1)

if version_codename is None and version_codename_pattern.search(line):
version_codename = version_codename_pattern.search(line).group(1)

if full_version is None and full_version_pattern.search(line):
full_version = full_version_pattern.search(line).group(1)
if "--------ENVIRONMENT OUTPUT--------" in line:
if in_environment_output:
break # Stop capturing after the end marker
in_environment_output = True
continue

if python_version is None and python_version_pattern.search(line):
python_version = python_version_pattern.search(line).group(1)
if in_environment_output:
if os_id is None and id_pattern.search(line):
os_id = id_pattern.search(line).group(1)

if version_id is None and version_id_pattern.search(line):
version_id = version_id_pattern.search(line).group(1)

if version_codename is None and version_codename_pattern.search(line):
version_codename = version_codename_pattern.search(line).group(1)

if full_version is None and full_version_pattern.search(line):
full_version = full_version_pattern.search(line).group(1)

if python_version is None and python_version_pattern.search(line):
python_version = python_version_pattern.search(line).group(1)

for pattern in error_patterns:
if pattern.search(line):
Expand Down

0 comments on commit 2a83799

Please sign in to comment.