Skip to content

Commit

Permalink
Support for --version on the command line.
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmj committed May 2, 2014
1 parent 99315b1 commit a70c361
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
7 changes: 6 additions & 1 deletion gns3/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import traceback
import time
import locale
import argparse

import logging
log = logging.getLogger(__name__)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down
46 changes: 45 additions & 1 deletion gns3/modules/iou/pages/iou_preferences_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
"""
Expand Down

0 comments on commit a70c361

Please sign in to comment.