Skip to content

Instantly share code, notes, and snippets.

@carlohamalainen
Created December 10, 2012 23:13
Show Gist options
  • Save carlohamalainen/4254229 to your computer and use it in GitHub Desktop.
Save carlohamalainen/4254229 to your computer and use it in GitHub Desktop.
callafter thread debugging
# Debugging for a threading/ui problem. Sometimes get stuck in an infinite
# loop just after the line "logger.debug('AAA 6')"
import logging
from StringIO import StringIO
# The top-level logging object. We call this with things like
# logger.debug(...), logger.error(...), etc.
global logger
logger = None
# We also save log messages to a file, so we need access to the
# logger FileHandler object.
global logger_fh
logger_fh = None
import sys
import wx
import threading
import os
import time
global launcherMainFrame
launcherMainFrame = None
class LauncherMainFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER)
self.menu_bar = wx.MenuBar()
self.file_menu = wx.Menu()
self.file_menu.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Close window and exit program.")
self.Bind(wx.EVT_MENU, self.onExit, id=wx.ID_EXIT)
self.menu_bar.Append(self.file_menu, "&File")
self.help_menu = wx.Menu()
self.help_menu.Append(wx.ID_ABOUT, "&About MASSIVE/CVL Launcher")
self.Bind(wx.EVT_MENU, self.onAbout, id=wx.ID_ABOUT)
self.menu_bar.Append(self.help_menu, "&Help")
self.SetTitle("MASSIVE / CVL Launcher")
self.SetMenuBar(self.menu_bar)
self.loginDialogPanel = wx.Panel(self, wx.ID_ANY)
self.loginDialogPanelSizer = wx.FlexGridSizer(rows=2, cols=1, vgap=15, hgap=5)
self.tabbedView = wx.Notebook(self.loginDialogPanel, wx.ID_ANY, style=(wx.NB_TOP))
# MASSIVE tab
self.massiveLoginDialogPanel = wx.Panel(self.tabbedView, wx.ID_ANY)
self.massiveLoginDialogPanelSizer = wx.FlexGridSizer(rows=2, cols=1, vgap=5, hgap=5)
self.massiveLoginFieldsPanel = wx.Panel(self.massiveLoginDialogPanel, wx.ID_ANY)
self.massiveLoginFieldsPanelSizer = wx.FlexGridSizer(rows=7, cols=2, vgap=3, hgap=5)
self.massiveLoginFieldsPanel.SetSizer(self.massiveLoginFieldsPanelSizer)
widgetWidth1 = 180
widgetWidth2 = 180
if not sys.platform.startswith("win"):
widgetWidth2 = widgetWidth2 + 25
widgetWidth3 = 75
self.massiveLoginHostLabel = wx.StaticText(self.massiveLoginFieldsPanel, wx.ID_ANY, 'Host')
self.massiveLoginFieldsPanelSizer.Add(self.massiveLoginHostLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
self.massiveLoginHost = ""
massiveLoginHosts = ["m1-login1.massive.org.au", "m1-login2.massive.org.au",
"m2-login1.massive.org.au", "m2-login2.massive.org.au"]
defaultMassiveHost = "m2-login2.massive.org.au"
self.massiveLoginHostComboBox = wx.ComboBox(self.massiveLoginFieldsPanel, wx.ID_ANY, value=defaultMassiveHost, choices=massiveLoginHosts, size=(widgetWidth2, -1), style=wx.CB_DROPDOWN)
self.massiveLoginFieldsPanelSizer.Add(self.massiveLoginHostComboBox, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
self.massiveLoginHost = self.massiveLoginHost.strip()
if self.massiveLoginHost!="":
if self.massiveLoginHost in massiveLoginHosts:
self.massiveLoginHostComboBox.SetSelection(massiveLoginHosts.index(self.massiveLoginHost))
else:
# Hostname was not found in combo-box.
self.massiveLoginHostComboBox.SetSelection(-1)
self.massiveLoginHostComboBox.SetValue(self.massiveLoginHost)
self.massiveProjectLabel = wx.StaticText(self.massiveLoginFieldsPanel, wx.ID_ANY, 'MASSIVE project')
self.massiveLoginFieldsPanelSizer.Add(self.massiveProjectLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
# The pre-populated list of projects in the combo-box is
# hard-coded for now, because
# Karaage (http://code.vpac.org/trac/karaage/)
# doesn't appear to provide a way to list all projects on MASSIVE
# without authenticating.
# The user can type in the project name themself, or use the
# [Use my default project] option.
self.defaultProjectPlaceholder = '[Use my default project]'
self.massiveProjects = [
self.defaultProjectPlaceholder,
'ASync001','ASync002','ASync003','ASync004','ASync005','ASync006',
'ASync007','ASync008','ASync009','ASync010','ASync011',
'CSIRO001','CSIRO002','CSIRO003','CSIRO004','CSIRO005','CSIRO006',
'CSIRO007',
'Desc001','Desc002','Desc003','Desc004',
'Monash001','Monash002','Monash003','Monash004',
'Monash005','Monash006','Monash007','Monash008',
'Monash009','Monash010','Monash011','Monash012','Monash013',
'Monash014','Monash015','Monash016','Monash017','Monash018',
'Monash019','Monash020','Monash021','Monash022','Monash023',
'Monash024','Monash025','Monash026','Monash027','Monash028',
'Monash029','Monash030','Monash031','Monash032','Monash033',
'Monash034','Monash035','Monash036',
'NCId75','NCIdb5','NCIdc0','NCIdd2','NCIg61','NCIg75',
'NCIq97','NCIr14','NCIw25','NCIw27','NCIw67','NCIw81','NCIw91',
'NCIy40','NCIy95','NCIy96',
'pDeak0023','pDeak0024','pDeak0026',
'pLaTr0011',
'pMelb0095','pMelb0100','pMelb0103','pMelb0104',
'pMOSP',
'pRMIT0074','pRMIT0078','pRMIT0083',
'pVPAC0005',
'Training'
]
self.massiveProjectComboBox = wx.ComboBox(self.massiveLoginFieldsPanel, wx.ID_ANY, value='', choices=self.massiveProjects, size=(widgetWidth2, -1), style=wx.CB_DROPDOWN)
self.massiveLoginFieldsPanelSizer.Add(self.massiveProjectComboBox, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
self.massiveProject = ""
self.massiveProject = self.massiveProject.strip()
if self.massiveProject!="":
if self.massiveProject in self.massiveProjects:
self.massiveProjectComboBox.SetSelection(self.massiveProjects.index(self.massiveProject))
else:
# Project was not found in combo-box.
self.massiveProjectComboBox.SetSelection(-1)
self.massiveProjectComboBox.SetValue(self.massiveProject)
else:
self.massiveProjectComboBox.SetValue(self.defaultProjectPlaceholder)
self.massiveHoursLabel = wx.StaticText(self.massiveLoginFieldsPanel, wx.ID_ANY, 'Hours requested')
self.massiveLoginFieldsPanelSizer.Add(self.massiveHoursLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
self.massiveHoursAndVisNodesPanel = wx.Panel(self.massiveLoginFieldsPanel, wx.ID_ANY)
self.massiveHoursAndVisNodesPanelSizer = wx.FlexGridSizer(rows=2, cols=3, vgap=3, hgap=5)
self.massiveHoursAndVisNodesPanel.SetSizer(self.massiveHoursAndVisNodesPanelSizer)
self.massiveHoursRequested = "4"
# Maximum of 336 hours is 2 weeks:
#self.massiveHoursField = wx.SpinCtrl(self.massiveLoginFieldsPanel, wx.ID_ANY, value=self.massiveHoursRequested, min=1,max=336)
self.massiveHoursField = wx.SpinCtrl(self.massiveHoursAndVisNodesPanel, wx.ID_ANY, value=self.massiveHoursRequested, size=(widgetWidth3,-1), min=1,max=336)
#self.massiveLoginFieldsPanelSizer.Add(self.massiveHoursField, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
self.massiveHoursAndVisNodesPanelSizer.Add(self.massiveHoursField, flag=wx.TOP|wx.BOTTOM|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
self.massiveVisNodesLabel = wx.StaticText(self.massiveHoursAndVisNodesPanel, wx.ID_ANY, 'Vis nodes')
self.massiveHoursAndVisNodesPanelSizer.Add(self.massiveVisNodesLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
self.massiveVisNodesRequested = "1"
self.massiveVisNodesField = wx.SpinCtrl(self.massiveHoursAndVisNodesPanel, wx.ID_ANY, value=self.massiveVisNodesRequested, size=(widgetWidth3,-1), min=1,max=10)
self.massiveHoursAndVisNodesPanelSizer.Add(self.massiveVisNodesField, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
self.massiveHoursAndVisNodesPanel.SetSizerAndFit(self.massiveHoursAndVisNodesPanelSizer)
self.massiveLoginFieldsPanelSizer.Add(self.massiveHoursAndVisNodesPanel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
if self.massiveLoginHost.startswith("m1"):
self.massivePersistentMode = True
else:
self.massivePersistentMode = False
self.massivePersistentModeLabel = wx.StaticText(self.massiveLoginFieldsPanel, wx.ID_ANY, 'Persistent mode')
self.massiveLoginFieldsPanelSizer.Add(self.massivePersistentModeLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
self.massivePersistentModeCheckBox = wx.CheckBox(self.massiveLoginFieldsPanel, wx.ID_ANY, "")
self.massivePersistentModeCheckBox.SetValue(self.massivePersistentMode)
self.massiveLoginFieldsPanelSizer.Add(self.massivePersistentModeCheckBox, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
self.massiveVncDisplayResolutionLabel = wx.StaticText(self.massiveLoginFieldsPanel, wx.ID_ANY, 'Resolution')
self.massiveLoginFieldsPanelSizer.Add(self.massiveVncDisplayResolutionLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
displaySize = wx.DisplaySize()
desiredWidth = displaySize[0] * 0.99
desiredHeight = displaySize[1] * 0.85
defaultResolution = str(int(desiredWidth)) + "x" + str(int(desiredHeight))
self.massiveVncDisplayResolution = defaultResolution
massiveVncDisplayResolutions = [
defaultResolution, "1024x768", "1152x864", "1280x800", "1280x1024", "1360x768", "1366x768", "1440x900", "1600x900", "1680x1050", "1920x1080", "1920x1200", "7680x3200",
]
self.massiveVncDisplayResolutionComboBox = wx.ComboBox(self.massiveLoginFieldsPanel, wx.ID_ANY, value='', choices=massiveVncDisplayResolutions, size=(widgetWidth2, -1), style=wx.CB_DROPDOWN)
self.massiveLoginFieldsPanelSizer.Add(self.massiveVncDisplayResolutionComboBox, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
self.massiveVncDisplayResolution = self.massiveVncDisplayResolution.strip()
if self.massiveVncDisplayResolution!="":
if self.massiveVncDisplayResolution in massiveVncDisplayResolutions:
self.massiveVncDisplayResolutionComboBox.SetSelection(massiveVncDisplayResolutions.index(self.massiveVncDisplayResolution))
else:
# Resolution was not found in combo-box.
self.massiveVncDisplayResolutionComboBox.SetSelection(-1)
self.massiveVncDisplayResolutionComboBox.SetValue(self.massiveVncDisplayResolution)
else:
self.massiveVncDisplayResolutionComboBox.SetValue(defaultResolution)
self.massiveSshTunnelCipherLabel = wx.StaticText(self.massiveLoginFieldsPanel, wx.ID_ANY, 'SSH tunnel cipher')
self.massiveLoginFieldsPanelSizer.Add(self.massiveSshTunnelCipherLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
self.massiveSshTunnelCipher = ""
if sys.platform.startswith("win"):
defaultCipher = "arcfour"
massiveSshTunnelCiphers = ["3des-cbc", "aes128-cbc", "blowfish-cbc", "arcfour"]
else:
defaultCipher = "arcfour128"
massiveSshTunnelCiphers = ["3des-cbc", "aes128-cbc", "blowfish-cbc", "arcfour128"]
self.massiveSshTunnelCipher = defaultCipher
self.massiveSshTunnelCipherComboBox = wx.ComboBox(self.massiveLoginFieldsPanel, wx.ID_ANY, value='', choices=massiveSshTunnelCiphers, size=(widgetWidth2, -1), style=wx.CB_DROPDOWN)
self.massiveLoginFieldsPanelSizer.Add(self.massiveSshTunnelCipherComboBox, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
self.massiveSshTunnelCipher = self.massiveSshTunnelCipher.strip()
if self.massiveSshTunnelCipher=="":
self.massiveSshTunnelCipher = defaultCipher
if self.massiveSshTunnelCipher!="":
if self.massiveSshTunnelCipher in massiveSshTunnelCiphers:
self.massiveSshTunnelCipherComboBox.SetSelection(massiveSshTunnelCiphers.index(self.massiveSshTunnelCipher))
else:
# Cipher was not found in combo-box.
self.massiveSshTunnelCipherComboBox.SetSelection(-1)
self.massiveSshTunnelCipherComboBox.SetValue(self.massiveSshTunnelCipher)
else:
self.massiveSshTunnelCipherComboBox.SetValue(defaultCipher)
self.massiveUsernameLabel = wx.StaticText(self.massiveLoginFieldsPanel, wx.ID_ANY, 'Username')
self.massiveLoginFieldsPanelSizer.Add(self.massiveUsernameLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
self.massiveUsername = ""
self.massiveUsernameTextField = wx.TextCtrl(self.massiveLoginFieldsPanel, wx.ID_ANY, self.massiveUsername, size=(widgetWidth1, -1))
self.massiveLoginFieldsPanelSizer.Add(self.massiveUsernameTextField, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=8)
if self.massiveUsername.strip()!="":
self.massiveUsernameTextField.SelectAll()
self.massivePasswordLabel = wx.StaticText(self.massiveLoginFieldsPanel, wx.ID_ANY, 'Password')
self.massiveLoginFieldsPanelSizer.Add(self.massivePasswordLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
self.massivePassword = ""
self.massivePasswordField = wx.TextCtrl(self.massiveLoginFieldsPanel, wx.ID_ANY, self.massivePassword, size=(widgetWidth1, -1), style=wx.TE_PASSWORD)
self.massiveLoginFieldsPanelSizer.Add(self.massivePasswordField, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=8)
self.massiveUsernameTextField.SetFocus()
self.massiveProjectComboBox.MoveAfterInTabOrder(self.massiveLoginHostComboBox)
#self.massiveHoursField.MoveAfterInTabOrder(self.massiveProjectComboBox)
self.massiveHoursAndVisNodesPanel.MoveAfterInTabOrder(self.massiveProjectComboBox)
#self.massiveVncDisplayResolutionComboBox.MoveAfterInTabOrder(self.massiveHoursField)
self.massiveVncDisplayResolutionComboBox.MoveAfterInTabOrder(self.massiveHoursAndVisNodesPanel)
self.massiveSshTunnelCipherComboBox.MoveAfterInTabOrder(self.massiveVncDisplayResolutionComboBox)
self.massiveUsernameTextField.MoveAfterInTabOrder(self.massiveSshTunnelCipherComboBox)
self.massivePasswordField.MoveAfterInTabOrder(self.massiveUsernameTextField)
self.massiveLoginFieldsPanel.SetSizerAndFit(self.massiveLoginFieldsPanelSizer)
self.massiveLoginDialogPanelSizer.Add(self.massiveLoginFieldsPanel, flag=wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, border=15)
self.massiveLoginDialogPanel.SetSizerAndFit(self.massiveLoginDialogPanelSizer)
self.massiveLoginDialogPanel.Layout()
self.tabbedView.AddPage(self.massiveLoginDialogPanel, "MASSIVE")
# CVL tab
self.cvlLoginDialogPanel = wx.Panel(self.tabbedView, wx.ID_ANY)
self.tabbedView.AddPage(self.cvlLoginDialogPanel, "CVL")
self.cvlLoginDialogPanelSizer = wx.FlexGridSizer(rows=2, cols=1, vgap=5, hgap=5)
self.cvlLoginFieldsPanel = wx.Panel(self.cvlLoginDialogPanel, wx.ID_ANY)
self.cvlLoginFieldsPanelSizer = wx.FlexGridSizer(rows=7, cols=2, vgap=3, hgap=5)
self.cvlLoginFieldsPanel.SetSizer(self.cvlLoginFieldsPanelSizer)
self.cvlLoginHostLabel = wx.StaticText(self.cvlLoginFieldsPanel, wx.ID_ANY, 'Host')
self.cvlLoginFieldsPanelSizer.Add(self.cvlLoginHostLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
self.cvlLoginHost = ""
cvlLoginHosts = ["115.146.93.198","115.146.94.0"]
defaultCvlHost = "115.146.93.198"
self.cvlLoginHostComboBox = wx.ComboBox(self.cvlLoginFieldsPanel, wx.ID_ANY, value=defaultCvlHost, choices=cvlLoginHosts, size=(widgetWidth2, -1), style=wx.CB_DROPDOWN)
self.cvlLoginFieldsPanelSizer.Add(self.cvlLoginHostComboBox, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
self.cvlLoginHost = self.cvlLoginHost.strip()
if self.cvlLoginHost!="":
if self.cvlLoginHost in cvlLoginHosts:
self.cvlLoginHostComboBox.SetSelection(cvlLoginHosts.index(self.cvlLoginHost))
else:
# Hostname was not found in combo-box.
self.cvlLoginHostComboBox.SetSelection(-1)
self.cvlLoginHostComboBox.SetValue(self.cvlLoginHost)
self.cvlVncDisplayNumberLabel = wx.StaticText(self.cvlLoginFieldsPanel, wx.ID_ANY, 'Display number')
self.cvlLoginFieldsPanelSizer.Add(self.cvlVncDisplayNumberLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
self.cvlVncDisplayNumberAutomatic = True
self.cvlVncDisplayNumber = 1
self.cvlVncDisplayNumberPanel = wx.Panel(self.cvlLoginFieldsPanel, wx.ID_ANY)
self.cvlVncDisplayNumberPanelSizer = wx.FlexGridSizer(rows=1, cols=2, vgap=5, hgap=20)
self.cvlVncDisplayNumberPanel.SetSizer(self.cvlVncDisplayNumberPanelSizer)
self.cvlVncDisplayNumberAutomaticCheckBox = wx.CheckBox(self.cvlVncDisplayNumberPanel, wx.ID_ANY, "Automatic")
self.cvlVncDisplayNumberPanelSizer.Add(self.cvlVncDisplayNumberAutomaticCheckBox, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_BOTTOM, border=5)
self.cvlVncDisplayNumberSpinCtrl = wx.SpinCtrl(self.cvlVncDisplayNumberPanel, wx.ID_ANY, min=0,max=100)
if self.cvlVncDisplayNumberAutomatic==True:
self.cvlVncDisplayNumberAutomaticCheckBox.SetValue(True)
self.cvlVncDisplayNumberSpinCtrl.SetValue(1)
self.cvlVncDisplayNumberSpinCtrl.Disable()
if self.cvlVncDisplayNumberAutomatic==False:
self.cvlVncDisplayNumberAutomaticCheckBox.SetValue(False)
self.cvlVncDisplayNumberSpinCtrl.SetValue(self.cvlVncDisplayNumber)
self.cvlVncDisplayNumberPanelSizer.Add(self.cvlVncDisplayNumberSpinCtrl, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_BOTTOM, border=5)
self.cvlVncDisplayNumberPanel.SetSizerAndFit(self.cvlVncDisplayNumberPanelSizer)
self.cvlLoginFieldsPanelSizer.Add(self.cvlVncDisplayNumberPanel, flag=wx.ALIGN_RIGHT|wx.RIGHT, border=10)
self.cvlVncDisplayResolutionLabel = wx.StaticText(self.cvlLoginFieldsPanel, wx.ID_ANY, 'Resolution')
self.cvlLoginFieldsPanelSizer.Add(self.cvlVncDisplayResolutionLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
displaySize = wx.DisplaySize()
desiredWidth = displaySize[0] * 0.99
desiredHeight = displaySize[1] * 0.85
defaultResolution = str(int(desiredWidth)) + "x" + str(int(desiredHeight))
self.cvlVncDisplayResolution = defaultResolution
cvlVncDisplayResolutions = [
defaultResolution, "1024x768", "1152x864", "1280x800", "1280x1024", "1360x768", "1366x768", "1440x900", "1600x900", "1680x1050", "1920x1080", "1920x1200", "7680x3200",
]
self.cvlVncDisplayResolutionComboBox = wx.ComboBox(self.cvlLoginFieldsPanel, wx.ID_ANY, value='', choices=cvlVncDisplayResolutions, size=(widgetWidth2, -1), style=wx.CB_DROPDOWN)
self.cvlLoginFieldsPanelSizer.Add(self.cvlVncDisplayResolutionComboBox, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
self.cvlVncDisplayResolution = self.cvlVncDisplayResolution.strip()
if self.cvlVncDisplayResolution!="":
if self.cvlVncDisplayResolution in cvlVncDisplayResolutions:
self.cvlVncDisplayResolutionComboBox.SetSelection(cvlVncDisplayResolutions.index(self.cvlVncDisplayResolution))
else:
# Resolution was not found in combo-box.
self.cvlVncDisplayResolutionComboBox.SetSelection(-1)
self.cvlVncDisplayResolutionComboBox.SetValue(self.cvlVncDisplayResolution)
else:
self.cvlVncDisplayResolutionComboBox.SetValue(defaultResolution)
if self.cvlVncDisplayNumberAutomatic==False:
self.cvlVncDisplayResolutionComboBox.Disable()
self.cvlVncDisplayResolutionLabel.Disable()
self.cvlSshTunnelCipherLabel = wx.StaticText(self.cvlLoginFieldsPanel, wx.ID_ANY, 'SSH tunnel cipher')
self.cvlLoginFieldsPanelSizer.Add(self.cvlSshTunnelCipherLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
defaultCipher = ""
self.cvlSshTunnelCipher = ""
cvlSshTunnelCiphers = [""]
if sys.platform.startswith("win"):
defaultCipher = "arcfour"
cvlSshTunnelCiphers = ["3des-cbc", "aes128-cbc", "blowfish-cbc", "arcfour"]
else:
defaultCipher = "arcfour128"
cvlSshTunnelCiphers = ["3des-cbc", "aes128-cbc", "blowfish-cbc", "arcfour128"]
self.cvlSshTunnelCipherComboBox = wx.ComboBox(self.cvlLoginFieldsPanel, wx.ID_ANY, value='', choices=cvlSshTunnelCiphers, size=(widgetWidth2, -1), style=wx.CB_DROPDOWN)
self.cvlLoginFieldsPanelSizer.Add(self.cvlSshTunnelCipherComboBox, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
self.cvlSshTunnelCipher = self.cvlSshTunnelCipher.strip()
if self.cvlSshTunnelCipher=="":
self.cvlSshTunnelCipher = defaultCipher
if self.cvlSshTunnelCipher!="":
if self.cvlSshTunnelCipher in cvlSshTunnelCiphers:
self.cvlSshTunnelCipherComboBox.SetSelection(cvlSshTunnelCiphers.index(self.cvlSshTunnelCipher))
else:
# Cipher was not found in combo-box.
self.cvlSshTunnelCipherComboBox.SetSelection(-1)
self.cvlSshTunnelCipherComboBox.SetValue(self.cvlSshTunnelCipher)
else:
self.cvlSshTunnelCipherComboBox.SetValue(defaultCipher)
self.cvlUsernameLabel = wx.StaticText(self.cvlLoginFieldsPanel, wx.ID_ANY, 'Username')
self.cvlLoginFieldsPanelSizer.Add(self.cvlUsernameLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
self.cvlUsername = ""
self.cvlUsernameTextField = wx.TextCtrl(self.cvlLoginFieldsPanel, wx.ID_ANY, self.cvlUsername, size=(widgetWidth1, -1))
self.cvlLoginFieldsPanelSizer.Add(self.cvlUsernameTextField, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=8)
if self.cvlUsername.strip()!="":
self.cvlUsernameTextField.SelectAll()
self.cvlPasswordLabel = wx.StaticText(self.cvlLoginFieldsPanel, wx.ID_ANY, 'Password')
self.cvlLoginFieldsPanelSizer.Add(self.cvlPasswordLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
self.cvlPassword = ""
self.cvlPasswordField = wx.TextCtrl(self.cvlLoginFieldsPanel, wx.ID_ANY, self.cvlPassword, size=(widgetWidth1, -1), style=wx.TE_PASSWORD)
self.cvlLoginFieldsPanelSizer.Add(self.cvlPasswordField, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=8)
self.cvlVncDisplayNumberPanel.MoveAfterInTabOrder(self.cvlLoginHostComboBox)
self.cvlVncDisplayNumberPanel.MoveAfterInTabOrder(self.cvlVncDisplayNumberPanel)
self.cvlVncDisplayResolutionComboBox.MoveAfterInTabOrder(self.cvlVncDisplayNumberPanel)
self.cvlSshTunnelCipherComboBox.MoveAfterInTabOrder(self.cvlVncDisplayResolutionComboBox)
self.cvlUsernameTextField.MoveAfterInTabOrder(self.cvlSshTunnelCipherComboBox)
self.cvlPasswordField.MoveAfterInTabOrder(self.cvlUsernameTextField)
self.cvlShowDebugWindowLabel = wx.StaticText(self.cvlLoginFieldsPanel, wx.ID_ANY, 'Show debug window')
self.cvlLoginFieldsPanelSizer.Add(self.cvlShowDebugWindowLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
self.cvlShowDebugWindowCheckBox = wx.CheckBox(self.cvlLoginFieldsPanel, wx.ID_ANY, "")
self.cvlShowDebugWindowCheckBox.SetValue(False)
self.cvlLoginFieldsPanelSizer.Add(self.cvlShowDebugWindowCheckBox, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
self.cvlLoginFieldsPanel.SetSizerAndFit(self.cvlLoginFieldsPanelSizer)
self.cvlLoginDialogPanelSizer.Add(self.cvlLoginFieldsPanel, flag=wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, border=15)
self.cvlLoginDialogPanel.SetSizerAndFit(self.cvlLoginDialogPanelSizer)
self.cvlLoginDialogPanel.Layout()
# End CVL tab
self.loginDialogPanelSizer.Add(self.tabbedView, flag=wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, border=10)
MASSIVE_TAB_INDEX = 0
self.tabbedView.ChangeSelection(MASSIVE_TAB_INDEX)
self.massiveTabSelected = True
self.cvlTabSelected = False
# Buttons Panel
self.buttonsPanel = wx.Panel(self.loginDialogPanel, wx.ID_ANY)
self.buttonsPanelSizer = wx.FlexGridSizer(rows=1, cols=3, vgap=5, hgap=10)
self.buttonsPanel.SetSizer(self.buttonsPanelSizer)
OPTIONS_BUTTON_ID = 1
self.optionsButton = wx.Button(self.buttonsPanel, OPTIONS_BUTTON_ID, 'Options...')
self.buttonsPanelSizer.Add(self.optionsButton, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT, border=10)
self.Bind(wx.EVT_BUTTON, self.onOptions, id=OPTIONS_BUTTON_ID)
CANCEL_BUTTON_ID = 2
self.cancelButton = wx.Button(self.buttonsPanel, CANCEL_BUTTON_ID, 'Cancel')
self.buttonsPanelSizer.Add(self.cancelButton, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT, border=10)
self.Bind(wx.EVT_BUTTON, self.onCancel, id=CANCEL_BUTTON_ID)
LOGIN_BUTTON_ID = 3
self.loginButton = wx.Button(self.buttonsPanel, LOGIN_BUTTON_ID, 'Login')
self.buttonsPanelSizer.Add(self.loginButton, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT, border=10)
self.Bind(wx.EVT_BUTTON, self.onLogin, id=LOGIN_BUTTON_ID)
self.buttonsPanel.SetSizerAndFit(self.buttonsPanelSizer)
self.loginDialogPanelSizer.Add(self.buttonsPanel, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT, border=15)
self.loginButton.SetDefault()
self.loginDialogStatusBar = LauncherStatusBar(self)
self.SetStatusBar(self.loginDialogStatusBar)
self.loginDialogPanel.SetSizerAndFit(self.loginDialogPanelSizer)
self.loginDialogPanel.Layout()
self.Fit()
self.Layout()
self.Centre()
def onAbout(self, event):
pass
def onExit(self, event):
pass
def onOptions(self, event):
pass
def onCancel(self, event):
pass
def SetCursor(self, cursor):
self.massiveLoginDialogPanel.SetCursor(cursor)
self.massiveLoginFieldsPanel.SetCursor(cursor)
self.massiveLoginHostLabel.SetCursor(cursor)
self.massiveProjectLabel.SetCursor(cursor)
self.massiveHoursLabel.SetCursor(cursor)
self.massiveVncDisplayResolutionLabel.SetCursor(cursor)
self.massiveSshTunnelCipherLabel.SetCursor(cursor)
self.massiveUsernameLabel.SetCursor(cursor)
self.massivePasswordLabel.SetCursor(cursor)
self.massiveLoginHostComboBox.SetCursor(cursor)
self.massiveVncDisplayResolutionComboBox.SetCursor(cursor)
self.massiveSshTunnelCipherComboBox.SetCursor(cursor)
self.massiveProjectComboBox.SetCursor(cursor)
self.massiveHoursField.SetCursor(cursor)
self.massiveUsernameTextField.SetCursor(cursor)
self.massivePasswordField.SetCursor(cursor)
self.cvlLoginHostComboBox.SetCursor(cursor)
self.cvlUsernameTextField.SetCursor(cursor)
self.cvlPasswordField.SetCursor(cursor)
self.cvlVncDisplayResolutionComboBox.SetCursor(cursor)
self.cvlSshTunnelCipherComboBox.SetCursor(cursor)
self.buttonsPanel.SetCursor(cursor)
self.optionsButton.SetCursor(cursor)
self.cancelButton.SetCursor(cursor)
self.loginButton.SetCursor(cursor)
super(LauncherMainFrame, self).SetCursor(cursor)
def onLogin(self, event):
class LoginThread(threading.Thread):
"""Login Thread Class."""
def __init__(self, notify_window):
"""Init Worker Thread Class."""
threading.Thread.__init__(self)
self._notify_window = notify_window
self.start()
def run(self):
"""Run Worker Thread."""
launcherMainFrame.SetCursor(wx.StockCursor(wx.CURSOR_WAIT))
logger.debug("AAA 1")
logger.debug('thread ident in run(): ' + str(threading.current_thread().ident))
wx.CallAfter(launcherMainFrame.loginDialogStatusBar.SetStatusText, "STATUS1")
def askCvlUserWhetherTheyWantToKeepOrDiscardTheirVncSession():
logger.debug('thread ident in askCvlUserWhetherTheyWantToKeepOrDiscardTheirVncSession(): ' + str(threading.current_thread().ident))
logger.debug('Made it to askCvlUserWhetherTheyWantToKeepOrDiscardTheirVncSession but leaving straight away')
launcherMainFrame.loginThread.askCvlUserWhetherTheyWantToKeepOrDiscardTheirVncSessionCompleted = True
return
logger.debug('AAA 5')
launcherMainFrame.loginThread.askCvlUserWhetherTheyWantToKeepOrDiscardTheirVncSessionCompleted = False
wx.CallAfter(askCvlUserWhetherTheyWantToKeepOrDiscardTheirVncSession)
logger.debug('AAA 6')
while launcherMainFrame.loginThread.askCvlUserWhetherTheyWantToKeepOrDiscardTheirVncSessionCompleted==False:
logger.debug('launcherMainFrame.loginThread.askCvlUserWhetherTheyWantToKeepOrDiscardTheirVncSessionCompleted == False, sleeping for one second...')
time.sleep(1)
logger.debug('AAA 7')
logger.debug('Setting the cursor back to CURSOR_ARROW.')
launcherMainFrame.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
os._exit(0)
MASSIVE_TAB_INDEX = 0
CVL_TAB_INDEX =1
global logger
global logger_fh
logger = logging.getLogger('launcher')
logger.setLevel(logging.DEBUG)
log_format_string = '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(message)s'
from os.path import expanduser, join
logger_fh = logging.FileHandler(join(expanduser("~"), 'MASSIVE_Launcher_debug_log.txt'))
logger_fh.setLevel(logging.DEBUG)
logger_fh.setFormatter(logging.Formatter(log_format_string))
logger.addHandler(logger_fh)
logger.debug('thread ident in main GUI thread(): ' + str(threading.current_thread().ident))
self.loginThread = LoginThread(self)
class LauncherStatusBar(wx.StatusBar):
def __init__(self, parent):
wx.StatusBar.__init__(self, parent)
self.SetFieldsCount(2)
self.SetStatusWidths([-5, -2])
class MyApp(wx.App):
def OnInit(self):
global launcherMainFrame
launcherMainFrame = LauncherMainFrame(None, wx.ID_ANY, 'MASSIVE/CVL Launcher')
launcherMainFrame.Show(True)
return True
app = MyApp(False) # Don't automatically redirect sys.stdout and sys.stderr to a Window.
app.MainLoop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment