Coverage for src/robotide/application/restartutil.py: 88%

21 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-05-06 10:40 +0100

1# Copyright 2024- Robot Framework Foundation 

2# 

3# Licensed under the Apache License, Version 2.0 (the "License"); 

4# you may not use this file except in compliance with the License. 

5# You may obtain a copy of the License at 

6# 

7# http://www.apache.org/licenses/LICENSE-2.0 

8# 

9# Unless required by applicable law or agreed to in writing, software 

10# distributed under the License is distributed on an "AS IS" BASIS, 

11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

12# See the License for the specific language governing permissions and 

13# limitations under the License. 

14import builtins 1ba

15import subprocess 1ba

16import sys 1ba

17 

18import psutil 1ba

19import wx 1ba

20 

21from .updatenotifier import _askyesno 1ba

22 

23_ = wx.GetTranslation # To keep linter/code analyser happy 1ba

24builtins.__dict__['_'] = wx.GetTranslation 1ba

25 

26SPC = " " 1ba

27 

28 

29def restart_dialog(): 1ba

30 if not _askyesno(_("Re-open RIDE for Language Change"), 1a

31 f"{SPC}{_('Language change will only be correct after re-opening RIDE.')}" 

32 f"{SPC}\n{SPC}{_('Do you want to CLOSE RIDE now?')}\n{SPC}" 

33 # f"{_('After restarting RIDE you will see another dialog informing to close this RIDE instance.')}" 

34 f"{SPC}\n", wx.GetTopLevelWindows()[0], no_default=True): 

35 return False 1a

36 else: 

37 # do_restart() 

38 return True 1a

39 

40 

41def do_restart(): 1ba

42 my_pid = psutil.Process() 1a

43 # DEBUG: The starting of new RIDE instance with subsequent closing of this instance, 

44 # makes problems in editing the current file, and even opening new file. Because of 

45 # this, the restarting was disabled, until someone finds a good way to clean-up memory. 

46 command = sys.executable + " -m robotide.__init__ --noupdatecheck" 1a

47 wx.CallLater(500, subprocess.Popen, command.split(' '), start_new_session=True) 1a

48 result = _askyesno(_("Completed Language Change"), 1a

49 f"\n{SPC}{_('You should close this RIDE (Process ID = ')}{my_pid.pid}){SPC}" 

50 f"\n{SPC}{_('Do you want to CLOSE RIDE now?')}\n{SPC}", 

51 wx.GetActiveWindow()) 

52 if result: 52 ↛ 53line 52 didn't jump to line 53 because the condition on line 52 was never true1a

53 wx.CallLater(1000, wx.App.Get().GetTopWindow().Close) 

54 return True