Openoffice3.1 pyuno混淆错误

发布于 2024-08-09 00:38:48 字数 1563 浏览 8 评论 0原文

我正在尝试获取 示例 以及我找到的用于 pyuno 运行的其他示例代码openoffice 3.1.1 和 python 2.5 没有运气。

不幸的是,pyuno 没有给出任何关于哪里出了问题的线索。

In [1]: import uno
In [2]: local = uno.getComponentContext()
In [3]: resolver = local.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", local)
---------------------------------------------------------------------------
com.sun.star.uno.RuntimeException         Traceback (most recent call last)

/opt/openoffice.org/basis3.1/program/ in ()

com.sun.star.uno.RuntimeException: : 'tuple' object has no attribute 'getTypes', traceback follows
no traceback available

以下是 /opt/openoffice.org/basis3.1/program/officehelper.py 的执行输出 它基本上启动无头办公室实例并返回相关的上下文对象。

den@ev:/opt/openoffice.org/basis3.1/program > python officehelper.py
Traceback (most recent call last):
  File "officehelper.py", line 42, in 
    from com.sun.star.connection import NoConnectException
  File "uno.py", line 273, in _uno_import
    RuntimeException = pyuno.getClass( "com.sun.star.uno.RuntimeException" )
RuntimeError: pyuno.getClass: expecting one string argument

pyuno 仅接受 1 个参数,并且必须是一个字符串,如 http://udk.openoffice.org/source/browse/udk/pyuno/source/module/pyuno_module.cxx?rev=1.14&view=markup 无论如何,我无法让 pyno.getClass 工作。

关于如何让 pyuno 工作有什么建议吗?

I'm trying to get the sample and other sample codes i find for pyuno running with openoffice 3.1.1 and python 2.5 with no luck.

Unfortunately, pyuno does not give any clues about what goes wrong.


In [1]: import uno
In [2]: local = uno.getComponentContext()
In [3]: resolver = local.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", local)
---------------------------------------------------------------------------
com.sun.star.uno.RuntimeException         Traceback (most recent call last)

/opt/openoffice.org/basis3.1/program/ in ()

com.sun.star.uno.RuntimeException: : 'tuple' object has no attribute 'getTypes', traceback follows
no traceback available

below is the output of execution of /opt/openoffice.org/basis3.1/program/officehelper.py
which basically boots the headless office instance and returns a related context object.

den@ev:/opt/openoffice.org/basis3.1/program > python officehelper.py
Traceback (most recent call last):
  File "officehelper.py", line 42, in 
    from com.sun.star.connection import NoConnectException
  File "uno.py", line 273, in _uno_import
    RuntimeException = pyuno.getClass( "com.sun.star.uno.RuntimeException" )
RuntimeError: pyuno.getClass: expecting one string argument

pyuno takes only 1 argument and it hasto be a string, as defined in http://udk.openoffice.org/source/browse/udk/pyuno/source/module/pyuno_module.cxx?rev=1.14&view=markup
i could not manage to get pyuno.getClass work anyway.

any suggestions about how to get pyuno working?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

亣腦蒛氧 2024-08-16 00:38:48

在[1]中:导入uno
在[2]中:local = uno.getComponentContext()
在[3]中:resolver = local.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", local)

OOP出错了,恕我直言。我知道它加班了,但我之前尝试过让 uno 工作,但放弃了。这是纯粹的 Steve Yegge 散文(阅读 http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html)。

当您将这些行翻译成更容易理解的形式时,它们大致如下:

“让‘local’成为调用‘uno’的‘get component context’方法的结果。让‘service manager’成为属性‘service manager’ ' 的 'local'。让 'resolver' 成为调用 'service manager' 方法 'create instance with context' 的结果,使用参数 'com sun starbridge uno url resolver' 和 'local'。”

我的天啊。毫不奇怪,一个程序出了问题,它是如此的过于具体、复杂和自我指涉,同时又没有自我意识……你调用了“本地”的子方法,并且必须告诉该子方法“本地”是什么意思?说什么?向能够解决这个问题的无所畏惧的开发人员致敬。调试愉快。

添加:

感谢评论和积分。

事实上,我对 pyuno 问题无能为力,但我鼓励在明确的期限内采取耐心的尝试方法。

我还建议向 pyuno 人员提交一个彻底的 BUG(如果他们实际上很活跃——我的印象是这是一个相当安静的项目),因为出现了无意义的错误消息:有问题的方法似乎请求一个字符串参数,它得到了一个,并且抱怨它得到了。这对于声明代码错误变得合理来说没有任何帮助。

在这种情况下,我经常查阅资料来源。但你已经这么做了,对吧?

我讨厌人们反问“你为什么要这样做?”当我寻求帮助时。然而,有时有人(也许是你)确实在此过程中提出了另一条可行的路径,该路径不包含特定问题的解决方案,但有助于解决上级问题。那么,如果我可以问:大局是什么?

In [1]: import uno
In [2]: local = uno.getComponentContext()
In [3]: resolver = local.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", local)

OOP gone wrong, imho. i know its OT, but i tried getting uno to work before, and gave up. this is pure Steve Yegge Prose (read up on http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html).

when you translate those lines into a more speakable form, they come out roughly as:

"Let 'local' be the result of calling method 'get component context' of 'uno'. Let the 'service manager' be the attribute 'service manager' of 'local'. Let 'resolver' be the result of calling the 'service manager' method 'create instance with context', using arguments 'com sun star bridge uno url resolver' and 'local'."

omg. no surprise something is wrong with a program that is so atrociously over-specific, convoluted, and self-referential while being not self-aware... you call a sub-method of 'local' and that sub-method has to be told what 'local' means? say what? hats off to the fearless developers who can cut through this. happy debugging.

ADDED:

thx for comment and points.

the pyuno problem i cannot do anything about in fact, but i encourage to persue a patient trytrytry approach with a clear deadline.

i also suggest to file an outright B.U.G. with the pyuno people (if they are in fact active—i got the impression that this was a rather silent project) because of the nonsense error message: the method in question appears to request one string argument, and it gets one, and it complains it did. this is so not helpful to the degree it becomes reasonable to declare a code fault.

in this kind of situation i often look into the sources. but you already did that, right?

i hate people to ask back ‘why do you want to do this?’ when i ask for help. however, sometimes someone (maybe you) does come up with another workable path in the process, one that does not include a solution to the particular problem, but helps to solve the superordinate one. so, if i may ask: what is the big picture?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文