Ask Your Question
2

python uno. 'com.sun.star.task.XRestartManager' object has no attribute 'requestRestart'

asked 2020-06-19 20:55:21 +0200

vlad.bezugliy gravatar image

Hi all. I need to restart office after changing UI language (so as real application behaves). So I found XRestartManager (https://www.openoffice.org/api/docs/c...) which has requestRestart method I wanted to try.

But, when I run following code:

            import uno
            restart_manager = uno.getClass("com.sun.star.task.XRestartManager")()
            restart_manager.requestRestart()

I have got

AttributeError: 'com.sun.star.task.XRestartManager' object has no attribute 'requestRestart'

Maybe there are some another way to perform app restart. Any advices might be helpfull. Thank you!

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2020-06-19 23:04:38 +0200

Jim K gravatar image

Use the component context to get the singleton.

ctx = XSCRIPTCONTEXT.getComponentContext()
restartManager = ctx.getValueByName(
    "/singletons/com.sun.star.task.OfficeRestartManager")
if not restartManager.isRestartRequested(False):
    restartManager.requestRestart(None)

According to https://forum-test.openoffice.org/en/..., it didn't use to restart. But it works now, so the full implementation must have been added at some point.

edit flag offensive delete link more

Comments

Thank you, OfficeRestartManager instantiated and worked properly in this way.

vlad.bezugliy gravatar imagevlad.bezugliy ( 2020-06-20 09:36:42 +0200 )edit

@Jim K

Hi, looking to call a restart from a base form after user completes an input box. Not familiar with Python, how can I do this with a basic macro ? Thanks for your thoughts

gkick gravatar imagegkick ( 2021-02-08 05:10:31 +0200 )edit
Jim K gravatar imageJim K ( 2021-02-08 11:47:07 +0200 )edit

@Jim K Thanks for the link

gkick gravatar imagegkick ( 2021-02-08 15:48:48 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-06-19 20:55:21 +0200

Seen: 118 times

Last updated: Jun 19 '20