fastinstaller.installProduct“安装”甚至不存在的东西。我如何提出例外?
我的产品中有一个 config.py
,具有:
DEPENDENCIES = ['bbbbbbbbbbbb'] #This doesn't exist
在我的 setuphandlers.py
中:
for dependency in DEPENDENCIES:
if not quickinstaller.isProductInstalled(dependency):
quickinstaller.installProduct(dependency)
现在我的 Portal_quickinstaller 中有一个 bbbbbbbbbbbb 条目内容选项卡。 (http://localhost:8080/Plone/portal_quickinstaller/manage_main)。
如果依赖项不存在,我应该怎么做才能使依赖项部分“抱怨”(引发异常,无论如何)?谢谢!
编辑:我发现了一个使用quickinstaller.getProductVersion
的黑客:如果没有任何结果,则它不存在。还有别的办法吗?
I have a config.py
in my product, having:
DEPENDENCIES = ['bbbbbbbbbbbb'] #This doesn't exist
And in my setuphandlers.py
:
for dependency in DEPENDENCIES:
if not quickinstaller.isProductInstalled(dependency):
quickinstaller.installProduct(dependency)
And now I have a bbbbbbbbbbbb entry in my portal_quickinstaller's Contents tab. (http://localhost:8080/Plone/portal_quickinstaller/manage_main).
What should I do to make the dependencies section 'complain' (raise an exception, whatever) if the dependency doesn't exist? Thanks!
EDIT: I've found a hack using quickinstaller.getProductVersion
: if nothing comes, it doesn't exist. Is there another way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你可以使用这样的东西:
You can use something like this:
声明 deps 的正常方法是使用
metadata.xml
:这将添加
plone.app.iterate
包,因为它的安装配置文件名称是plone.app .迭代
。其中绝大多数都称为默认设置,例如:当然,这仅在您尝试安装的产品具有通用安装配置文件时才有效,但除了最旧的产品之外的所有产品都可以。
The normal way of declaring deps is to use
metadata.xml
:This will add the
plone.app.iterate
package, as its install profile name isplone.app.iterate
. The vast majority of these are called default, e.g.:Of course, this only works if the product you're trying to install has a Generic Setup profile, but all but the very oldest do.
我想这取决于为什么你可能拥有一个不存在的产品。
通常,您不会在这里测试它 - 您会将依赖项放入 setup.py 中,然后如果产品不存在,您的构建就会失败。
不过,如果您的产品可能会使用第二个产品(如果存在)(例如,SQLAlchemy 需要一个或多个 python DBAPI Egg,但没有特定的一个),那么我认为您需要执行通常的操作:即使用try/ except包装产品中某些模块的导入,如果导入失败则不进行安装。
I guess it depends why you might have a product that doesn't exist.
Normally, you wouldn't be testing this here - you'd put your dependency in setup.py, and then your buildout fails if the product doesn't exist.
If, though, you have a product that may use a second product if it exists (for instance, SQLAlchemy needs one or more python DBAPI eggs, but no specific one), then I would think you need to do the usual: which is to wrap an import of some module in the product with a try/except and not do the install if the import fails.