New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: 对环境判断以处理开发环境由于配置文件路径不存在导致的异常 #225
Changes from 4 commits
1331268
3f64e08
5a7b19b
9ef7e72
31f32f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ __pycache__ | |
.idea/ | ||
|
||
# Docs out folder | ||
site/ | ||
site/ | ||
venv |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
from api.values import Config | ||
from api import values | ||
from utils.config_reader import YamlFileSectionConfigReader, YamlFileConfigReader | ||
from kubespider.utils import helper | ||
|
||
import source_provider.mikanani_source_provider.provider as mikanani_source_provider | ||
import source_provider.btbtt12_disposable_source_provider.provider as btbtt12_disposable_source_provider | ||
|
@@ -151,6 +152,13 @@ def prepare_config() -> None: | |
return | ||
|
||
logging.info("Config files(%s) miss, try to init them", ','.join(miss_cfg)) | ||
|
||
# local run, make sure the current working directory like this {repo_root}/kubespider/kubespider | ||
if not helper.is_running_in_docker(): | ||
if not os.path.exists(values.CFG_BASE_PATH): | ||
os.makedirs(values.CFG_BASE_PATH) | ||
values.CFG_TEMPLATE_PATH = os.path.join(os.path.dirname(os.getcwd()), '.config/') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. >>> os.path.join(os.path.dirname(os.getcwd()), '.config/')
'/Users/.config/'
>>> ^D
richardli1598@richardli1598 [~]
-> % pwd
/Users/richardli1598 这个是预期行为吗?是不是至少应该是
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 是预期行为吧,这里源代码结构一般clone下来是有两层kubespider目录吧 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 例如:代码clone下来在/Users/ljt/code/kubespider 目录下,那么os.getcwd()应该是/Users/ljt/code/kubespider/kubespider,那么os.path.dirname(os.getcwd())就是/Users/ljt/code/kubespider,即代码根目录,join上.config 就是默认配置模板目录 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 好的,感谢解释。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 注释和校验容器运行方式按照你说的格式改了,然后我看了下,ci报错好像不是我那段代码报错,我pr里面有个pylint 的style错误,好像是多加了一行空格,这个我也改了。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
这个应该如下修改就行: -from kubespider.utils import helper
+from utils import helper There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
嗯这个我修改了,但是我看这个pylint还有导入包顺序限制? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 嗯嗯,现在ok了,一般顺序是 系统,第三方,本项目库 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
额,开源新手,github这些流程还不太会。麻烦你了 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 欢迎下次贡献,一起共建! |
||
|
||
for cfg in miss_cfg: | ||
template_cfg = values.CFG_TEMPLATE_PATH + cfg | ||
target_cfg = values.CFG_BASE_PATH + cfg | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.