Skip to content

Commit

Permalink
Prevent command.log from being appended to when run in a loop (mvt-pr…
Browse files Browse the repository at this point in the history
…oject#501)

* Prevent command.log from being appended to when run in a loop

* Ignore a rather stupid vulnerability scan alert for pip
  • Loading branch information
roaree authored May 27, 2024
1 parent 555e49f commit f0dbe0b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .safety-policy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Safety Security and License Configuration file
# We recommend checking this file into your source control in the root of your Python project
# If this file is named .safety-policy.yml and is in the same directory where you run `safety check` it will be used by default.
# Otherwise, you can use the flag `safety check --policy-file <path-to-this-file>` to specify a custom location and name for the file.
# To validate and review your policy file, run the validate command: `safety validate policy_file --path <path-to-this-file>`
security: # configuration for the `safety check` command
ignore-vulnerabilities: # Here you can list multiple specific vulnerabilities you want to ignore (optionally for a time period)
67599: # Example vulnerability ID
reason: disputed, inapplicable
9 changes: 9 additions & 0 deletions mvt/common/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ def _setup_logging(self):
)
file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(formatter)

# MVT can be run in a loop
# Old file handlers stick around in subsequent loops
# Remove any existing logging.FileHandler instances
for handler in logger.handlers:
if isinstance(handler, logging.FileHandler):
logger.removeHandler(handler)

# And finally add the new one
logger.addHandler(file_handler)

def _store_timeline(self) -> None:
Expand Down

0 comments on commit f0dbe0b

Please sign in to comment.