Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add messages to start and end Runner/RunAnything #2897

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Likewise, the current version of wxPython, is 4.2.2, but RIDE is known to work w

`pip install -U robotframework-ride`

(3.8 <= python <= 3.12) Install current development version (**2.1dev86**) with:
(3.8 <= python <= 3.12) Install current development version (**2.1dev87**) with:

`pip install -U https://github.com/robotframework/RIDE/archive/master.zip`

Expand Down
2 changes: 1 addition & 1 deletion src/robotide/application/releasenotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def set_content(self, html_win, content):
<pre class="literal-block">python -m robotide.postinstall -install</pre>
<p>or</p>
<pre class="literal-block">ride_postinstall.py -install</pre>
<p>RIDE {VERSION} was released on 07/October/2024.</p>
<p>RIDE {VERSION} was released on 08/October/2024.</p>
<!-- <br/>
<h3>May The Fourth Be With You!</h3>
<h3>Celebrate the bank holiday, 10th June, Day of Portugal, Portuguese Communities and Camões!!</h3>
Expand Down
42 changes: 12 additions & 30 deletions src/robotide/application/updatenotifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

import time
import urllib.request as urllib2
import xmlrpc.client as xmlrpclib
from dataclasses import dataclass

import psutil
import requests
import wx
from wx import Colour
Expand All @@ -32,6 +32,7 @@
from ..utils.versioncomparator import cmp_versions, parse_version
from ..widgets import ButtonWithHandler, HtmlWindow, RIDEDialog
from ..postinstall import MessageDialog
from ..publish import PUBLISHER, RideRunnerStarted, RideRunnerStopped

_ = wx.GetTranslation # To keep linter/code analyser happy
builtins.__dict__['_'] = wx.GetTranslation
Expand Down Expand Up @@ -161,46 +162,26 @@ def do_upgrade(command, notebook):
# print("DEBUG: Here will be the installation step.") # DEBUG 'pip list'
from ..run import ui
config = RunnerCommand('Upgrade RIDE', command, 'Uses pip to upgrade RIDE.')
PUBLISHER.subscribe(start_upgraded, RideRunnerStopped)
result = ui.Runner(config, notebook).run()
print(f"DEBUG: do_upgrade result={result}")
result = 0
# result = 0
time.sleep(10)
# wx.Exit()
"""
my_pid = psutil.Process()
my_pip = subprocess.Popen(command.split(' '), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
result = None
count = 0
while not result and count < 60:
count += 1
outs, errs = my_pip.communicate()
# DEBUG: Add output to a notebook tab
print(f"{outs}\n")
if errs:
print(f"\nERRORS: {errs}\n")
errs = None
result = my_pip.returncode
if result == 0:
break
time.sleep(1)
"""
if result != 0:
if result == -1:
_askyesno(_("Failed to Upgrade"), f"{SPC}{_('An error occurred when installing new version')}",
wx.GetActiveWindow())
return False


def start_upgraded(message):
command = sys.executable + " -m robotide.__init__ --noupdatecheck"
wx.CallLater(500, subprocess.Popen, command.split(' '), start_new_session=True)
# Wait 10 seconds before trying to kill this process
""" Not working well:
wx.CallLater(10000, psutil.Process.kill, my_pid.pid)
"""
result = _askyesno(_("Completed Upgrade"), f"\n{SPC}{_('You should close this RIDE (Process ID = ')}{result}){SPC}",
pid = psutil.Process.pid
result = _askyesno(_("Completed Upgrade"), f"\n{SPC}{_('You should close this RIDE (Process ID = ')}{pid}){SPC}",
wx.GetActiveWindow())
PUBLISHER.unsubscribe(start_upgraded, RideRunnerStopped)
if result:
time.sleep(10)
wx.App.Get().OnExit()
# _askyesno(_("Completed Upgrade"), f"\n{SPC}{_('You should close this RIDE (Process ID = ')}{my_pid.pid}){SPC}",
# wx.GetActiveWindow())


class LocalHtmlWindow(HtmlWindow):
Expand Down Expand Up @@ -277,4 +258,5 @@ def on_checkbox_change(self, event):
def on_upgrade_now(self, event):
__ = event
_add_content_to_clipboard(self._command)
self.Hide()
do_upgrade(self._command, self._notebook)
9 changes: 9 additions & 0 deletions src/robotide/publish/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,5 +472,14 @@ class RideTreeAwarePluginAdded(RideMessage):
data = ['plugin']


class RideRunnerStarted(RideMessage):
""" Sent when a process is started at Runner/RunAnything """
data = ['process']

class RideRunnerStopped(RideMessage):
""" Sent when a process is stopped at Runner/RunAnything """
data = ['process']


__all__ = [name for name, cls in globals().items()
if inspect.isclass(cls) and issubclass(cls, RideMessage)]
9 changes: 9 additions & 0 deletions src/robotide/run/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import subprocess
import tempfile
import time
from ..publish import RideRunnerStarted, RideRunnerStopped


class Process(object):
Expand All @@ -29,6 +30,11 @@ def __init__(self, command):
self._out_path = None
self._out_fd = None
self._fuse = False
self._pid =None

@property
def pid(self):
return self._pid

@staticmethod
def _parse_command(command):
Expand All @@ -44,6 +50,8 @@ def start(self):
return
try:
self._process = subprocess.Popen(self._command, stdout=self._out_fd, stderr=subprocess.STDOUT)
self._pid = self._process.pid
RideRunnerStarted(process=self._pid).publish()
except OSError as err:
self._error = str(err)

Expand All @@ -53,6 +61,7 @@ def is_finished(self):
def stop(self):
self._process.kill()
self._close_outputs()
RideRunnerStopped(process=self._pid).publish()

def wait(self):
if self._process is not None:
Expand Down
14 changes: 12 additions & 2 deletions src/robotide/run/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
from .process import Process
from ..widgets import Label, Font, VerticalSizer, HorizontalSizer
from ..log import LogOutput
from ..publish import RideRunnerStopped

_ = wx.GetTranslation # To keep linter/code analyser happy
builtins.__dict__['_'] = wx.GetTranslation

FINNISHED = _('finished')
FINISHED = _('finished')
RUN_AGAIN = _('Run Again')
RUNNING = _('running')
STOP = _('Stop')
Expand All @@ -48,6 +49,11 @@ def __init__(self, config, notebook):
self._config = config
self._window = self._get_output_window(notebook)
self.output_panel = self._window.output_panel
self._pid = None

@property
def pid(self):
return self._pid

def _get_output_window(self, notebook):
return _OutputWindow(notebook, self)
Expand All @@ -62,8 +68,11 @@ def run(self):
try:
self._process.start()
self._timer.Start(500)
self._pid = self._process.pid
return self._pid
except Exception as err:
wx.MessageBox(str(err), style=wx.ICON_ERROR)
return -1

def on_timer(self, event=None):
__ = event
Expand Down Expand Up @@ -114,7 +123,8 @@ def update_output(self, output, finished=False):
self.output_panel.update(output)
self.SetVirtualSize(self.output_panel.Size)
if finished:
self._rename_tab(f"{self._runner.name} ({FINNISHED})")
RideRunnerStopped(process=self._runner.pid).publish()
self._rename_tab(f"{self._runner.name} ({FINISHED})")
self.Parent.allow_closing(self)
self._state_button.enable_run_again()
size = (max(85, self._font_size * len(' ' + RUN_AGAIN + ' ')), max(28, self._font_size * 3))
Expand Down
2 changes: 1 addition & 1 deletion src/robotide/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
#
# Automatically generated by `tasks.py`.

VERSION = 'v2.1dev86'
VERSION = 'v2.1dev87'
Loading