Skip to content

Commit f4818f3

Browse files
committed
Made changes
1 parent 7cdb200 commit f4818f3

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

scripts/2-process/wikipedia_process.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@
88
import csv
99
import os
1010
import sys
11+
import textwrap
1112
import traceback
1213

1314
# Third-party
1415
import pandas as pd
16+
from pygments import highlight
17+
from pygments.formatters import TerminalFormatter
18+
from pygments.lexers import PythonTracebackLexer
1519

1620
# Add parent directory so shared can be imported
1721
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
@@ -115,7 +119,7 @@ def process_least_language_usage(args, count_data):
115119

116120
def process_language_representation(args, count_data):
117121
"""
118-
Processing count data: language representation
122+
Processing count data: Language representation
119123
"""
120124
LOGGER.info(process_language_representation.__doc__.strip())
121125
data = {}
@@ -170,13 +174,22 @@ def main():
170174
LOGGER.info(e.message)
171175
else:
172176
LOGGER.error(e.message)
173-
sys.exit(e.code)
177+
sys.exit(e.exit_code)
174178
except SystemExit as e:
175-
LOGGER.error(f"System exit with code: {e.code}")
179+
if e.code != 0:
180+
LOGGER.error(f"System exit with code: {e.code}")
176181
sys.exit(e.code)
177182
except KeyboardInterrupt:
178183
LOGGER.info("(130) Halted via KeyboardInterrupt.")
179184
sys.exit(130)
180185
except Exception:
181-
LOGGER.exception(f"(1) Unhandled exception: {traceback.format_exc()}")
186+
traceback_formatted = textwrap.indent(
187+
highlight(
188+
traceback.format_exc(),
189+
PythonTracebackLexer(),
190+
TerminalFormatter(),
191+
),
192+
" ",
193+
)
194+
LOGGER.critical(f"(1) Unhandled exception:\n{traceback_formatted}")
182195
sys.exit(1)

0 commit comments

Comments
 (0)