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
Conversation
✅ Deploy Preview for kubespider ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
hello, 感谢大佬的PR, 可以修复一下ci报的问题吗 |
好的,我看看 |
好像是因为循环依赖导致的问题,python这个好奇怪,循环依赖在调试环境不会报错。 已经重新提交了。 |
if not 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 comment
The 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
这个是预期行为吗?是不是至少应该是 /Users/richardli1598/.config
? 那么是不是如下代码更合适:
>>> os.path.join(os.getcwd(), '.config/')
'/Users/richardli1598/.config/'
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.
是预期行为吧,这里源代码结构一般clone下来是有两层kubespider目录吧
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.
例如:代码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 comment
The reason will be displayed to describe this comment to others. Learn more.
好的,感谢解释。
这里麻烦加点注释,说明一下,运行时,需要在 {repo_root}/kubespider/kubespider
下面运行,其他地方运行可能不行
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.
注释和校验容器运行方式按照你说的格式改了,然后我看了下,ci报错好像不是我那段代码报错,我pr里面有个pylint 的style错误,好像是多加了一行空格,这个我也改了。
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.
另外,这个导入为啥总失败啊,我本地运行都可以。python真的太神奇了
这个应该如下修改就行:
-from kubespider.utils import helper
+from utils import helper
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.
另外,这个导入为啥总失败啊,我本地运行都可以。python真的太神奇了
这个应该如下修改就行:
-from kubespider.utils import helper +from utils import helper
嗯这个我修改了,但是我看这个pylint还有导入包顺序限制?
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.
嗯嗯,现在ok了,一般顺序是 系统,第三方,本项目库
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.
嗯嗯,现在ok了
额,开源新手,github这些流程还不太会。麻烦你了
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.
欢迎下次贡献,一起共建!
kubespider/core/config_handler.py
Outdated
@@ -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 |
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.
-from kubespider.utils import helper
+from utils import helper
member邀请以发出,请查收:https://github.com/settings/organizations |
Fix #224