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

Hi all. I need to restart office after changing UI language (so as real application behaves). So I found XRestartManager (Interface XRestartManager) 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!

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 [Solved] Auto update extension (View topic) • Apache OpenOffice Community Forum, it didn’t use to restart. But it works now, so the full implementation must have been added at some point.

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

@jimk

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: See How do I create an instance of a singleton? - #6 by librebel

@jimk
Thanks for the link

It doesn’t work for me. StarBasic code:

ctx = GetDefaultContext()
restartManager = ctx _
 .getValueByName("/singletons/com.sun.star.task.OfficeRestartManager")
If Not restartManager.isRestartRequested(False) Then
    restartManager.requestRestart(None)  'triggers an error (see screenshot)
End If

Снимок экрана от 2021-07-11 16-33-43.png