Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Commit

Permalink
Handle exceptions when logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola committed Jan 25, 2021
1 parent d1dc7ae commit 9d39ed4
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions ospd/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,19 +436,22 @@ def calculate_target_progress(self, scan_id: str) -> int:
count_dead = self.get_count_dead(scan_id)
host_progresses = self.get_current_target_progress(scan_id)

LOGGER.debug(
"Calculating scan progress with the following data:\n"
"\ttotal_hosts: %d\n\t"
"\texc_hosts: %d\n\t"
"\tcount_alive: %d\n\t"
"\tcount_dead: %d\n\t"
"\thost_prgresses: %d\n\t",
total_hosts,
exc_hosts,
count_alive,
count_dead,
sum(host_progresses.values),
)
try:
LOGGER.debug(
"Calculating scan progress with the following data:\n"
"\ttotal_hosts: %d\n\t"
"\texc_hosts: %d\n\t"
"\tcount_alive: %d\n\t"
"\tcount_dead: %d\n\t"
"\thost_prgresses: %d\n\t",
total_hosts,
exc_hosts,
count_alive,
count_dead,
sum(host_progresses.values),
)
except TypeError:
LOGGER.debug('%s: Not enough data to calculate target progress')

try:
t_prog = int(
Expand All @@ -459,6 +462,8 @@ def calculate_target_progress(self, scan_id: str) -> int:
# Consider the case in which all hosts are dead or excluded
LOGGER.debug('%s: All hosts dead or excluded.')
t_prog = ScanProgress.FINISHED.value
except TypeError:
LOGGER.debug('%s: Not enough data to calculate target progress')

return t_prog

Expand Down

0 comments on commit 9d39ed4

Please sign in to comment.