mirror of
https://github.com/GNS3/gns3-gui.git
synced 2026-05-17 00:46:01 +03:00
Small bug fixes all over the place for alpha-1.
This commit is contained in:
@@ -673,7 +673,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
event.accept()
|
||||
|
||||
servers = Servers.instance()
|
||||
servers.stopLocalServer()
|
||||
servers.stopLocalServer(wait=True)
|
||||
else:
|
||||
event.ignore()
|
||||
|
||||
@@ -747,9 +747,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
log.info("no local server is configured")
|
||||
return
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
QtGui.QMessageBox.critical(self, "Local server", "Please manually start the server: All programs -> GNS3-ER -> GNS3 Server")
|
||||
elif servers.startLocalServer(servers.localServerPath(), server.host, server.port):
|
||||
if servers.startLocalServer(servers.localServerPath(), server.host, server.port):
|
||||
thread = WaitForConnectionThread(server.host, server.port)
|
||||
self._progress_dialog = ProgressDialog(thread, "Local server", "Connecting...", "Cancel", busy=True, parent=self)
|
||||
self._progress_dialog.show()
|
||||
|
||||
@@ -404,6 +404,7 @@ class Dynamips(Module):
|
||||
for server in self._servers:
|
||||
if server.connected():
|
||||
server.send_notification("dynamips.reset")
|
||||
self._servers.clear()
|
||||
|
||||
def notification(self, destination, params):
|
||||
"""
|
||||
|
||||
@@ -388,7 +388,7 @@ class Router(Node):
|
||||
self.created_signal.emit(self.id())
|
||||
self._module.addNode(self)
|
||||
self._inital_settings = None
|
||||
elif updated:
|
||||
elif updated or self._loading:
|
||||
log.info("router {} has been updated".format(self.name()))
|
||||
self.updated_signal.emit()
|
||||
|
||||
|
||||
@@ -386,6 +386,7 @@ class IOU(Module):
|
||||
for server in self._servers:
|
||||
if server.connected():
|
||||
server.send_notification("iou.reset")
|
||||
self._servers.clear()
|
||||
|
||||
def notification(self, destination, params):
|
||||
"""
|
||||
|
||||
@@ -63,7 +63,7 @@ class IOUPreferencesPage(QtGui.QWidget, Ui_IOUPreferencesPageWidget):
|
||||
QtGui.QMessageBox.critical(self, "IOURC file", "{} cannot be read".format(os.path.basename(path)))
|
||||
return
|
||||
|
||||
self.uiIOURCPathLineEdit.setText(path)
|
||||
self.uiIOURCPathLineEdit.setText(os.path.normpath(path))
|
||||
|
||||
def _iouyapPathBrowserSlot(self):
|
||||
"""
|
||||
@@ -78,7 +78,7 @@ class IOUPreferencesPage(QtGui.QWidget, Ui_IOUPreferencesPageWidget):
|
||||
QtGui.QMessageBox.critical(self, "iouyap", "{} is not an executable".format(os.path.basename(path)))
|
||||
return
|
||||
|
||||
self.uiIouyapPathLineEdit.setText(path)
|
||||
self.uiIouyapPathLineEdit.setText(os.path.normpath(path))
|
||||
|
||||
def _testSettingsSlot(self):
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@ Keeps track of all the local and remote servers and their settings.
|
||||
|
||||
import sys
|
||||
import os
|
||||
import shlex
|
||||
import signal
|
||||
import subprocess
|
||||
from .qt import QtCore
|
||||
from .websocket_client import WebSocketClient
|
||||
|
||||
@@ -42,8 +45,7 @@ class Servers(QtCore.QObject):
|
||||
self._local_server = None
|
||||
self._remote_servers = {}
|
||||
self._local_server_path = ""
|
||||
self._local_server_proccess = QtCore.QProcess()
|
||||
self._local_server_proccess.setWorkingDirectory(os.curdir)
|
||||
self._local_server_proccess = None
|
||||
self._loadSettings()
|
||||
self._remote_server_iter_pos = 0
|
||||
|
||||
@@ -129,34 +131,44 @@ class Servers(QtCore.QObject):
|
||||
Starts the local server process.
|
||||
"""
|
||||
|
||||
params = ['--host=' + host, '--port=' + str(port)]
|
||||
params = ' --host=' + host + ' --port=' + str(port)
|
||||
# start the server, use Python on all platform but Windows (in release mode)
|
||||
if sys.platform.startswith('win') and os.path.splitext(path)[1] == '.exe':
|
||||
executable = '"' + path + '"'
|
||||
elif hasattr(sys, "frozen"):
|
||||
executable = "python3"
|
||||
params = [path] + params
|
||||
params = path + params
|
||||
else:
|
||||
executable = sys.executable
|
||||
params = [path] + params
|
||||
params = path + params
|
||||
|
||||
log.info("starting local server process {} with {}".format(executable, params))
|
||||
self._local_server_proccess.start(executable, params)
|
||||
command = executable + ' ' + params
|
||||
log.info("starting local server process with {}".format(command))
|
||||
|
||||
if self._local_server_proccess.waitForStarted() == False:
|
||||
try:
|
||||
if sys.platform.startswith("win"):
|
||||
# use the string on Windows
|
||||
self._local_server_proccess = subprocess.Popen(command)
|
||||
else:
|
||||
# use arguments on other platforms
|
||||
args = shlex.split(command)
|
||||
self._local_server_proccess = subprocess.Popen(args)
|
||||
except EnvironmentError as e:
|
||||
log.warning('could not start local server "{}": {}'.format(command, e))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def stopLocalServer(self, wait=False):
|
||||
|
||||
if self._local_server and self._local_server.connected():
|
||||
self._local_server.close_connection()
|
||||
if self._local_server_proccess.state() == QtCore.QProcess.Running:
|
||||
log.info("stopping local server process")
|
||||
self._local_server_proccess.terminate()
|
||||
if wait:
|
||||
self._local_server_proccess.waitForFinished()
|
||||
self._local_server_proccess.close()
|
||||
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()
|
||||
else:
|
||||
self._local_server_proccess.send_signal(signal.SIGINT)
|
||||
self._local_server_proccess.wait()
|
||||
|
||||
def setLocalServer(self, path, host, port):
|
||||
"""
|
||||
|
||||
@@ -118,8 +118,6 @@ class TopologySummaryView(QtGui.QTreeWidget):
|
||||
"""
|
||||
|
||||
node = self._topology.getNode(node_id)
|
||||
# just disconnect because the node cannot be created twice
|
||||
node.created_signal.disconnect(self._createdNodeSlot)
|
||||
TopologyNodeItem(self, node)
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
|
||||
@@ -53,7 +53,7 @@ class WaitForConnectionThread(QtCore.QThread):
|
||||
begin = time.time()
|
||||
|
||||
# try to connect for 10 seconds
|
||||
while(time.time() - begin < 10.0):
|
||||
while (time.time() - begin < 10.0):
|
||||
if not self._is_running:
|
||||
return
|
||||
time.sleep(0.01)
|
||||
|
||||
Reference in New Issue
Block a user