wait for opened threads/honeypots modules Returns: True
(virtual_machine_container_reset_factory_time_seconds, configuration,
new_network_events_thread, run_as_test)
| 333 | |
| 334 | |
| 335 | def wait_until_interrupt(virtual_machine_container_reset_factory_time_seconds, configuration, |
| 336 | new_network_events_thread, run_as_test): |
| 337 | """ |
| 338 | wait for opened threads/honeypots modules |
| 339 | |
| 340 | Returns: |
| 341 | True |
| 342 | """ |
| 343 | # running_time variable will be use to check |
| 344 | # if its need to reset the container after a while |
| 345 | # if virtual_machine_container_reset_factory_time_seconds < 0, |
| 346 | # it will keep containers until user interruption |
| 347 | running_time = 0 |
| 348 | while True: |
| 349 | # while True sleep until user send ctrl + c |
| 350 | try: |
| 351 | time.sleep(1) |
| 352 | running_time += 1 |
| 353 | # check if running_time is equal to reset factory time |
| 354 | if running_time == virtual_machine_container_reset_factory_time_seconds: |
| 355 | # reset the run time |
| 356 | running_time = 0 |
| 357 | # stop old containers (in case they are not stopped) |
| 358 | stop_containers(configuration) |
| 359 | # remove old containers (in case they are not updated) |
| 360 | remove_old_containers(configuration) |
| 361 | # start containers based on selected modules |
| 362 | start_containers(configuration) |
| 363 | if not new_network_events_thread.is_alive(): |
| 364 | return error(messages["interrupt_application"]) |
| 365 | if containers_are_unhealthy(configuration): |
| 366 | return error( |
| 367 | "Interrupting the application because \"{0}\" container(s) is(are) not alive!".format( |
| 368 | ", ".join(containers_are_unhealthy(configuration)) |
| 369 | ) |
| 370 | ) |
| 371 | if run_as_test: |
| 372 | break |
| 373 | except KeyboardInterrupt: |
| 374 | # break and return for stopping and removing containers/images |
| 375 | info(messages["interrupted_by_user"]) |
| 376 | break |
| 377 | return True |
| 378 | |
| 379 | |
| 380 | def honeypot_configuration_builder(selected_modules): |
no test coverage detected