Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Hello all,

I rebuilt master with the latest changes made by Michael Stahl, Michael
Meeks and Julien Nabet and
desktop.addTerminateListener(TerminateListenerProcAdapter(test)) does not
fail anymore. However, print(dir(desktop)) still yells the same problem.
Anyway, I could already launch fax wizard using python3.3 so this is a big
step foward. Thank you to all of you guys.

Regards,
Xisco Faulí
2012/11/22 Xisco Faulí <anistenis@gmail.com>

Hello all,

I built libreoffice with python3.3 today in order to adapt python code to
this version and I realized python3.3 has a different behaviour interacting
with UNO components than python2.7 does. Just to check it I created a
simple script:

import unohelper

def test():
    localContext = uno.getComponentContext()
    resolver = localContext.ServiceManager.createInstanceWithContext(
                    "com.sun.star.bridge.UnoUrlResolver", localContext )
    ctx = resolver.resolve(
"uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" )
    smgr = ctx.ServiceManager
    desktop = smgr.createInstanceWithContext(
"com.sun.star.frame.Desktop",ctx)
    print(dir(desktop))
    desktop.addTerminateListener(TerminateListenerProcAdapter(test))
    model = desktop.getCurrentComponent()
    text = model.Text
    cursor = text.createTextCursor()
    text.insertString( cursor, "Hello World", 0 )
    ctx.ServiceManager

from com.sun.star.frame import XTerminateListener
class TerminateListenerProcAdapter(unohelper.Base, XTerminateListener):
    def __init__( self, oProcToCall):
        self.oProcToCall = oProcToCall

if __name__ == "__main__":
    test()

in python2.7 it works perfecty but in python3.3 it throws 2 exceptions.

print(dir(desktop)):

Traceback (most recent call last):
  File "test.py", line 25, in <module>
    test()
  File "test.py", line 11, in test
    print(dir(desktop))
TypeError: object does not provide __dir__
Error in sys.excepthook:
Traceback (most recent call last):
  File "/home/xisco/libo/install/program/uno.py", line 286, in _uno_import
    d[x] = pyuno.getClass( name + "." + x )
uno.RuntimeException: pyuno.getClass: uno exception
apport.fileutils.likely_packaged is unknown

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/xisco/libo/install/program/uno.py", line 290, in _uno_import
    d[x] = Enum( name , x )
  File "/home/xisco/libo/install/program/uno.py", line 123, in __init__
    pyuno.checkEnum( self )
uno.RuntimeException: attributes typeName and/or value of uno.Enum are not
strings

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/xisco/libo/install/program/uno.py", line 294, in _uno_import
    d[x] = getConstantByName( name + "." + x )
  File "/home/xisco/libo/install/program/uno.py", line 48, in
getConstantByName
    return pyuno.getConstantByName( constant )
uno.RuntimeException: apport.fileutils.likely_packaged

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 64, in
apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/home/xisco/libo/install/program/uno.py", line 297, in _uno_import
    raise ImportError( "type "+ name + "." +x + " is unknown" )
ImportError: type apport.fileutils.likely_packaged is unknown

Original exception was:
Traceback (most recent call last):
  File "test.py", line 25, in <module>
    test()
  File "test.py", line 11, in test
    print(dir(desktop))
TypeError: object does not provide __dir__

and desktop.addTerminateListener(TerminateListenerProcAdapter(test)) (
comenting previous line):

Traceback (most recent call last):
  File "test.py", line 25, in <module>
    test()
  File "test.py", line 12, in test
    desktop.addTerminateListener(TerminateListenerProcAdapter(test))
uno.RuntimeException: Couldn't convert
<__main__.TerminateListenerProcAdapter object at 0xb70cb9ec> to a UNO type;
caught exception: attributes typeName and/or value of uno.Enum are not
strings
Error in sys.excepthook:
Traceback (most recent call last):
  File "/home/xisco/libo/install/program/uno.py", line 286, in _uno_import
    d[x] = pyuno.getClass( name + "." + x )
uno.RuntimeException: pyuno.getClass: uno exception
apport.fileutils.likely_packaged is unknown

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/xisco/libo/install/program/uno.py", line 290, in _uno_import
    d[x] = Enum( name , x )
  File "/home/xisco/libo/install/program/uno.py", line 123, in __init__
    pyuno.checkEnum( self )
uno.RuntimeException: attributes typeName and/or value of uno.Enum are not
strings

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/xisco/libo/install/program/uno.py", line 294, in _uno_import
    d[x] = getConstantByName( name + "." + x )
  File "/home/xisco/libo/install/program/uno.py", line 48, in
getConstantByName
    return pyuno.getConstantByName( constant )
uno.RuntimeException: apport.fileutils.likely_packaged

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 64, in
apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/home/xisco/libo/install/program/uno.py", line 297, in _uno_import
    raise ImportError( "type "+ name + "." +x + " is unknown" )
ImportError: type apport.fileutils.likely_packaged is unknown

Original exception was:
Traceback (most recent call last):
  File "test.py", line 25, in <module>
    test()
  File "test.py", line 12, in test
    desktop.addTerminateListener(TerminateListenerProcAdapter(test))
uno.RuntimeException: Couldn't convert
<__main__.TerminateListenerProcAdapter object at 0xb70cb9ec> to a UNO type;
caught exception: attributes typeName and/or value of uno.Enum are not
strings


any idea ?

Regards,
Xisco Faulí



Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.