mirror of
https://github.com/GNS3/gns3-gui.git
synced 2026-05-17 00:46:01 +03:00
Local server shutdown management.
Fix some terminal commands.
This commit is contained in:
@@ -690,7 +690,7 @@ class GraphicsView(QtGui.QGraphicsView):
|
||||
try:
|
||||
telnetConsole(name, console_host, console_port)
|
||||
except (OSError, ValueError) as e:
|
||||
QtGui.QMessageBox.critical(self, "Console", 'could not start console: {}'.format(e))
|
||||
QtGui.QMessageBox.critical(self, "Console", 'Cannot start console application: {}'.format(e))
|
||||
break
|
||||
|
||||
def idlepcActionSlot(self):
|
||||
|
||||
@@ -93,8 +93,8 @@ def main():
|
||||
|
||||
try:
|
||||
win32console.AllocConsole()
|
||||
#console_window = win32console.GetConsoleWindow()
|
||||
#win32gui.ShowWindow(console_window, win32con.SW_HIDE)
|
||||
console_window = win32console.GetConsoleWindow()
|
||||
win32gui.ShowWindow(console_window, win32con.SW_HIDE)
|
||||
except win32console.error as e:
|
||||
print("warning: could not allocate console: {}".format(e))
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ Main window for the GUI.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import socket
|
||||
import shutil
|
||||
@@ -806,8 +805,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
thread = ProcessFilesThread(self._project_files_dir, new_project_files_dir)
|
||||
self._progress_dialog = ProgressDialog(thread, "Project", "Copying project files...", "Cancel", parent=self)
|
||||
self._progress_dialog.show()
|
||||
if not self._progress_dialog.exec_():
|
||||
return False
|
||||
self._progress_dialog.exec_()
|
||||
|
||||
self._deleteTemporaryProject()
|
||||
self._project_files_dir = new_project_files_dir
|
||||
|
||||
@@ -148,7 +148,7 @@ class Servers(QtCore.QObject):
|
||||
try:
|
||||
if sys.platform.startswith("win"):
|
||||
# use the string on Windows
|
||||
self._local_server_proccess = subprocess.Popen(command)
|
||||
self._local_server_proccess = subprocess.Popen(command, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
|
||||
else:
|
||||
# use arguments on other platforms
|
||||
args = shlex.split(command)
|
||||
@@ -161,14 +161,17 @@ class Servers(QtCore.QObject):
|
||||
|
||||
def stopLocalServer(self, wait=False):
|
||||
|
||||
if self._local_server_proccess:
|
||||
if self._local_server and self._local_server.connected():
|
||||
log.info("sending stop request to the server")
|
||||
self._local_server.send_notification("builtin.stop")
|
||||
self._local_server.close_connection()
|
||||
# if self._local_server and self._local_server.connected():
|
||||
# log.info("sending stop request to the server")
|
||||
# #self._local_server.send_notification("builtin.stop")
|
||||
# self._local_server.close_connection()
|
||||
if self._local_server_proccess and self._local_server_proccess.poll() == None:
|
||||
if sys.platform.startswith("win"):
|
||||
self._local_server_proccess.send_signal(signal.CTRL_BREAK_EVENT)
|
||||
else:
|
||||
self._local_server_proccess.send_signal(signal.SIGINT)
|
||||
self._local_server_proccess.wait()
|
||||
if wait:
|
||||
self._local_server_proccess.wait()
|
||||
|
||||
def setLocalServer(self, path, host, port):
|
||||
"""
|
||||
|
||||
@@ -75,12 +75,12 @@ elif sys.platform.startswith("darwin"):
|
||||
DEFAULT_TELNET_CONSOLE_COMMAND = PRECONFIGURED_TELNET_CONSOLE_COMMANDS["Terminal"]
|
||||
|
||||
else:
|
||||
PRECONFIGURED_TELNET_CONSOLE_COMMANDS = {'xterm': 'xterm -T %d -e \'telnet %h %p\' >/dev/null 2>&1 &',
|
||||
PRECONFIGURED_TELNET_CONSOLE_COMMANDS = {'xterm': 'xterm -T %d -e \'telnet %h %p\'',
|
||||
'Putty': 'putty -telnet %h %p -title %d -sl 2500 -fg SALMON1 -bg BLACK',
|
||||
'Gnome Terminal': 'gnome-terminal -t %d -e \'telnet %h %p\' >/dev/null 2>&1 &',
|
||||
'KDE Konsole': 'konsole --new-tab -p tabtitle=%d -e telnet %h %p >/dev/null 2>&1 &',
|
||||
'Gnome Terminal': 'gnome-terminal -t %d -e \'telnet %h %p\'',
|
||||
'KDE Konsole': 'konsole --new-tab -p tabtitle=%d -e telnet %h %p',
|
||||
'SecureCRT': 'SecureCRT /T /N "%d" /TELNET %h %p',
|
||||
'Mate Terminal': 'mate-terminal --tab -e \'telnet %h %p\' -t %d >/dev/null 2>&1 & '}
|
||||
'Mate Terminal': 'mate-terminal --tab -e \'telnet %h %p\' -t %d'}
|
||||
|
||||
# default Telnet console command on other systems
|
||||
DEFAULT_TELNET_CONSOLE_COMMAND = PRECONFIGURED_TELNET_CONSOLE_COMMANDS["xterm"]
|
||||
|
||||
@@ -23,6 +23,9 @@ import os
|
||||
import shutil
|
||||
from ..qt import QtCore
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ProcessFilesThread(QtCore.QThread):
|
||||
"""
|
||||
@@ -92,12 +95,14 @@ class ProcessFilesThread(QtCore.QThread):
|
||||
else:
|
||||
shutil.copy2(source_file, destination_file)
|
||||
except OSError as e:
|
||||
pass # FIXME
|
||||
if self._move:
|
||||
log.warning("cannot move: {}".format(e))
|
||||
else:
|
||||
log.warning("cannot copy: {}".format(e))
|
||||
# if self._move:
|
||||
# self.error.emit("Could not move file to {}: {}".format(destination_file, str(e)))
|
||||
# else:
|
||||
# self.error.emit("Could not copy file to {}: {}".format(destination_file, str(e)))
|
||||
return
|
||||
copied += 1
|
||||
# update the progress made
|
||||
progress = float(copied) / file_count * 100
|
||||
|
||||
Reference in New Issue
Block a user