|
14 | 14 | import xml.etree.ElementTree as ET |
15 | 15 | from contextlib import suppress |
16 | 16 | from functools import cached_property |
| 17 | +from inspect import cleandoc |
17 | 18 | from itertools import groupby |
18 | 19 | from operator import attrgetter |
19 | 20 | from traceback import format_exc as traceback_format_exc |
@@ -2073,7 +2074,7 @@ def pipeline_class(self): |
2073 | 2074 |
|
2074 | 2075 | @property |
2075 | 2076 | def job(self): |
2076 | | - with suppress(NoSuchJobError): |
| 2077 | + with suppress(redis.exceptions.ConnectionError, NoSuchJobError): |
2077 | 2078 | return Job.fetch( |
2078 | 2079 | str(self.run_id), |
2079 | 2080 | connection=django_rq.get_connection(), |
@@ -2219,20 +2220,19 @@ def stop_run(self): |
2219 | 2220 | ) |
2220 | 2221 | self.set_run_stopped() |
2221 | 2222 |
|
2222 | | - def delete_run(self, delete_self=True): |
| 2223 | + def delete_run(self): |
2223 | 2224 | if job := self.job: |
2224 | 2225 | job.delete() |
2225 | 2226 |
|
2226 | | - if delete_self: |
2227 | | - self.delete() |
2228 | | - |
2229 | 2227 | def delete(self, *args, **kwargs): |
2230 | 2228 | """ |
2231 | 2229 | Before deletion of the run instance, try to stop the run execution. |
2232 | 2230 | """ |
2233 | 2231 | with suppress(redis.exceptions.ConnectionError, AttributeError): |
2234 | 2232 | self.stop_run() |
2235 | 2233 |
|
| 2234 | + self.delete_run() |
| 2235 | + |
2236 | 2236 | return super().delete(*args, **kwargs) |
2237 | 2237 |
|
2238 | 2238 | def append_to_log(self, message, is_multiline=False): |
@@ -2366,16 +2366,20 @@ def pipeline_class(self): |
2366 | 2366 | from vulnerabilities.importers import IMPORTERS_REGISTRY |
2367 | 2367 | from vulnerabilities.improvers import IMPROVERS_REGISTRY |
2368 | 2368 | from vulnerabilities.pipelines.exporters import EXPORTERS_REGISTRY |
| 2369 | + from vulnerabilities.pipelines.management import MANAGEMENT_REGISTRY |
2369 | 2370 |
|
2370 | | - pipeline_registry = IMPORTERS_REGISTRY | IMPROVERS_REGISTRY | EXPORTERS_REGISTRY |
| 2371 | + pipeline_registry = ( |
| 2372 | + IMPORTERS_REGISTRY | IMPROVERS_REGISTRY | EXPORTERS_REGISTRY | MANAGEMENT_REGISTRY |
| 2373 | + ) |
2371 | 2374 |
|
2372 | 2375 | return pipeline_registry[self.pipeline_id] |
2373 | 2376 |
|
2374 | 2377 | @property |
2375 | 2378 | def description(self): |
2376 | 2379 | """Return the pipeline class.""" |
| 2380 | + |
2377 | 2381 | if self.pipeline_class: |
2378 | | - return self.pipeline_class.__doc__ |
| 2382 | + return cleandoc(self.pipeline_class.__doc__ or "") |
2379 | 2383 |
|
2380 | 2384 | @property |
2381 | 2385 | def all_runs(self): |
|
0 commit comments