Skip to content

Commit

Permalink
Feature 144 log update (#158)
Browse files Browse the repository at this point in the history
* Updated .gitignore and tass.base main error catching and logging.

* Added log folder to .gitignore and removed commented code from __main__py of tass-base.

* Removed commented code and updated for flake8 compatibility.

* Updated page_reader.py and secrets.py for logging purposes.
  • Loading branch information
DominicParent authored Sep 11, 2024
1 parent ee416aa commit fd293d4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# TASS related files / folders
configs/
results/
log/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
21 changes: 17 additions & 4 deletions tass-base/src/tass/base/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def _make_report(registrar, func_name, *args, **kwargs):

# TODO: add logging messages.


def main(args):
"""
Starting point for execution of tests.
Expand All @@ -46,9 +47,16 @@ def main(args):
path = Path(args.file).resolve()

log.info("Preparing job using file @: %s", path)
with open(path) as f:

try:
f = open(path)
# open test file
except IOError as e:
log.error("An IOError occured: %s" % e)
return
with f:
job = json.load(f)

runs = parse_runs(path, job)
registrar = parse_reporters(job)

Expand All @@ -65,15 +73,20 @@ def main(args):
log.info("")
log.info("> > > Finished Case: %s < < <", case.uuid)
log.info("")

_make_report(registrar, "report", test)
_make_report(registrar, 'end_report', test)

Path('results').mkdir(exist_ok=True)
for test in runs:
file_name = test.uuid + '---' + test.start_time + '.json'
result_path = Path().resolve() / "results" / file_name
with open(result_path, 'w+', encoding='utf-8') as f:
try:
f = open(result_path, 'w+', encoding='utf-8')
except IOError as e:
log.error("An IOError occured: %s" % e)
return
with f:
json.dump(test, f, indent=4, cls=TassEncoder)


Expand Down
7 changes: 6 additions & 1 deletion tass-base/src/tass/base/core/page_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ def _page(self, file_key, page_key):
def _load_pages(self, file_key):
file_name = file_key + '.json'
page = self._page_root.resolve() / file_name
with open(page, encoding='utf-8') as file:
try:
file = open(page, encoding='utf-8')
except IOError as e:
log.error("An IOError occured: %s" % e)
return
with file:
self.page_dict[file_key] = json.load(file)
return self.page_dict[file_key]

Expand Down
7 changes: 6 additions & 1 deletion tass-base/src/tass/base/core/secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ def __init__(self):

def add_source(self, config_path):
path = Path(config_path).resolve()
with open(path) as conf:
try:
conf = open(path)
except IOError as e:
log.error("An IOError occured: %s" % e)
return
with conf:
config = json.load(conf)

key = config['source']['name']
Expand Down

0 comments on commit fd293d4

Please sign in to comment.