[Libosinfo] Errors on import

Loranz Steve sloranz at xantham.com
Wed Sep 18 21:49:01 UTC 2013


Hello,

I previously emailed the list about unsuccessfully using get_install_script() on an instance of Db. I thought I would try a different route and try instantiating an empty InstallScript and using generate, supplying the OS, an InstallConfig, and a Cancellable object.

I'm seeing the following behavior depending on the order of the imports:

------

Python 2.7.3 (default, Aug  9 2012, 17:23:57)
[GCC 4.7.1 20120720 (Red Hat 4.7.1-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gi.repository import Libosinfo as osinfo
>>> from gio import Cancellable
/usr/lib64/python2.7/site-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  import gobject._gobject
>>>

------

or

------

Python 2.7.3 (default, Aug  9 2012, 17:23:57)
[GCC 4.7.1 20120720 (Red Hat 4.7.1-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gio import Cancellable
>>> from gi.repository import Libosinfo as osinfo
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/gi/__init__.py", line 27, in <module>
    from ._gi import _API, Repository
ImportError: could not import gobject (error was: ImportError('When using gi.repository you must not import static modules like "gobject". Please change all occurrences of "import gobject" to "from gi.repository import GObject".',))
>>>

------


If I ignore the warning from importing Cancellable after Libosinfo, I get the following exception from within gi

------

>>> from gi.repository import Libosinfo as osinfo
>>> from gio import Cancellable
/usr/lib64/python2.7/site-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  import gobject._gobject
>>> loader = osinfo.Loader()
>>> loader.process_path("/usr/share/libosinfo/db")
>>> db = loader.get_db()
>>> osid = 'http://microsoft.com/win/2k8r2'
>>> os = db.get_os(osid)
>>> config = osinfo.InstallConfig()
>>> cancellable = Cancellable()
>>> script = osinfo.InstallScript()
>>> script.generate(os, config, cancellable)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/gi/types.py", line 47, in function
    return info.invoke(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/gi/importer.py", line 76, in load_module
    dynamic_module._load()
  File "/usr/lib64/python2.7/site-packages/gi/module.py", line 244, in _load
    overrides_modules = __import__('gi.overrides', fromlist=[self._namespace])
  File "/usr/lib64/python2.7/site-packages/gi/overrides/Gio.py", line 49, in <module>
    FileEnumerator = override(FileEnumerator)
  File "/usr/lib64/python2.7/site-packages/gi/overrides/__init__.py", line 70, in override
    registry.register(type_)
  File "/usr/lib64/python2.7/site-packages/gi/overrides/__init__.py", line 44, in register
    self[override_class] = override_class
  File "/usr/lib64/python2.7/site-packages/gi/overrides/__init__.py", line 28, in __setitem__
    raise TypeError('Can not override a type %s, which is not in a gobject introspection typelib' % value.__name__)
TypeError: Can not override a type FileEnumerator, which is not in a gobject introspection typelib
>>>

------


My experience with GObject provided bindings is nonexistent prior to this, so I'm not sure if this is an issue with the binding definitions or my use of the API. Any help you can provide here would be appreciated.

Thank you.
-steve





More information about the Libosinfo mailing list