-adding root logger handler when no default exists

-fixes to ssh_to_server script for linux
-fixed callback for upload image thread
This commit is contained in:
Nasrullah Taha
2014-10-30 12:10:14 -06:00
parent 4828b3a73b
commit e9850ee962
4 changed files with 17 additions and 10 deletions

View File

@@ -323,12 +323,13 @@ class UploadFileThread(QThread):
"""
Upload a file to cloud files
"""
completed = pyqtSignal()
def __init__(self, cloud_settings, router_settings):
super().__init__()
self._cloud_settings = cloud_settings
self._router_settings = router_settings
self.completed_callback = None
def run(self):
disk_path = self._router_settings['path']
@@ -342,8 +343,7 @@ class UploadFileThread(QThread):
self._cloud_settings['image'] = filename
log.debug('Uploading image completed')
if self.completed_callback:
self.completed_callback()
self.completed.emit()
class DownloadProjectThread(QThread):

View File

@@ -194,7 +194,11 @@ def main():
if options.debug:
root_logger = logging.getLogger()
root_logger.setLevel(logging.DEBUG)
root_handler = root_logger.handlers[0]
if len(root_logger.handlers) > 0:
root_handler = root_logger.handlers[0]
else:
root_handler = logging.StreamHandler()
root_logger.addHandler(root_handler)
root_handler.setLevel(logging.DEBUG)
else:
handler.setLevel(logging.INFO)

View File

@@ -143,7 +143,7 @@ class IOSRouterPreferencesPage(QtGui.QWidget, Ui_IOSRouterPreferencesPageWidget)
self._upload_image_progress_dialog.show()
try:
upload_thread = UploadFileThread(MainWindow.instance().cloudSettings(), self._ios_routers[key])
upload_thread.completed_callback = self._imageUploadComplete
upload_thread.completed.connect(self._imageUploadComplete)
upload_thread.start()
except Exception as e:
self._upload_image_progress_dialog.reject()

View File

@@ -8,9 +8,13 @@ file.
"""
import os
import sys
from PyQt4 import QtCore, QtGui
QtCore.QSettings.setDefaultFormat(QtCore.QSettings.IniFormat)
if sys.platform.startswith('win') or sys.platform.startswith('darwin'):
QtCore.QSettings.setDefaultFormat(QtCore.QSettings.IniFormat)
app = QtGui.QApplication([])
app.setOrganizationName("GNS3")
@@ -36,10 +40,10 @@ def read_cloud_settings():
# For now, just use the first system.
return name, host, private_key, public_key
raise Exception("Could not find any servers")
name, host, private_key, public_key = read_cloud_settings()
name, host, private_key, public_key = read_cloud_settings()
print(name)
print(host)
@@ -53,4 +57,3 @@ os.system('chmod 0600 /tmp/id_rsa')
cmd = 'ssh -i /tmp/id_rsa root@{}'.format(host)
os.system(cmd)