Export fails on AttributeError
Hi! I'm ran into this while trying to export on fresh GIMP install:
Traceback (most recent call last): File "/usr/lib/gimp/2.0/python/gimpplugin.py", line 58, in _run return apply(getattr(self, name), params) File "/home/jonas/.gimp-2.8/plug-ins/export_layers.py", line 85, in procedure_wrapper report_uri_list=constants.BUG_REPORT_URI_LIST)(procedure)(run_mode, *args) File "/home/jonas/.gimp-2.8/plug-ins/export_layers/pygimplib/pggui.py", line 377, in func_wrapper func(self, *args, **kwargs) File "/home/jonas/.gimp-2.8/plug-ins/export_layers.py", line 135, in plug_in_export_layers self._run_export_layers_interactive(image) File "/home/jonas/.gimp-2.8/plug-ins/export_layers.py", line 169, in _run_export_layers_interactive gui_plugin.export_layers_gui(image, self.settings, self.session_source, self.persistent_source) File "/home/jonas/.gimp-2.8/plug-ins/export_layers/gui_plugin.py", line 658, in export_layers_gui _ExportLayersGui(image, settings, session_source, persistent_source) File "/home/jonas/.gimp-2.8/plug-ins/export_layers/gui_plugin.py", line 239, in __init__ self._init_gui() File "/home/jonas/.gimp-2.8/plug-ins/export_layers/gui_plugin.py", line 286, in _init_gui 'advanced_settings_expanded': [pgsetting.SettingGuiTypes.expander, self.expander_advanced_settings], File "/home/jonas/.gimp-2.8/plug-ins/export_layers/pygimplib/pgsettinggroup.py", line 251, in initialize_gui setting.create_gui() File "/home/jonas/.gimp-2.8/plug-ins/export_layers/pygimplib/pgsetting.py", line 375, in create_gui old_setting_presenter=self._gui, auto_update_gui_to_setting=auto_update_gui_to_setting) File "/home/jonas/.gimp-2.8/plug-ins/export_layers/pygimplib/pgsettingpresenters_gtk.py", line 63, in __init__ super(GtkSettingPresenter, self).__init__(*args, **kwargs) File "/home/jonas/.gimp-2.8/plug-ins/export_layers/pygimplib/pgsettingpresenter.py", line 134, in __init__ self._copy_state(old_setting_presenter) File "/home/jonas/.gimp-2.8/plug-ins/export_layers/pygimplib/pgsettingpresenter.py", line 250, in _copy_state self._set_value(old_setting_presenter._get_value()) File "/home/jonas/.gimp-2.8/plug-ins/export_layers/pygimplib/pgsettingpresenters_gtk.py", line 143, in _set_value self._element.set_text(value.encode(GTK_CHARACTER_ENCODING)) AttributeError: 'NoneType' object has no attribute 'encode'
Hi, thanks for the report. I believe this is caused by selecting Search or Recently Used from the list of folders to the left.
If this is the issue you're experiencing, I already fixed it after releasing 2.5, so you may as well download the latest revision (it's work-in-progress 3.0, but it's pretty stable). If you'd still prefer to use the 2.5 release, I made a patch to fix the issue. Simply drop the file to plug-ins/export_layers.
Hey! Thanks for the patch! I had a problem testing this out because I was using a dumb test case with only two layers. Then the pgsettingpresenters_gtk.py fails at line 198. For files with more layers, both solutions worked without a hitch, very nice plugin. I didn't get too much into the code, but putting the self._element.set_current_folder(encoded_folder) in a try clause fixed the problem with the two layer case. But again, it's not a realistic test case, is it.
Looks like you indeed found a different bug. Apparently, one cannot pass None to set_current_folder. You could also fix this by simply changing
if folder is not None:
encoded_folder = folder.encode(constants.GTK_CHARACTER_ENCODING)
else:
encoded_folder = None
to
if folder is not None:
encoded_folder = folder.encode(constants.GTK_CHARACTER_ENCODING)
else:
encoded_folder = b""
As a side effect, this will display the default folder in the GUI (usually the home folder).
Thanks for the report again (and I do think it is a realistic case). :)
Getting the same problem here, tried the above fix:
Traceback (most recent call last):
File "/usr/lib/gimp/2.0/python/gimpplugin.py", line 58, in _run
return apply(getattr(self, name), params)
File "/home/expenses/.gimp-2.8/plug-ins/export_layers.py", line 85, in procedure_wrapper
report_uri_list=constants.BUG_REPORT_URI_LIST)(procedure)(run_mode, *args)
File "/home/expenses/.gimp-2.8/plug-ins/export_layers/pygimplib/pggui.py", line 377, in func_wrapper
func(self, *args, **kwargs)
File "/home/expenses/.gimp-2.8/plug-ins/export_layers.py", line 135, in plug_in_export_layers
self._run_export_layers_interactive(image)
File "/home/expenses/.gimp-2.8/plug-ins/export_layers.py", line 169, in _run_export_layers_interactive
gui_plugin.export_layers_gui(image, self.settings, self.session_source, self.persistent_source)
File "/home/expenses/.gimp-2.8/plug-ins/export_layers/gui_plugin.py", line 658, in export_layers_gui
_ExportLayersGui(image, settings, session_source, persistent_source)
File "/home/expenses/.gimp-2.8/plug-ins/export_layers/gui_plugin.py", line 239, in __init__
self._init_gui()
File "/home/expenses/.gimp-2.8/plug-ins/export_layers/gui_plugin.py", line 286, in _init_gui
'advanced_settings_expanded': [pgsetting.SettingGuiTypes.expander, self.expander_advanced_settings],
File "/home/expenses/.gimp-2.8/plug-ins/export_layers/pygimplib/pgsettinggroup.py", line 251, in initialize_gui
setting.create_gui()
File "/home/expenses/.gimp-2.8/plug-ins/export_layers/pygimplib/pgsetting.py", line 375, in create_gui
old_setting_presenter=self._gui, auto_update_gui_to_setting=auto_update_gui_to_setting)
File "/home/expenses/.gimp-2.8/plug-ins/export_layers/pygimplib/pgsettingpresenters_gtk.py", line 63, in __init__
super(GtkSettingPresenter, self).__init__(*args, **kwargs)
File "/home/expenses/.gimp-2.8/plug-ins/export_layers/pygimplib/pgsettingpresenter.py", line 134, in __init__
self._copy_state(old_setting_presenter)
File "/home/expenses/.gimp-2.8/plug-ins/export_layers/pygimplib/pgsettingpresenter.py", line 250, in _copy_state
self._set_value(old_setting_presenter._get_value())
File "/home/expenses/.gimp-2.8/plug-ins/export_layers/pygimplib/pgsettingpresenters_gtk.py", line 143, in _set_value
self._element.set_text(value.encode(GTK_CHARACTER_ENCODING))
AttributeError: 'NoneType' object has no attribute 'encode'
@expenses When does this error occur? Do you use the 2.5 version of the plug-in?
Using 2.9 Development version of gimp with 2.5 version of the plugin. When trying to open the export layers menu entry, i get this error.
Traceback (most recent call last):
File "/usr/lib/gimp/2.0/python/gimpplugin.py", line 62, in _run
return apply(getattr(self, name), params)
File "/home/kerle/.config/GIMP/2.9/plug-ins/export_layers.py", line 85, in procedure_wrapper
report_uri_list=constants.BUG_REPORT_URI_LIST)(procedure)(run_mode, *args)
File "/home/kerle/.config/GIMP/2.9/plug-ins/export_layers/pygimplib/pggui.py", line 377, in func_wrapper
func(self, *args, **kwargs)
File "/home/kerle/.config/GIMP/2.9/plug-ins/export_layers.py", line 135, in plug_in_export_layers
self._run_export_layers_interactive(image)
File "/home/kerle/.config/GIMP/2.9/plug-ins/export_layers.py", line 169, in _run_export_layers_interactive
gui_plugin.export_layers_gui(image, self.settings, self.session_source, self.persistent_source)
File "/home/kerle/.config/GIMP/2.9/plug-ins/export_layers/gui_plugin.py", line 658, in export_layers_gui
_ExportLayersGui(image, settings, session_source, persistent_source)
File "/home/kerle/.config/GIMP/2.9/plug-ins/export_layers/gui_plugin.py", line 239, in __init__
self._init_gui()
File "/home/kerle/.config/GIMP/2.9/plug-ins/export_layers/gui_plugin.py", line 286, in _init_gui
'advanced_settings_expanded': [pgsetting.SettingGuiTypes.expander, self.expander_advanced_settings],
File "/home/kerle/.config/GIMP/2.9/plug-ins/export_layers/pygimplib/pgsettinggroup.py", line 251, in initialize_gui
setting.create_gui()
File "/home/kerle/.config/GIMP/2.9/plug-ins/export_layers/pygimplib/pgsetting.py", line 375, in create_gui
old_setting_presenter=self._gui, auto_update_gui_to_setting=auto_update_gui_to_setting)
File "/home/kerle/.config/GIMP/2.9/plug-ins/export_layers/pygimplib/pgsettingpresenters_gtk.py", line 63, in __init__
super(GtkSettingPresenter, self).__init__(*args, **kwargs)
File "/home/kerle/.config/GIMP/2.9/plug-ins/export_layers/pygimplib/pgsettingpresenter.py", line 134, in __init__
self._copy_state(old_setting_presenter)
File "/home/kerle/.config/GIMP/2.9/plug-ins/export_layers/pygimplib/pgsettingpresenter.py", line 250, in _copy_state
self._set_value(old_setting_presenter._get_value())
File "/home/kerle/.config/GIMP/2.9/plug-ins/export_layers/pygimplib/pgsettingpresenters_gtk.py", line 143, in _set_value
self._element.set_text(value.encode(GTK_CHARACTER_ENCODING))
AttributeError: 'NoneType' object has no attribute 'encode'
@Jikstra This bug has been fixed after the 2.5 release. Try the new 3.0 version for GIMP 2.9.
I put some more safeguards in version 3.3.3 to prevent this error. I'm closing this issue due to recent inactivity and the fact that this is (hopefully) resolved. Feel free to open a new issue if such an error happens to you again.