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

Update tom-dev #39

Merged
merged 20 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b5238ac
comments added on system.py
LorenzoFerraces Dec 17, 2023
f7c8c64
working on test_system.py
LorenzoFerraces Dec 17, 2023
8bf3659
failing test_get_module_version
LorenzoFerraces Dec 29, 2023
43d1037
system tests and comments about errors
LorenzoFerraces Dec 30, 2023
9c55c70
added tests from_utf8, from_unicode, get_file_modificacion_time
LorenzoFerraces Jan 2, 2024
183f21e
system tests almost finished
LorenzoFerraces Jan 3, 2024
5c721f5
system.py test almost finished
LorenzoFerraces Jan 4, 2024
882c39f
test changes
LorenzoFerraces Jan 7, 2024
9d347f8
Merge branch 'main' of https://github.com/tomasohara/mezcla into lore…
LorenzoFerraces Jan 7, 2024
d665282
finished test_system.py with changes to print_full_stack and trace_stack
LorenzoFerraces Jan 7, 2024
f4de8e1
updated unittest_wwrapper.py and system.py
LorenzoFerraces Jan 13, 2024
168d9c4
updated test that used capsys, monkeypatch marked as xfail
LorenzoFerraces Jan 14, 2024
d2a03b2
updated requirements.txt
LorenzoFerraces Jan 14, 2024
8c90915
corrected milisecond precision in get_file_modification_time tests
LorenzoFerraces Jan 14, 2024
9bcb985
proxy methods for monkeypatch
LorenzoFerraces Jan 14, 2024
4ad1287
Merge pull request #36 from tomasohara/tom-dev
tomasohara Jan 15, 2024
42cebaf
Merge pull request #37 from tomasohara/tom-dev
tomasohara Jan 15, 2024
0bced77
replaced monkeypatch proxy methods with direct access to instance var…
LorenzoFerraces Jan 15, 2024
6527c5a
Merge branch 'main' into lorenzo-dev
LorenzoFerraces Jan 15, 2024
c2a6210
Merge pull request #38 from tomasohara/lorenzo-dev
tomasohara Jan 16, 2024
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
31 changes: 15 additions & 16 deletions mezcla/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

# Standard packages
from collections import defaultdict, OrderedDict
import importlib_metadata
import datetime
import inspect
import os
Expand Down Expand Up @@ -369,10 +370,10 @@ def print_full_stack(stream=sys.stderr):
return


def trace_stack(level=debug.VERBOSE):
def trace_stack(level=debug.VERBOSE, stream=sys.stderr):
"""Output stack trace to stderr (if at trace LEVEL or higher)"""
if debug.debugging(level):
print_full_stack()
print_full_stack(stream)
return


Expand Down Expand Up @@ -612,7 +613,7 @@ def read_directory(directory):
# Note simple wrapper around os.listdir with tracing
# EX: (intersection(["init.d", "passwd"], read_directory("/etc")))
files = os.listdir(directory)
debug.trace_fmtd(5, "read_directory({d}) => {r}", d=directory, r=files, max_len=4096)
debug.trace_fmtd(5, "read_directory({d}) => {r}", d=directory, r=files)
return files


Expand Down Expand Up @@ -1065,24 +1066,22 @@ def get_module_version(module_name):
# note: used in bash function (alias):
# python-module-version() = { python -c "print(get_module_version('$1))"; }'

# Try to load the module with given name
# TODO: eliminate eval and just import directly
try:
eval("import {m}".format(m=module_name)) # pylint: disable=eval-used
except:
debug.trace_fmtd(6, "Exception importing module '{m}': {exc}",
m=module_name, exc=get_exception())
return "-1.-1.-1"
## OLD:
# try:
# ## BAD: eval("import {m}".format(m=module_name)) # pylint: disable=eval-used
# exec("import {m}".format(m=module_name)) # pylint: disable=eval-used
# except:
# debug.trace_fmtd(6, "Exception importing module '{m}': {exc}",
# m=module_name, exc=get_exception())
# return "-1.-1.-1"

# Try to get the version number for the module
# TODO: eliminate eval and use getattr()
# TODO: try other conventions besides module.__version__ member variable
version = "?.?.?"
try:
version = eval("module_name.__version__") # pylint: disable=eval-used
## OLD: version = eval(f"{module_name}.__version__") # pylint: disable=eval-used
version = importlib_metadata.version(module_name)
except:
debug.trace_fmtd(6, "Exception evaluating '{m}.__version__': {exc}",
m=module_name, exc=get_exception())
debug.trace_fmtd(6, f"Exception evaluating metadada from {module_name}: {get_exception()}")
## TODO: version = "0.0.0"
return version

Expand Down
Loading