From a70c3613346fd98dd3b2a0fe469a7ead1a8b316d Mon Sep 17 00:00:00 2001 From: grossmj Date: Thu, 1 May 2014 19:34:47 -0600 Subject: [PATCH] Support for --version on the command line. --- gns3/main.py | 7 ++- .../modules/iou/pages/iou_preferences_page.py | 46 ++++++++++++++++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/gns3/main.py b/gns3/main.py index 412ec363b..b2204698e 100644 --- a/gns3/main.py +++ b/gns3/main.py @@ -22,6 +22,7 @@ import traceback import time import locale +import argparse import logging log = logging.getLogger(__name__) @@ -78,7 +79,11 @@ def main(): Entry point for GNS3 GUI. """ + parser = argparse.ArgumentParser() + parser.add_argument('--version', help="show the version", action='version', version=__version__) + parser.parse_args() exception_file_path = "exception.log" + def exceptionHook(exception, value, tb): if exception == KeyboardInterrupt: @@ -164,7 +169,7 @@ def exceptionHook(exception, value, tb): app.setOrganizationDomain("gns3.net") app.setApplicationName("GNS3") app.setApplicationVersion(__version__) - + # update the exception file path to have it in the same directory as the settings file. exception_file_path = os.path.join(os.path.dirname(QtCore.QSettings().fileName()), exception_file_path) diff --git a/gns3/modules/iou/pages/iou_preferences_page.py b/gns3/modules/iou/pages/iou_preferences_page.py index ede98bcde..2c10954a6 100644 --- a/gns3/modules/iou/pages/iou_preferences_page.py +++ b/gns3/modules/iou/pages/iou_preferences_page.py @@ -21,7 +21,7 @@ import os import sys -from gns3.qt import QtGui +from gns3.qt import QtCore, QtGui from gns3.servers import Servers from .. import IOU from ..ui.iou_preferences_page_ui import Ui_IOUPreferencesPageWidget @@ -83,6 +83,50 @@ def _iouyapPathBrowserSlot(self): def _testSettingsSlot(self): QtGui.QMessageBox.critical(self, "Test settings", "Sorry, not yet implemented!") + return + + servers = Servers.instance() + if self.uiUseLocalServercheckBox.isChecked(): + server = servers.localServer() + else: + QtGui.QMessageBox.critical(self, "Test settings", "Sorry, not yet implemented!") + + try: + if not server.connected(): + server.reconnect() + except OSError as e: + QtGui.QMessageBox.critical(self, "Local server", "Could not connect to the local server {host} on port {port}: {error}".format(host=server.host, + port=server.port, + error=e)) + + self._progress_dialog = QtGui.QProgressDialog("Testing settings...", "Cancel", 0, 0, parent=self) + self._progress_dialog.setWindowModality(QtCore.Qt.WindowModal) + self._progress_dialog.setWindowTitle("Settings") + self._progress_dialog.show() + + iou_module = IOU.instance() + if server not in iou_module.servers(): + server_added = True + iou_module.addServer(server) + self.savePreferences() + if server_added: + iou_module.removeServer(server) + server.send_message("iou.test_settings", None, self._testSettingsCallback) + + def _testSettingsCallback(self, result, error=False): + + if self._progress_dialog.wasCanceled(): + print("Was canceled") + return + + self._progress_dialog.accept() + + if error: + pass + #log.error("error while allocating an UDP port for {}: {}".format(self.name(), result["message"])) + + print("Report received") + print(result) def _restoreDefaultsSlot(self): """