Skip to content

Commit

Permalink
Ianhelle/mpconfigedit fix from main 2022 05 22 (#396)
Browse files Browse the repository at this point in the history
* Fix for MpConfigEdit ValueError

Updating version for hotfix

# Conflicts:
#	msticpy/_version.py

* MpConfig edit throws error with invalid file path.

* Updating Dockerfile source to mcr anaconda
  • Loading branch information
ianhelle authored May 10, 2022
1 parent bd96d40 commit 857835d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# See here for image contents: https://hub.docker.com/r/jupyter/scipy-notebook
FROM jupyter/scipy-notebook
FROM mcr.microsoft.com/vscode/devcontainers/anaconda
LABEL maintainer="Msticpy Dev Team <[email protected]>"

#installing Msticpy requirements and dependencies
Expand Down
3 changes: 1 addition & 2 deletions msticpy/config/mp_config_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ def __init__(
if not self.mp_conf_file.current_file and conf_filepath:
self.mp_conf_file.current_file = conf_filepath
elif isinstance(settings, str):
self.mp_conf_file = MpConfigFile()
self.mp_conf_file.load_from_file(file=settings)
self.mp_conf_file = MpConfigFile(file=settings)
else:
self.mp_conf_file = MpConfigFile()
self.mp_conf_file.load_default()
Expand Down
5 changes: 2 additions & 3 deletions msticpy/config/mp_config_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import io
import os
import pprint
import warnings
from contextlib import redirect_stdout, suppress
from datetime import datetime
from pathlib import Path
Expand Down Expand Up @@ -118,7 +117,7 @@ def __init__(
self.mp_config_def_path is not None
and not Path(self.mp_config_def_path).is_file()
):
warnings.warn(
self.set_status(
"MSTICPYCONFIG env variable is pointing to invalid path."
+ self.mp_config_def_path
)
Expand All @@ -137,7 +136,7 @@ def __init__(
if self.current_file and Path(self.current_file).is_file():
self.load_from_file(self.current_file)
else:
raise ValueError(f"File not found: '{self.current_file}'.")
self.set_status(f"Filename does not exist: '{self.current_file}'.")

@property
def current_file(self):
Expand Down
4 changes: 2 additions & 2 deletions prospector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ ignore-paths:
pyroma:
run: true

pycodestyle:
pep8:
full: true
disable: [
E501, # Line length handled by Black
]

pydocstyle:
pep257:
disable: [
# Disable because not part of PEP257 official convention:
# see http://pep257.readthedocs.io/en/latest/error_codes.html
Expand Down
9 changes: 5 additions & 4 deletions tests/config/test_mp_config_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ def test_mp_edit_load_params():
for key in orig_settings.keys():
check.equal(orig_settings[key], mp_conf.mp_controls.mp_config[key])

# Test no existing MPConfig
# Test invalid file in MPConfig env and with file parameter.
# should load without exception
with custom_mp_config(str(config_path)):
os.environ["MSTICPYCONFIG"] = "./invalid_file.yaml"
with pytest.raises(ValueError):
with pytest.warns(UserWarning):
mp_conf = MpConfigEdit()
mp_conf = MpConfigEdit()

mp_conf = MpConfigEdit(settings="./invalid_file.yaml")

0 comments on commit 857835d

Please sign in to comment.