-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve CLI and monitor on error (#29)
* Improve CLI and monitor on error * Add dev-tools for debugging * Improve debug tools and log * Fix testing * Improve config and check repo config uptodate
- Loading branch information
Showing
12 changed files
with
88 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import os | ||
|
||
os.chdir(os.path.dirname(os.path.abspath(__file__))) | ||
os.environ["DUETECTOR_LOG_LEVEL"] = "DEBUG" | ||
|
||
import re | ||
import sys | ||
from pathlib import Path | ||
|
||
from pkg_resources import load_entry_point | ||
|
||
db_file = Path("./duetector-dbcollector.sqlite3") | ||
config_file = Path("./config.toml") | ||
|
||
if __name__ == "__main__": | ||
db_file.unlink(missing_ok=True) | ||
sys.argv[0] = re.sub(r"(-script\.pyw?|\.exe)?$", "", sys.argv[0]) | ||
sys.argv.append("start") | ||
sys.argv.extend(["--config", config_file.resolve().as_posix()]) | ||
sys.exit(load_entry_point("duetector", "console_scripts", "duectl")()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
import tomli | ||
|
||
from duetector.config import ConfigLoader | ||
from duetector.tools.config_generator import ConfigGenerator | ||
|
||
_HERE = Path(__file__).parent.absolute() | ||
|
||
|
||
def test_repo_config_uptodate(tmpdir): | ||
# Check default config in repo is up to date | ||
CONFIG_IN_REPO = _HERE / ".." / "duetector/static/config.toml" | ||
GENERATED_CONFIG = tmpdir.join("g-default-config.toml") | ||
config_generator = ConfigGenerator(load=False, load_env=False) | ||
config_generator.generate(GENERATED_CONFIG) | ||
assert GENERATED_CONFIG.exists() | ||
|
||
generated_config = tomli.loads(GENERATED_CONFIG.read_text(encoding="utf-8")) | ||
repo_config = ConfigLoader( | ||
path=CONFIG_IN_REPO, | ||
load_env=False, | ||
dump_when_load=False, | ||
config_dump_dir=None, | ||
generate_config=False, | ||
).load_config() | ||
assert generated_config == repo_config | ||
|
||
|
||
if __name__ == "__main__": | ||
pytest.main(["-vv", "-s", __file__]) |