实现配置文件插拔式设计

This commit is contained in:
Jing Ling
2020-08-07 20:06:16 +08:00
parent d7f7c54b1a
commit 69ce692ff1
14 changed files with 103 additions and 103 deletions
+6 -6
View File
@@ -4,7 +4,7 @@ import importlib
import dbexport
from config.log import logger
from config import setting
from config import settings
from common import utils
@@ -26,7 +26,7 @@ class Collect(object):
"""
Get modules
"""
if setting.enable_all_module:
if settings.enable_all_module:
# modules = ['brute', 'certificates', 'crawl',
# 'datasets', 'intelligence', 'search']
# The crawl module has some problems
@@ -34,13 +34,13 @@ class Collect(object):
'dnsquery', 'intelligence', 'search']
# modules = ['certificates']
for module in modules:
module_path = setting.module_dir.joinpath(module)
module_path = settings.module_dir.joinpath(module)
for path in module_path.rglob('*.py'):
# Classes to be imported
import_module = ('modules.' + module, path.stem)
self.modules.append(import_module)
else:
self.modules = setting.enable_partial_module
self.modules = settings.enable_partial_module
def import_func(self):
"""
@@ -76,7 +76,7 @@ class Collect(object):
for thread in threads:
# 挨个线程判断超时 最坏情况主线程阻塞时间=线程数*module_thread_timeout
# 超时线程将脱离主线程 由于创建线程时已添加守护属于 所有超时线程会随着主线程结束
thread.join(setting.module_thread_timeout)
thread.join(settings.module_thread_timeout)
for thread in threads:
if thread.is_alive():
@@ -86,7 +86,7 @@ class Collect(object):
if self.export:
if not self.path:
name = f'{self.domain}.{self.format}'
self.path = setting.result_save_dir.joinpath(name)
self.path = settings.result_save_dir.joinpath(name)
dbexport.export(self.domain, path=self.path, format=self.format)
end = time.time()
self.elapse = round(end - start, 1)