Skip to content

Commit

Permalink
deepsource fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mlodic committed Dec 6, 2023
1 parent 311133e commit e96f180
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion api_app/analyzers_manager/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def _monkeypatch(self, patches: list = None):
)
return super()._monkeypatch(patches)

def health_check(self, user: User) -> bool:
def health_check(self, user: User = None) -> bool:
"""
basic health check: if instance is up or not (timeout - 10s)
"""
Expand Down
13 changes: 7 additions & 6 deletions api_app/analyzers_manager/observable_analyzers/maxmind.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ def run(self):
for db in db_names:
try:
db_location = _get_db_location(db)
if not os.path.isfile(db_location):
if not self._update_db(db, self._api_key_name):
raise AnalyzerRunException(
f"failed extraction of maxmind db {db},"
" reached max number of attempts"
)
if not os.path.isfile(db_location) and not self._update_db(
db, self._api_key_name
):
raise AnalyzerRunException(
f"failed extraction of maxmind db {db},"
" reached max number of attempts"
)
if not os.path.exists(db_location):
raise maxminddb.InvalidDatabaseError(
"database location does not exist"
Expand Down
5 changes: 2 additions & 3 deletions api_app/analyzers_manager/observable_analyzers/tor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
class Tor(classes.ObservableAnalyzer):
def run(self):
result = {"found": False}
if not os.path.isfile(database_location):
if not self.update():
raise AnalyzerRunException("Failed extraction of tor db")
if not os.path.isfile(database_location) and not self.update():
raise AnalyzerRunException("Failed extraction of tor db")

if not os.path.exists(database_location):
raise AnalyzerRunException(
Expand Down
2 changes: 1 addition & 1 deletion api_app/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def name(self):
@property
@abstractmethod
def python_base_path(cls) -> PosixPath:
...
NotImplementedError()

@classmethod
def all_subclasses(cls):
Expand Down
9 changes: 6 additions & 3 deletions api_app/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,12 @@ def post_delete_python_module_periodic_tasks(
def post_delete_python_config_periodic_tasks(
sender: Type[PythonConfig], instance: PythonConfig, using, origin, *args, **kwargs
):
if issubclass(sender, PythonConfig):
if hasattr(instance, "health_check_task") and instance.health_check_task:
instance.health_check_task.delete()
if (
issubclass(sender, PythonConfig)
and hasattr(instance, "health_check_task")
and instance.health_check_task
):
instance.health_check_task.delete()


@receiver(models.signals.post_save)
Expand Down

0 comments on commit e96f180

Please sign in to comment.