Skip to content

Commit 1012b6d

Browse files
committed
Fixes formatting errors
1 parent 4595185 commit 1012b6d

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

deltascan/cli/cmd.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
from rich.columns import Columns
1717
import threading
1818
import signal
19-
import select
19+
import select
2020
import sys
2121

22+
2223
def interactive_shell(_app, _ui, _is_interactive):
2324
"""
2425
Starts an interactive shell for the application.
@@ -33,15 +34,15 @@ def interactive_shell(_app, _ui, _is_interactive):
3334
shell = Shell(_app)
3435
__only_first_time = True
3536

36-
while _app.cleaning_up == False:
37-
if _app.is_running == False and _is_interactive == True and __only_first_time == True:
37+
while _app.cleaning_up is False:
38+
if _app.is_running is False and _is_interactive is True and __only_first_time is True:
3839
__only_first_time = False
3940
pass
4041
else:
4142
# Setting inpout with timeout in order not to block in case of cancel
4243
# and _app.cleaning_up is re-checked
4344
a, b, c = select.select([sys.stdin], [], [], 2)
44-
if a ==[] and b == [] and c == []:
45+
if a == [] and b == [] and c == []:
4546
continue
4647

4748
_ui["ui_live"].stop()
@@ -135,7 +136,7 @@ def do_scan(self, v):
135136
return
136137
v1, v2 = v.split(" ")
137138
_r = self._app.add_scan(v1, v2)
138-
if self._app.is_running == False:
139+
if self._app.is_running is False:
139140
_dscan_thread = threading.Thread(target=self._app.scan)
140141
_dscan_thread.start()
141142
if _r is False:
@@ -220,10 +221,12 @@ def do_exit(self, _):
220221
Exit Deltascan"""
221222
os._exit(0)
222223

224+
223225
def signal_handler(signal, frame):
224226
print("Exiting without cleanup :-(")
225227
os._exit(1)
226228

229+
227230
def run():
228231
"""
229232
Entry point for the command line interface.
@@ -362,8 +365,8 @@ def run():
362365
_dscan_thread.start()
363366
_shell_thread.start()
364367
_dscan_thread.join()
365-
366-
if _dscan.is_interactive or clargs.interactive == True:
368+
369+
if _dscan.is_interactive or clargs.interactive is True:
367370
_shell_thread.join()
368371
else:
369372
print("No scans left in the queue... Exiting.")
@@ -389,12 +392,12 @@ def run():
389392
output = CliOutput(_r)
390393
output.display()
391394
else:
392-
if clargs.interactive == True:
395+
if clargs.interactive is True:
393396
print("No action provided. Starting interactive shell.")
394397
else:
395398
print("Invalid action. Exiting...")
396399

397-
if clargs.interactive == True:
400+
if clargs.interactive is True:
398401
_shell_thread = threading.Thread(
399402
target=interactive_shell, args=(_dscan, ui_context, clargs.interactive,))
400403
_shell_thread.start()
@@ -406,8 +409,9 @@ def run():
406409
signal.signal(signal.SIGINT, signal_handler)
407410
_dscan.cleanup()
408411
print("Cancelling running scans and closing ...")
409-
except Exception:
412+
except Exception as e:
410413
print(f"Unknown error occurred: {str(e)}")
411414

415+
412416
if __name__ == "__main__":
413417
run()

deltascan/core/deltascan.py

+18-18
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ def scan(self):
174174
Returns:
175175
None
176176
"""
177-
if self._is_running == True:
177+
if self._is_running is True:
178178
return
179179
self._T = Thread(target=self._scan_orchestrator)
180180
self._T.start()
181181
self._T.join()
182182

183183
def _scan_orchestrator(self):
184184
self._scans_to_wait = {}
185-
185+
186186
self._is_running = True
187187
while True:
188188
self._remove_finished_scan_from_list()
@@ -206,24 +206,24 @@ def _scan_orchestrator(self):
206206
time.sleep(1)
207207

208208
def _remove_finished_scan_from_list(self):
209-
"""
210-
Removes the finished scans from the list of scans to wait for completion.
209+
"""
210+
Removes the finished scans from the list of scans to wait for completion.
211211
212-
This method iterates over the `_scans_to_wait` dictionary and checks if each thread is alive.
213-
If a thread is not alive, it is removed from the dictionary.
212+
This method iterates over the `_scans_to_wait` dictionary and checks if each thread is alive.
213+
If a thread is not alive, it is removed from the dictionary.
214214
215-
Args:
216-
None
215+
Args:
216+
None
217217
218-
Returns:
219-
None
220-
"""
221-
threads_to_remove = []
222-
for _n, _th in self._scans_to_wait.items():
223-
if _th["_thr"].is_alive() is False:
224-
threads_to_remove.append(_n)
225-
for _n in threads_to_remove:
226-
del self._scans_to_wait[_n]
218+
Returns:
219+
None
220+
"""
221+
threads_to_remove = []
222+
for _n, _th in self._scans_to_wait.items():
223+
if _th["_thr"].is_alive() is False:
224+
threads_to_remove.append(_n)
225+
for _n in threads_to_remove:
226+
del self._scans_to_wait[_n]
227227

228228
def _get_profile(self, _profile):
229229
try:
@@ -834,7 +834,7 @@ def is_running(self):
834834
@property
835835
def scans_to_wait(self):
836836
return len(self._scans_to_wait.keys())
837-
837+
838838
@property
839839
def scans_to_execute(self):
840840
return len(self._scan_list)

0 commit comments

Comments
 (0)