Yapsy通过eclipse与cx_Freeze可执行文件查找插件 [英] Yapsy finding plugins through eclipse versus cx_Freeze executable

查看:76
本文介绍了Yapsy通过eclipse与cx_Freeze可执行文件查找插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个程序,该程序使用 Yapsy 作为插件系统的后端。用户可以编写自己的插件并在运行时加载它们。我有一个菜单,显示所有已加载的插件,每个插件都是自己的菜单项。我还提供了该程序的两个预制插件。当通过Eclipse运行程序时,这些预制的插件可以很好地加载(即菜单显示两个插件);但是,使用cx_Freeze创建可执行文件后,由于某些原因,插件无法正确加载。仅找到第一个插件,这很奇怪,因为两个插件都位于同一目录中,并且我的代码没有更改。我想知道Yapsy是否有问题?当两个都在同一个目录中时(为什么只有在使用cx_Freeze创建可执行文件之后),为什么只能找到一个插件?

I'm working on a program that uses Yapsy as a backend for a plugin system. User's can write their own plugins and load them at runtime. I've got a menu that displays all the loaded plugins, each as it's own menuitem. I also supply two pre-made plugins with the program. These pre-made plugins load fine when running the program through eclipse (i.e. the menu displays both plugins); however, after I've create an executable, using cx_Freeze, the plugins are not loading correctly for some reason. Only the first plugin is found, which is odd since both plugins reside in the same directory, and the code has not been changed on my end. I'm wondering if there's something wrong with Yapsy? Why would it only be finding one plugin, when both are in the same directory (only after creating an executable with cx_Freeze)?

这是我的方式示例获取预制插件:

Here's an example of the way I'm getting the pre-made plugins:

default_dir = os.path.expanduser('~') + os.sep + "plugins"

if xml.get_plugin_directory() == "":
    directory = [default_dir] # no user specified directory
else:
    directory = [default_dir, xml.get_plugin_directory()] # user specified dir too

# Load the plugins from the specified plugin directory/s.
manager = PluginManager()
manager.setPluginPlaces(directory)
manager.setPluginInfoExtension('plugin')
manager.collectPlugins()

for plugin in manager.getAllPlugins():
    ...

如您所见,我设置了默认目录(它应该总是已经创建,并且我已经对此进行了测试以确保),然后通过 yapsy.PluginManager()将插件位置设置为该目录或该目录以及用户指定的目录。 .setPluginPlaces(目录)。默认插件位置不在我的Eclipse工作区中;它位于其他地方。如前所述,通过Eclipse运行程序时,此方法工作正常,但是一旦创建了可执行文件,就只能找到其中一个插件。我期望没有找到任何插件的错误,但是奇怪的是确实找到了一个,而没有找到另一个。另外,如果我将更多测试插件文件添加到默认目录,则会找到这些文件。就像Yapsy完全跳过了第二个插件(仅在运行可执行文件时一样)。

As you can see, I set the default directory (it always should have been created and I've tested this to make sure), and then set the plugin places to that directory or that directory and a user specified directory via yapsy.PluginManager().setPluginPlaces(directory). The default plugin location isn't in my eclipse workspace; it resides somewhere else. As I said before, this works fine when running the program through Eclipse, but once I create an executable, only one of the plugins is being found. I'd expect an error where no plugins were being found, but this is strange that one is indeed being found and not the other. Also, if I add more test plugin files to the default directory, these are found. It's almost as if Yapsy skips over the second plugin completely (only when running the executable).

任何想法我为什么会遇到这种情况?

Any ideas why I may be getting this behavior?

谢谢,
亚当

推荐答案

您描述问题的方式似乎

如果我不得不猜测我会说该插件不会在Eclipse外部加载,那么yapsy只能加载您测试过的所有插件之一。有一个导入错误(Eclipse中的导入路径可能不同,并且在Eclipse中尝试时不会发生此导入错误)。

If I had to guess I would say that the plugin that doesn't load outside Eclipse has an import error (it's possible that the import path in Eclipse is different, and that this import error doesn't happen when tried inside Eclipse).

当然,这是只是一个疯狂的猜测,如果要深入研究,您可以通过Yapsy以相当标准的方式使用Python日志记录模块显示更多调试信息。

Of course, that's just a wild guess and to investigate a little deeper you can display more debug info via the Python logging module that Yapsy uses in a rather standard way.

要激活调试级别信息,您可以使用以下代码:

To activate debug-level info you can use the following code:

import logging
logging.basicConfig(level=logging.DEBUG)

如果问题仍未解决,您仍然可以将插件的精简版本和插件管理器代码提交给Yapsy的跟踪器。跟踪器位于: http://sourceforge.net/tracker/?group_id=208383

If the problem remains unsolved you can still submit a bug to Yapsy's tracker with strimmed down version of your plugins and plugin manager code. The tracker is at: http://sourceforge.net/tracker/?group_id=208383

这篇关于Yapsy通过eclipse与cx_Freeze可执行文件查找插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆