crawlab
crawlab copied to clipboard
crawlab/core/client.py获取settings可优化判断
/usr/local/lib/python3.8/dist-packages/crawlab/core/client.py文件190行
@staticmethod
def settings(directory=None):
if directory is None:
directory = os.path.abspath(os.curdir)
os.chdir(directory)
cp = get_scrapy_cfg()
settings_mod_name = cp.get('settings', 'default')
sys.path.insert(0, directory)
settings = importlib.import_module(settings_mod_name)
data = []
for key in [key for key in dir(settings) if not key.startswith('__')]:
value = getattr(settings, key)
# `建议修改这里的取值,否则后面json.dumps(data)会报错,比如value是一个模块变量的话`
value = value if isinstance(value, (str, int, bool, dict, tuple)) else str(value)
data.append({
'key': key,
'value': value,
})
print(json.dumps(data))
比如setttings.py这种文件结构,会出现该问题
I'm having the same issue, will this be updated soon ?