Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python "no return values, shouldn't happen"
#1
Exclamation 
I'm creating a python script to load a custom image format (.PRS with the magic string "YB").  But I'm having trouble getting even a skeleton file loading plugin to work.  This is what I've been able to reduce my code down to:
Code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import gi
gi.require_version('Gimp', '3.0')
from gi.repository import Gimp, GObject
import sys

load_proc = "file-prs-load"
plugin_binary = "file-prs"

class PrsLoader(Gimp.PlugIn):
   def do_query_procedures(self):
       return [load_proc]
   
   def do_create_procedure(self, name):
       procedure = None
       
       if name == load_proc:
           procedure = Gimp.LoadProcedure.new(self, name,
                                               Gimp.PDBProcType.PLUGIN,
                                               self.PrsLoad, None)
           procedure.set_menu_label("PRS image")
           procedure.set_attribution("Nathan", "Nathan", "2025")
           procedure.set_menu_label("PRS image")
           procedure.set_documentation("Loads files of PRS file format",
                                       "Loads files of PRS file format",
                                       None)
           procedure.set_mime_types("image/prs")
           procedure.set_extensions("prs")
           procedure.set_magics("0,string,YB")
       return procedure
   
   def PrsLoad(self, procedure, run_mode, file, metadata, flags, config, run_data):
       print("PrsLoad called")

       #Return dummy image for now
       image = Gimp.Image.new(100, 100, Gimp.ImageBaseType.RGB)

       return_vals = procedure.new_return_values(Gimp.PDBStatusType.SUCCESS, None)
       val = GObject.Value(Gimp.Image.__gtype__, image)
       return_vals.append(val)

       return return_vals

Gimp.main(PrsLoader.__gtype__, sys.argv)

When I try to open a PRS image file, I get the following errors:
Code:
GIMP Message
Opening '/home/nathan/Pictures/tree2b.prs' failed:
PRS image plug-in could not open image


Code:
[nathan@TARDIS file-prs]$ gimp
set device 'Wayland Pointer' to mode: disabled
[file-prs-load] The catalog directory does not exist: /home/nathan/.config/GIMP/3.0/plug-ins/file-prs/locale
[file-prs-load] Override method set_i18n() for the plug-in to customize or disable localization.
[file-prs-load] Localization disabled
env: ‘gjs’: No such file or directory
gimp: LibGimpBase-WARNING: gimp: gimp_wire_read(): unexpected EOF
[file-prs-load] The catalog directory does not exist: /home/nathan/.config/GIMP/3.0/plug-ins/file-prs/locale
[file-prs-load] Override method set_i18n() for the plug-in to customize or disable localization.
[file-prs-load] Localization disabled
[file-prs-load] The catalog directory does not exist: /home/nathan/.config/GIMP/3.0/plug-ins/file-prs/locale
[file-prs-load] Override method set_i18n() for the plug-in to customize or disable localization.
[file-prs-load] Localization disabled
PrsLoad called

(file-prs.py:2595385): LibGimp-WARNING **: 17:46:44.730: _gimp_procedure_run_array: no return values, shouldn't happen
/home/nathan/.config/GIMP/3.0/plug-ins/file-prs/file-prs.py:46: Warning: g_error_new: assertion 'domain != 0' failed
 Gimp.main(PrsLoader.__gtype__, sys.argv)
INFO: a stray image seems to have been left around by a plug-in: "[Untitled]"[nathan@TARDIS file-prs]$

I'm not too worried about the localization messages at this time.
Reply


Messages In This Thread
Python "no return values, shouldn't happen" - by Nathan - Yesterday, 09:55 PM

Forum Jump: