generated from itdominator/Python-With-Gtk-Template
Handle launch erroring
This commit is contained in:
parent
9bf78ed559
commit
ed63067bb8
|
@ -105,6 +105,11 @@ class BottomButtonBox(Gtk.Box):
|
||||||
def full_init(self, button, eve = None):
|
def full_init(self, button, eve = None):
|
||||||
button.hide()
|
button.hide()
|
||||||
self.start_stop_lsp(self.start_stop_lsp_btn)
|
self.start_stop_lsp(self.start_stop_lsp_btn)
|
||||||
|
|
||||||
|
if not hasattr(self.get_parent(), "lsp_process"):
|
||||||
|
self.rest_buttons()
|
||||||
|
return
|
||||||
|
|
||||||
self.send_initialize_message(self.initialize_btn)
|
self.send_initialize_message(self.initialize_btn)
|
||||||
self.send_initialized_message(self.initialized_btn)
|
self.send_initialized_message(self.initialized_btn)
|
||||||
|
|
||||||
|
@ -117,4 +122,4 @@ class BottomButtonBox(Gtk.Box):
|
||||||
self.request_btn.hide()
|
self.request_btn.hide()
|
||||||
self.full_init_btn.show()
|
self.full_init_btn.show()
|
||||||
|
|
||||||
self.start_stop_lsp_btn.set_image( Gtk.Image.new_from_icon_name("gtk-media-play", Gtk.IconSize.BUTTON) )
|
self.start_stop_lsp_btn.set_image( Gtk.Image.new_from_icon_name("gtk-media-play", Gtk.IconSize.BUTTON) )
|
|
@ -120,7 +120,7 @@ class LSPMessageBox(Gtk.Box):
|
||||||
self._send_message( LSPRequest(self._message_id, method, params) )
|
self._send_message( LSPRequest(self._message_id, method, params) )
|
||||||
|
|
||||||
def _send_message(self, data: LSPRequest or LSPNotification):
|
def _send_message(self, data: LSPRequest or LSPNotification):
|
||||||
if not data: return
|
if not data or not hasattr(self, "lsp_process"): return
|
||||||
|
|
||||||
message_str = json.dumps(data, cls = MessageEncoder)
|
message_str = json.dumps(data, cls = MessageEncoder)
|
||||||
message_size = len(message_str)
|
message_size = len(message_str)
|
||||||
|
@ -163,11 +163,24 @@ class LSPMessageBox(Gtk.Box):
|
||||||
# _command: str = parent.command_entry.get_text()
|
# _command: str = parent.command_entry.get_text()
|
||||||
# _command: str = parent.socket_entry.get_text()
|
# _command: str = parent.socket_entry.get_text()
|
||||||
command: [] = _command.split() if len( _command.split() ) > 0 else [ _command ]
|
command: [] = _command.split() if len( _command.split() ) > 0 else [ _command ]
|
||||||
self.lsp_process = subprocess.Popen(
|
try:
|
||||||
command,
|
self.lsp_process = subprocess.Popen(
|
||||||
stdout = subprocess.PIPE,
|
command,
|
||||||
stdin = subprocess.PIPE
|
stdout = subprocess.PIPE,
|
||||||
)
|
stdin = subprocess.PIPE
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
self.bottom_buttons.rest_buttons()
|
||||||
|
self.get_parent().log_list.add_log_entry(
|
||||||
|
"LSP Client Error",
|
||||||
|
LSPResponse(
|
||||||
|
None,
|
||||||
|
{
|
||||||
|
"error": repr(e)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
return self.lsp_process.pid
|
return self.lsp_process.pid
|
||||||
|
|
||||||
|
@ -183,6 +196,8 @@ class LSPMessageBox(Gtk.Box):
|
||||||
# Virtually this whole method unabashedly taken from ^ ...
|
# Virtually this whole method unabashedly taken from ^ ...
|
||||||
@daemon_threaded
|
@daemon_threaded
|
||||||
def _monitor_lsp_response(self):
|
def _monitor_lsp_response(self):
|
||||||
|
if not hasattr(self, "lsp_process"): return
|
||||||
|
|
||||||
with self.read_lock:
|
with self.read_lock:
|
||||||
message_size = None
|
message_size = None
|
||||||
while True:
|
while True:
|
||||||
|
|
Loading…
Reference in New Issue