Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion docs/source/dev/data_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Output of the different `hermes` subcommands consequently are valid JSON-LD file
subdirectories of the `.hermes/` directory that is created in the root of the project directory (see following diagram).
```
.hermes
│ audit.log
├──curate
│ └──result
│ ├──codemeta.json
Expand Down
12 changes: 7 additions & 5 deletions src/hermes/commands/clean/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ def __call__(self, args: argparse.Namespace) -> None:
self.log.info("Removing HERMES caches...")

# Naive implementation for now... check errors, validate directory, don't construct the path ourselves, etc.
shutil.rmtree(args.path / '.hermes')

def load_settings(self, args: argparse.Namespace):
"""No settings are needed for the clean command."""
pass
try:
path = args.path / '.hermes'
shutil.rmtree(path)
except FileNotFoundError:
pass
except Exception as exc:
self.log.warning(f"{path} couldn't be cleaned: {exc}")
9 changes: 8 additions & 1 deletion src/hermes/commands/init/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,14 @@ def clean_up_files(self, aborted: bool) -> None:
sc.echo("Cleaning unused files...")
hidden_hermes_path = Path(".hermes")
if hidden_hermes_path.exists() and hidden_hermes_path.is_dir():
shutil.rmtree(hidden_hermes_path)
try:
shutil.rmtree(hidden_hermes_path)
except Exception as exc:
sc.echo(
f"{hidden_hermes_path} couldn't be cleaned: {exc}",
formatting=sc.Formats.WARNING,
log_as=logging.ERROR
)
if aborted:
if not self.hermes_was_already_installed:
for path in reversed(self.new_created_paths):
Expand Down
18 changes: 4 additions & 14 deletions src/hermes/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

'formatters': {
'plain': {'format': "%(message)s"},
'logfile': {'format': "%(created)16f:%(name)20s:%(levelname)10s | %(message)s"},
'auditlog': {'format': "%(asctime)s %(name)-20s %(message)s"},
'logfile': {'format': "%(created)16f:%(name)20s:%(levelname)10s | %(message)s"}
},

'handlers': {
Expand All @@ -32,22 +31,14 @@
'formatter': "logfile",
'level': "DEBUG",
'filename': "./hermes.log",
},

'auditfile': {
'class': "logging.FileHandler",
'formatter': "plain",
'level': "DEBUG",
'filename': "./.hermes/audit.log",
'mode': "w",
},
}
},

'loggers': {
'cli': {'level': "DEBUG", 'handlers': ['terminal']},
'hermes': {'level': "DEBUG", 'handlers': ['terminal', 'logfile']},
'audit': {'level': "DEBUG", 'handlers': ['terminal', 'logfile']},
},
'audit': {'level': "DEBUG", 'handlers': ['terminal', 'logfile']}
}
}

_loggers = {}
Expand All @@ -59,7 +50,6 @@ def init_logging():

# Make sure the directories to hold the log files exists (or else create)
pathlib.Path(_logging_config['handlers']['logfile']['filename']).parent.mkdir(exist_ok=True, parents=True)
pathlib.Path(_logging_config['handlers']['auditfile']['filename']).parent.mkdir(exist_ok=True, parents=True)

# Inintialize logging system
import logging.config
Expand Down
Loading