-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathlauncher.py
executable file
·1954 lines (1672 loc) · 113 KB
/
launcher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# MASSIVE/CVL Launcher - easy secure login for the MASSIVE Desktop and the CVL
#
# Copyright (c) 2012-2013, Monash e-Research Centre (Monash University, Australia)
# All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# In addition, redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# - Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# - Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# - Neither the name of the Monash University nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SEE THE
# GNU GENERAL PUBLIC LICENSE FOR MORE DETAILS.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Enquiries: [email protected]
# launcher.py
"""
A wxPython GUI to provide easy login to the MASSIVE Desktop.
It can be run using "python launcher.py", assuming that you
have an appropriate (32-bit or 64-bit) version of Python
installed (*), wxPython, and the dependent Python modules
listed in the DEPENDENCIES file.
(*) wxPython 2.8.x on Mac OS X doesn't support 64-bit mode.
The py2app module is required to build the "MASSIVE Launcher.app"
application bundle on Mac OS X, which can be built as follows:
python create_mac_bundle.py py2app
To build a DMG containing the app bundle and a symbolic link to
Applications, you can run:
python package_mac_version.py <version_number>
See: https://confluence-vre.its.monash.edu.au/display/CVL/MASSIVE+Launcher+Mac+OS+X+build+instructions
The PyInstaller module, bundled with the Launcher code is used
to build the Windows and Linux executables. The Windows setup wizard
(created with InnoSetup) can be built using:
package_windows_version.bat C:\path\to\code\signing\certificate.pfx <certificate_password>
assuming that you have InnoSetup installed and that you have signtool.exe installed for
code signing.
See: https://confluence-vre.its.monash.edu.au/display/CVL/MASSIVE+Launcher+Windows+build+instructions
If you want to build a stand-alone Launcher binary for Mac or Windows
without using a code-signing certificate, you can do so by commenting
out the code-signing functionality in package_mac_version.py and in
package_windows_version.bat. In other words, sorry, this is not
possible at present without modifying the packaging scripts.
A self-contained Linux binary distribution can be built using
PyInstaller, as described on the following wiki page.
See: https://confluence-vre.its.monash.edu.au/display/CVL/MASSIVE+Launcher+Linux+build+instructions
"""
# Make sure that the Launcher doesn't attempt to write to
# "MASSIVE Launcher.exe.log", because it might not have
# permission to do so.
import sys
if sys.platform.startswith("win"):
sys.stderr = sys.stdout
if sys.platform.startswith("win"):
import _winreg
import subprocess
import wx
import time
import traceback
import threading
import os
import HTMLParser
import urllib2
import launcher_version_number
import xmlrpclib
import appdirs
import ConfigParser
import datetime
import shlex
import inspect
import requests
import ssh
from StringIO import StringIO
import logging
import LoginTasks
from utilityFunctions import *
import cvlsshutils.sshKeyDist
import cvlsshutils
import launcher_progress_dialog
from menus.IdentityMenu import IdentityMenu
import tempfile
from cvlsshutils.KeyModel import KeyModel
from logger.Logger import logger
from utilityFunctions import LAUNCHER_URL
launcherMainFrame = None
massiveLauncherConfig = None
cvlLauncherConfig = None
globalLauncherConfig = None
massiveLauncherPreferencesFilePath = None
cvlLauncherPreferencesFilePath = None
globalLauncherPreferencesFilePath = None
class LauncherMainFrame(wx.Frame):
PERM_SSH_KEY=0
TEMP_SSH_KEY=1
def __init__(self, parent, id, title):
sys.modules[__name__].launcherMainFrame = self
launcherMainFrame = sys.modules[__name__].launcherMainFrame
massiveLauncherConfig = sys.modules[__name__].massiveLauncherConfig
massiveLauncherPreferencesFilePath = sys.modules[__name__].massiveLauncherPreferencesFilePath
cvlLauncherConfig = sys.modules[__name__].cvlLauncherConfig
cvlLauncherPreferencesFilePath = sys.modules[__name__].cvlLauncherPreferencesFilePath
globalLauncherConfig = sys.modules[__name__].globalLauncherConfig
globalLauncherPreferencesFilePath = sys.modules[__name__].globalLauncherPreferencesFilePath
self.logWindow = None
self.progressDialog = None
if sys.platform.startswith("darwin"):
wx.Frame.__init__(self, parent, id, title, style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER)
else:
wx.Frame.__init__(self, parent, id, title, style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER)
self.globalOptions = {}
if globalLauncherConfig.has_section("Global Preferences"):
savedGlobalLauncherOptions = globalLauncherConfig.items("Global Preferences")
for option in savedGlobalLauncherOptions:
key = option[0]
value = option[1]
if value=='True':
value = True
if value=='False':
value = False
self.globalOptions[key] = value
import optionsDialog
self.globalOptionsDialog = optionsDialog.GlobalOptionsDialog(launcherMainFrame, wx.ID_ANY, "Preferences", self.globalOptions, 0)
if sys.platform.startswith("win"):
_icon = wx.Icon('MASSIVE.ico', wx.BITMAP_TYPE_ICO)
self.SetIcon(_icon)
if sys.platform.startswith("linux"):
import MASSIVE_icon
self.SetIcon(MASSIVE_icon.getMASSIVElogoTransparent128x128Icon())
self.menu_bar = wx.MenuBar()
self.Bind(wx.EVT_CLOSE, self.onExit, id=self.GetId())
# Do this for all platforms, even Mac OS X.
# Even though we don't have a File menu with
# an Exit menu item on Mac OS X, the wx.ID_EXIT
# ID automatically gets mapped to the Quit menu
# item (command q) in the "MASSIVE Launcher" menu.
self.Bind(wx.EVT_MENU, self.onExit, id=wx.ID_EXIT)
if sys.platform.startswith("win") or sys.platform.startswith("linux"):
self.file_menu = wx.Menu()
self.file_menu.Append(wx.ID_EXIT, "E&xit", "Close window and exit program.")
self.menu_bar.Append(self.file_menu, "&File")
#if sys.platform.startswith("darwin"):
## Only do this for Mac OS X, because other platforms have
## a right-click pop-up menu for wx.TextCtrl with Copy,
## Select All etc. Plus, the menu doesn't look that good on
## the MASSIVE Launcher main dialog, and doesn't work for
## non Mac platforms, because FindFocus() will always
## find the window/dialog which contains the menu.
#self.edit_menu = wx.Menu()
#self.edit_menu.Append(wx.ID_CUT, "Cut", "Cut the selected text")
#self.Bind(wx.EVT_MENU, self.onCut, id=wx.ID_CUT)
#self.edit_menu.Append(wx.ID_COPY, "Copy", "Copy the selected text")
#self.Bind(wx.EVT_MENU, self.onCopy, id=wx.ID_COPY)
#self.edit_menu.Append(wx.ID_PASTE, "Paste", "Paste text from the clipboard")
#self.Bind(wx.EVT_MENU, self.onPaste, id=wx.ID_PASTE)
#self.edit_menu.Append(wx.ID_SELECTALL, "Select All")
#self.Bind(wx.EVT_MENU, self.onSelectAll, id=wx.ID_SELECTALL)
#self.menu_bar.Append(self.edit_menu, "&Edit")
self.edit_menu = wx.Menu()
self.edit_menu.Append(wx.ID_CUT, "Cu&t", "Cut the selected text")
self.Bind(wx.EVT_MENU, self.onCut, id=wx.ID_CUT)
self.edit_menu.Append(wx.ID_COPY, "&Copy", "Copy the selected text")
self.Bind(wx.EVT_MENU, self.onCopy, id=wx.ID_COPY)
self.edit_menu.Append(wx.ID_PASTE, "&Paste", "Paste text from the clipboard")
self.Bind(wx.EVT_MENU, self.onPaste, id=wx.ID_PASTE)
self.edit_menu.Append(wx.ID_SELECTALL, "Select &All")
self.Bind(wx.EVT_MENU, self.onSelectAll, id=wx.ID_SELECTALL)
self.edit_menu.AppendSeparator()
if sys.platform.startswith("win") or sys.platform.startswith("linux"):
self.edit_menu.Append(wx.ID_PREFERENCES, "P&references\tCtrl-P")
else:
self.edit_menu.Append(wx.ID_PREFERENCES, "&Preferences")
self.Bind(wx.EVT_MENU, self.onOptions, id=wx.ID_PREFERENCES)
self.menu_bar.Append(self.edit_menu, "&Edit")
self.identity_menu = IdentityMenu()
self.identity_menu.initialize(self, globalLauncherConfig, globalLauncherPreferencesFilePath)
self.menu_bar.Append(self.identity_menu, "&Identity")
self.help_menu = wx.Menu()
helpContentsMenuItemID = wx.NewId()
self.help_menu.Append(helpContentsMenuItemID, "&MASSIVE/CVL Launcher Help")
self.Bind(wx.EVT_MENU, self.onHelpContents, id=helpContentsMenuItemID)
self.help_menu.AppendSeparator()
emailHelpAtMassiveMenuItemID = wx.NewId()
self.help_menu.Append(emailHelpAtMassiveMenuItemID, "Email &[email protected]")
self.Bind(wx.EVT_MENU, self.onEmailHelpAtMassive, id=emailHelpAtMassiveMenuItemID)
emailCvlHelpAtMonashMenuItemID = wx.NewId()
self.help_menu.Append(emailCvlHelpAtMonashMenuItemID, "Email &[email protected]")
self.Bind(wx.EVT_MENU, self.onEmailCvlHelpAtMonash, id=emailCvlHelpAtMonashMenuItemID)
submitDebugLogMenuItemID = wx.NewId()
self.help_menu.Append(submitDebugLogMenuItemID, "&Submit debug log")
self.Bind(wx.EVT_MENU, self.onSubmitDebugLog, id=submitDebugLogMenuItemID)
# On Mac, the About menu item will automatically be moved from
# the Help menu to the "MASSIVE Launcher" menu, so we don't
# need a separator.
if not sys.platform.startswith("darwin"):
self.help_menu.AppendSeparator()
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))
self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.onTabbedViewChanged, id=self.tabbedView.GetId())
# 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_READONLY)
self.massiveLoginHostComboBox.Bind(wx.EVT_TEXT, self.onMassiveLoginHostNameChanged)
self.massiveLoginFieldsPanelSizer.Add(self.massiveLoginHostComboBox, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
if massiveLauncherConfig.has_section("MASSIVE Launcher Preferences"):
if massiveLauncherConfig.has_option("MASSIVE Launcher Preferences", "massive_login_host"):
self.massiveLoginHost = massiveLauncherConfig.get("MASSIVE Launcher Preferences", "massive_login_host")
else:
massiveLauncherConfig.set("MASSIVE Launcher Preferences", "massive_login_host","")
with open(massiveLauncherPreferencesFilePath, 'wb') as massiveLauncherPreferencesFileObject:
massiveLauncherConfig.write(massiveLauncherPreferencesFileObject)
else:
massiveLauncherConfig.add_section("MASSIVE Launcher Preferences")
with open(massiveLauncherPreferencesFilePath, 'wb') as massiveLauncherPreferencesFileObject:
massiveLauncherConfig.write(massiveLauncherPreferencesFileObject)
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',
'ASync008',
'ASync009',
'ASync010',
'ASync011',
'ASync012',
'ASync013',
'ASync_IMBL',
'CSIRO001',
'CSIRO002',
'CSIRO003',
'CSIRO004',
'CSIRO005',
'CSIRO006',
'CSIRO007',
'Desc001',
'Desc002',
'Desc003',
'Desc004',
'Desc005',
'Desc006',
'Desc007',
'Monash001',
'Monash002',
'Monash003',
'Monash004',
'Monash005',
'Monash006',
'Monash007',
'Monash008',
'Monash009',
'Monash010',
'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',
'Monash037',
'Monash038',
'Monash039',
'Monash040',
'Monash041',
'Monash042',
'Monash043',
'Monash044',
'Monash045',
'NCId75',
'NCIdb5',
'NCIdc0',
'NCIdd2',
'NCIdv0',
'NCIdw3',
'NCIdy4',
'NCIdy7',
'NCIdz3',
'NCIea0',
'NCIg61',
'NCIg75',
'NCIh77',
'NCIq97',
'NCIr14',
'NCIv43',
'NCIw25',
'NCIw27',
'NCIw67',
'NCIw81',
'NCIw91',
'NCIy40',
'NCIy95',
'NCIy96',
'pDeak0023',
'pDeak0026',
'pLaTr0011',
'pMelb0095',
'pMelb0100',
'pMelb0103',
'pMelb0104',
'pMelb0106',
'pMelb0107',
'pMOSP',
'pRMIT0074',
'pRMIT0078',
'pRMIT0083',
'pVPAC0008',
'Training',]
self.massiveProjectComboBox = wx.ComboBox(self.massiveLoginFieldsPanel, wx.ID_ANY, value='', choices=self.massiveProjects, size=(widgetWidth2, -1), style=wx.CB_DROPDOWN)
self.massiveProjectComboBox.Bind(wx.EVT_TEXT, self.onMassiveProjectTextChanged)
self.massiveLoginFieldsPanelSizer.Add(self.massiveProjectComboBox, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
self.massiveProject = ""
if massiveLauncherConfig.has_section("MASSIVE Launcher Preferences"):
if massiveLauncherConfig.has_option("MASSIVE Launcher Preferences", "massive_project"):
self.massiveProject = massiveLauncherConfig.get("MASSIVE Launcher Preferences", "massive_project")
elif massiveLauncherConfig.has_option("MASSIVE Launcher Preferences", "project"):
self.massiveProject = massiveLauncherConfig.get("MASSIVE Launcher Preferences", "project")
else:
massiveLauncherConfig.set("MASSIVE Launcher Preferences", "massive_project","")
with open(massiveLauncherPreferencesFilePath, 'wb') as massiveLauncherPreferencesFileObject:
massiveLauncherConfig.write(massiveLauncherPreferencesFileObject)
else:
massiveLauncherConfig.add_section("MASSIVE Launcher Preferences")
with open(massiveLauncherPreferencesFilePath, 'wb') as massiveLauncherPreferencesFileObject:
massiveLauncherConfig.write(massiveLauncherPreferencesFileObject)
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"
if massiveLauncherConfig.has_section("MASSIVE Launcher Preferences"):
if massiveLauncherConfig.has_option("MASSIVE Launcher Preferences", "massive_hours_requested"):
self.massiveHoursRequested = massiveLauncherConfig.get("MASSIVE Launcher Preferences", "massive_hours_requested")
if self.massiveHoursRequested.strip() == "":
self.massiveHoursRequested = "4"
elif massiveLauncherConfig.has_option("MASSIVE Launcher Preferences", "hours"):
self.massiveHoursRequested = massiveLauncherConfig.get("MASSIVE Launcher Preferences", "hours")
if self.massiveHoursRequested.strip() == "":
self.massiveHoursRequested = "4"
else:
massiveLauncherConfig.set("MASSIVE Launcher Preferences", "massive_hours_requested","")
with open(massiveLauncherPreferencesFilePath, 'wb') as massiveLauncherPreferencesFileObject:
massiveLauncherConfig.write(massiveLauncherPreferencesFileObject)
else:
massiveLauncherConfig.add_section("MASSIVE Launcher Preferences")
with open(massiveLauncherPreferencesFilePath, 'wb') as massiveLauncherPreferencesFileObject:
massiveLauncherConfig.write(massiveLauncherPreferencesFileObject)
# 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.massiveHoursField.Bind(wx.EVT_TEXT, self.onTextEnteredInIntegerField)
# Spin controls are tricky to configure event-handling for,
# because they contain both a TextCtrl object and a
# spinner button, but they don't provide a direct interface
# for accessing their TextCtrl object. So we will
# determine the TextCtrl object of each SpinCtrl the
# first time it is focused, and then bind wx.EVT_KILL_FOCUS
# to it, so we can ensure that the field has been
# filled in.
self.Bind(wx.EVT_CHILD_FOCUS, self.onChildFocus)
#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"
if massiveLauncherConfig.has_section("MASSIVE Launcher Preferences"):
if massiveLauncherConfig.has_option("MASSIVE Launcher Preferences", "massive_visnodes_requested"):
self.massiveVisNodesRequested = massiveLauncherConfig.get("MASSIVE Launcher Preferences", "massive_visnodes_requested")
if self.massiveVisNodesRequested.strip() == "":
self.massiveVisNodesRequested = "1"
elif massiveLauncherConfig.has_option("MASSIVE Launcher Preferences", "visnodes"):
self.massiveVisNodesRequested = massiveLauncherConfig.get("MASSIVE Launcher Preferences", "visnodes")
if self.massiveVisNodesRequested.strip() == "":
self.massiveVisNodesRequested = "1"
else:
massiveLauncherConfig.set("MASSIVE Launcher Preferences", "massive_visnodes_requested","")
with open(massiveLauncherPreferencesFilePath, 'wb') as massiveLauncherPreferencesFileObject:
massiveLauncherConfig.write(massiveLauncherPreferencesFileObject)
else:
massiveLauncherConfig.add_section("MASSIVE Launcher Preferences")
with open(massiveLauncherPreferencesFilePath, 'wb') as massiveLauncherPreferencesFileObject:
massiveLauncherConfig.write(massiveLauncherPreferencesFileObject)
self.massiveVisNodesField = wx.SpinCtrl(self.massiveHoursAndVisNodesPanel, wx.ID_ANY, value=self.massiveVisNodesRequested, size=(widgetWidth3,-1), min=1,max=10)
self.massiveVisNodesField.Bind(wx.EVT_TEXT, self.onTextEnteredInIntegerField)
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 massiveLauncherConfig.has_section("MASSIVE Launcher Preferences"):
with open(massiveLauncherPreferencesFilePath, 'wb') as massiveLauncherPreferencesFileObject:
massiveLauncherConfig.write(massiveLauncherPreferencesFileObject)
else:
massiveLauncherConfig.add_section("MASSIVE Launcher Preferences")
with open(massiveLauncherPreferencesFilePath, 'wb') as massiveLauncherPreferencesFileObject:
massiveLauncherConfig.write(massiveLauncherPreferencesFileObject)
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)
if massiveLauncherConfig.has_section("MASSIVE Launcher Preferences"):
if massiveLauncherConfig.has_option("MASSIVE Launcher Preferences", "massive_vnc_display_resolution"):
self.massiveVncDisplayResolution = massiveLauncherConfig.get("MASSIVE Launcher Preferences", "massive_vnc_display_resolution")
elif massiveLauncherConfig.has_option("MASSIVE Launcher Preferences", "resolution"):
self.massiveVncDisplayResolution = massiveLauncherConfig.get("MASSIVE Launcher Preferences", "resolution")
else:
massiveLauncherConfig.set("MASSIVE Launcher Preferences", "massive_vnc_display_resolution","")
with open(massiveLauncherPreferencesFilePath, 'wb') as massiveLauncherPreferencesFileObject:
massiveLauncherConfig.write(massiveLauncherPreferencesFileObject)
else:
massiveLauncherConfig.add_section("MASSIVE Launcher Preferences")
with open(massiveLauncherPreferencesFilePath, 'wb') as massiveLauncherPreferencesFileObject:
massiveLauncherConfig.write(massiveLauncherPreferencesFileObject)
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)
if massiveLauncherConfig.has_section("MASSIVE Launcher Preferences"):
if massiveLauncherConfig.has_option("MASSIVE Launcher Preferences", "massive_ssh_tunnel_cipher"):
self.massiveSshTunnelCipher = massiveLauncherConfig.get("MASSIVE Launcher Preferences", "massive_ssh_tunnel_cipher")
if massiveLauncherConfig.has_option("MASSIVE Launcher Preferences", "cipher"):
self.massiveSshTunnelCipher = massiveLauncherConfig.get("MASSIVE Launcher Preferences", "cipher")
else:
massiveLauncherConfig.set("MASSIVE Launcher Preferences", "massive_ssh_tunnel_cipher","")
with open(massiveLauncherPreferencesFilePath, 'wb') as massiveLauncherPreferencesFileObject:
massiveLauncherConfig.write(massiveLauncherPreferencesFileObject)
else:
massiveLauncherConfig.add_section("MASSIVE Launcher Preferences")
with open(massiveLauncherPreferencesFilePath, 'wb') as massiveLauncherPreferencesFileObject:
massiveLauncherConfig.write(massiveLauncherPreferencesFileObject)
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 = ""
if massiveLauncherConfig.has_section("MASSIVE Launcher Preferences"):
if massiveLauncherConfig.has_option("MASSIVE Launcher Preferences", "massive_username"):
self.massiveUsername = massiveLauncherConfig.get("MASSIVE Launcher Preferences", "massive_username")
elif massiveLauncherConfig.has_option("MASSIVE Launcher Preferences", "username"):
self.massiveUsername = massiveLauncherConfig.get("MASSIVE Launcher Preferences", "username")
else:
massiveLauncherConfig.set("MASSIVE Launcher Preferences", "massive_username","")
with open(massiveLauncherPreferencesFilePath, 'wb') as massiveLauncherPreferencesFileObject:
massiveLauncherConfig.write(massiveLauncherPreferencesFileObject)
else:
massiveLauncherConfig.add_section("MASSIVE Launcher Preferences")
with open(massiveLauncherPreferencesFilePath, 'wb') as massiveLauncherPreferencesFileObject:
massiveLauncherConfig.write(massiveLauncherPreferencesFileObject)
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.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.massiveShowDebugWindowLabel = wx.StaticText(self.massiveLoginFieldsPanel, wx.ID_ANY, 'Show debug window')
self.massiveLoginFieldsPanelSizer.Add(self.massiveShowDebugWindowLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
self.massiveDebugAndAutoExitPanel = wx.Panel(self.massiveLoginFieldsPanel, wx.ID_ANY)
self.massiveDebugAndAutoExitPanelSizer = wx.FlexGridSizer(rows=1, cols=3, vgap=3, hgap=5)
self.massiveDebugAndAutoExitPanel.SetSizer(self.massiveDebugAndAutoExitPanelSizer)
self.massiveShowDebugWindowCheckBox = wx.CheckBox(self.massiveDebugAndAutoExitPanel, wx.ID_ANY, "")
self.massiveShowDebugWindowCheckBox.SetValue(False)
self.massiveShowDebugWindowCheckBox.Bind(wx.EVT_CHECKBOX, self.onDebugWindowCheckBoxStateChanged)
self.massiveDebugAndAutoExitPanelSizer.Add(self.massiveShowDebugWindowCheckBox, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
self.massiveAutomaticallyExitLabel = wx.StaticText(self.massiveDebugAndAutoExitPanel, wx.ID_ANY, " Automatically exit")
self.massiveDebugAndAutoExitPanelSizer.Add(self.massiveAutomaticallyExitLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, border=5)
self.massiveAutomaticallyExit = True
if massiveLauncherConfig.has_section("MASSIVE Launcher Preferences"):
if massiveLauncherConfig.has_option("MASSIVE Launcher Preferences", "massive_automatically_exit"):
self.massiveAutomaticallyExit = massiveLauncherConfig.get("MASSIVE Launcher Preferences", "massive_automatically_exit")
if self.massiveAutomaticallyExit.strip() == "":
self.massiveAutomaticallyExit = True
else:
if self.massiveAutomaticallyExit==True or self.massiveAutomaticallyExit=='True':
self.massiveAutomaticallyExit = True
else:
self.massiveAutomaticallyExit = False
else:
massiveLauncherConfig.set("MASSIVE Launcher Preferences", "massive_automatically_exit","False")
with open(massiveLauncherPreferencesFilePath, 'wb') as massiveLauncherPreferencesFileObject:
massiveLauncherConfig.write(massiveLauncherPreferencesFileObject)
else:
massiveLauncherConfig.add_section("MASSIVE Launcher Preferences")
with open(massiveLauncherPreferencesFilePath, 'wb') as massiveLauncherPreferencesFileObject:
massiveLauncherConfig.write(massiveLauncherPreferencesFileObject)
self.massiveAutomaticallyExitCheckBox = wx.CheckBox(self.massiveDebugAndAutoExitPanel, wx.ID_ANY, "")
self.massiveAutomaticallyExitCheckBox.SetValue(self.massiveAutomaticallyExit)
self.massiveDebugAndAutoExitPanelSizer.Add(self.massiveAutomaticallyExitCheckBox, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, border=5)
self.massiveDebugAndAutoExitPanel.Fit()
self.massiveLoginFieldsPanelSizer.Add(self.massiveDebugAndAutoExitPanel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
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
# Overall CVL login panel:
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)
# Simple login fields: connection profile, username, advanced settings checkbox
self.cvlSimpleLoginFieldsPanel = wx.Panel(self.cvlLoginDialogPanel, wx.ID_ANY)
self.cvlSimpleLoginFieldsPanelSizer = wx.FlexGridSizer(rows=5, cols=2, vgap=3, hgap=5)
self.cvlSimpleLoginFieldsPanel.SetSizer(self.cvlSimpleLoginFieldsPanelSizer)
self.cvlConnectionProfileLabel = wx.StaticText(self.cvlSimpleLoginFieldsPanel, wx.ID_ANY, 'Connection')
self.cvlSimpleLoginFieldsPanelSizer.Add(self.cvlConnectionProfileLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
self.cvlConnectionProfile = ""
cvlConnectionProfiles = ["login.cvl.massive.org.au","Huygens on the CVL","Other..."]
defaultCvlConnectionProfile = "login.cvl.massive.org.au"
self.cvlConnectionProfileComboBox = wx.ComboBox(self.cvlSimpleLoginFieldsPanel, wx.ID_ANY, value=defaultCvlConnectionProfile, choices=cvlConnectionProfiles, size=(widgetWidth2, -1), style=wx.CB_READONLY)
self.Bind(wx.EVT_COMBOBOX, self.onCvlConnectionProfileChanged, self.cvlConnectionProfileComboBox)
self.cvlSimpleLoginFieldsPanelSizer.Add(self.cvlConnectionProfileComboBox, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
if cvlLauncherConfig.has_section("CVL Launcher Preferences"):
if cvlLauncherConfig.has_option("CVL Launcher Preferences", "cvl_connection_profile"):
self.cvlConnectionProfile = cvlLauncherConfig.get("CVL Launcher Preferences", "cvl_connection_profile")
# If the user has a setting for cvl_connection_profile that is not in our approved list, just take
# the first known CVL connection profile.
if self.cvlConnectionProfile not in cvlConnectionProfiles:
self.cvlConnectionProfile = cvlConnectionProfiles[0]
cvlLauncherConfig.set("CVL Launcher Preferences", "cvl_connection_profile", self.cvlConnectionProfile)
with open(cvlLauncherPreferencesFilePath, 'wb') as cvlLauncherPreferencesFileObject:
cvlLauncherConfig.write(cvlLauncherPreferencesFileObject)
else:
cvlLauncherConfig.set("CVL Launcher Preferences", "cvl_connection_profile","")
with open(cvlLauncherPreferencesFilePath, 'wb') as cvlLauncherPreferencesFileObject:
cvlLauncherConfig.write(cvlLauncherPreferencesFileObject)
else:
cvlLauncherConfig.add_section("CVL Launcher Preferences")
with open(cvlLauncherPreferencesFilePath, 'wb') as cvlLauncherPreferencesFileObject:
cvlLauncherConfig.write(cvlLauncherPreferencesFileObject)
self.cvlConnectionProfile = self.cvlConnectionProfile.strip()
if self.cvlConnectionProfile!="":
if self.cvlConnectionProfile in cvlConnectionProfiles:
self.cvlConnectionProfileComboBox.SetSelection(cvlConnectionProfiles.index(self.cvlConnectionProfile))
else:
# Connection profile was not found in combo-box.
self.cvlConnectionProfileComboBox.SetSelection(0)
self.cvlLoginHostLabel = wx.StaticText(self.cvlSimpleLoginFieldsPanel, wx.ID_ANY, 'Host')
self.cvlSimpleLoginFieldsPanelSizer.Add(self.cvlLoginHostLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
self.cvlLoginHost = ""
if cvlLauncherConfig.has_section("CVL Launcher Preferences"):
if cvlLauncherConfig.has_option("CVL Launcher Preferences", "cvl_login_host"):
self.cvlLoginHost = cvlLauncherConfig.get("CVL Launcher Preferences", "cvl_login_host")
else:
cvlLauncherConfig.set("CVL Launcher Preferences", "cvl_login_host","")
with open(cvlLauncherPreferencesFilePath, 'wb') as cvlLauncherPreferencesFileObject:
cvlLauncherConfig.write(cvlLauncherPreferencesFileObject)
else:
cvlLauncherConfig.add_section("CVL Launcher Preferences")
with open(cvlLauncherPreferencesFilePath, 'wb') as cvlLauncherPreferencesFileObject:
cvlLauncherConfig.write(cvlLauncherPreferencesFileObject)
self.cvlLoginHost = self.cvlLoginHost.strip()
self.cvlLoginHostTextFieldPanel = wx.Panel(self.cvlSimpleLoginFieldsPanel, wx.ID_ANY, size=wx.Size(widgetWidth1, -1))
self.cvlLoginHostTextFieldPanelSizer = wx.FlexGridSizer(rows=1, cols=1)
self.cvlLoginHostTextField = wx.TextCtrl(self.cvlLoginHostTextFieldPanel, wx.ID_ANY, self.cvlLoginHost, size=wx.Size(widgetWidth1, -1))
self.cvlLoginHostTextFieldPanelSizer.Add(self.cvlLoginHostTextField, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
self.cvlLoginHostTextFieldPanel.SetSizerAndFit(self.cvlLoginHostTextFieldPanelSizer)
self.cvlSimpleLoginFieldsPanelSizer.Add(self.cvlLoginHostTextFieldPanel, flag=wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=3)
if self.cvlConnectionProfileComboBox.GetValue()!="Other...":
self.cvlSimpleLoginFieldsPanelSizer.Show(self.cvlLoginHostTextFieldPanel,False)
self.cvlUsernameLabel = wx.StaticText(self.cvlSimpleLoginFieldsPanel, wx.ID_ANY, 'Username')
self.cvlSimpleLoginFieldsPanelSizer.Add(self.cvlUsernameLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
self.cvlUsername = ""
if cvlLauncherConfig.has_section("CVL Launcher Preferences"):
if cvlLauncherConfig.has_option("CVL Launcher Preferences", "cvl_username"):
self.cvlUsername = cvlLauncherConfig.get("CVL Launcher Preferences", "cvl_username")
else:
cvlLauncherConfig.set("CVL Launcher Preferences", "cvl_username","")
with open(cvlLauncherPreferencesFilePath, 'wb') as cvlLauncherPreferencesFileObject:
cvlLauncherConfig.write(cvlLauncherPreferencesFileObject)
else:
cvlLauncherConfig.add_section("CVL Launcher Preferences")
with open(cvlLauncherPreferencesFilePath, 'wb') as cvlLauncherPreferencesFileObject:
cvlLauncherConfig.write(cvlLauncherPreferencesFileObject)
self.cvlUsernameTextField = wx.TextCtrl(self.cvlSimpleLoginFieldsPanel, wx.ID_ANY, self.cvlUsername, size=(widgetWidth1, -1))
self.cvlSimpleLoginFieldsPanelSizer.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.cvlShowAdvancedLoginLabel = wx.StaticText(self.cvlSimpleLoginFieldsPanel, wx.ID_ANY, 'Show advanced options')
self.cvlSimpleLoginFieldsPanelSizer.Add(self.cvlShowAdvancedLoginLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
self.cvlAdvancedLoginCheckBox = wx.CheckBox(self.cvlSimpleLoginFieldsPanel, wx.ID_ANY, "")
self.cvlAdvancedLoginCheckBox.SetMinSize(self.cvlAdvancedLoginCheckBox.GetSize())
self.cvlAdvancedLoginCheckBox.SetValue(False)
self.cvlAdvancedLoginCheckBox.Bind(wx.EVT_CHECKBOX, self.onCvlAdvancedLoginCheckBox)
self.cvlSimpleLoginFieldsPanelSizer.Add(self.cvlAdvancedLoginCheckBox, flag=wx.LEFT|wx.EXPAND, border=10)
self.cvlAdvancedLoginFieldsPanel = wx.Panel(self.cvlLoginDialogPanel, wx.ID_ANY)
self.cvlAdvancedLoginFieldsPanelSizer = wx.FlexGridSizer(rows=4, cols=2, vgap=3, hgap=5)
self.cvlAdvancedLoginFieldsPanel.SetSizer(self.cvlAdvancedLoginFieldsPanelSizer)
self.cvlVncDisplayResolutionLabel = wx.StaticText(self.cvlAdvancedLoginFieldsPanel, wx.ID_ANY, 'Resolution')
self.cvlAdvancedLoginFieldsPanelSizer.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.cvlAdvancedLoginFieldsPanel, wx.ID_ANY, value='', choices=cvlVncDisplayResolutions, size=(widgetWidth2, -1), style=wx.CB_DROPDOWN)
self.cvlAdvancedLoginFieldsPanelSizer.Add(self.cvlVncDisplayResolutionComboBox, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
if cvlLauncherConfig.has_section("CVL Launcher Preferences"):
if cvlLauncherConfig.has_option("CVL Launcher Preferences", "cvl_vnc_display_resolution"):
self.cvlVncDisplayResolution = cvlLauncherConfig.get("CVL Launcher Preferences", "cvl_vnc_display_resolution")
elif cvlLauncherConfig.has_option("CVL Launcher Preferences", "resolution"):
self.cvlVncDisplayResolution = cvlLauncherConfig.get("CVL Launcher Preferences", "resolution")
else:
cvlLauncherConfig.set("CVL Launcher Preferences", "cvl_vnc_display_resolution","")
with open(cvlLauncherPreferencesFilePath, 'wb') as cvlLauncherPreferencesFileObject:
cvlLauncherConfig.write(cvlLauncherPreferencesFileObject)
else:
cvlLauncherConfig.add_section("CVL Launcher Preferences")
with open(cvlLauncherPreferencesFilePath, 'wb') as cvlLauncherPreferencesFileObject:
cvlLauncherConfig.write(cvlLauncherPreferencesFileObject)
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)
self.cvlSshTunnelCipherLabel = wx.StaticText(self.cvlAdvancedLoginFieldsPanel, wx.ID_ANY, 'SSH tunnel cipher')
self.cvlAdvancedLoginFieldsPanelSizer.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.cvlAdvancedLoginFieldsPanel, wx.ID_ANY, value='', choices=cvlSshTunnelCiphers, size=(widgetWidth2, -1), style=wx.CB_DROPDOWN)
self.cvlAdvancedLoginFieldsPanelSizer.Add(self.cvlSshTunnelCipherComboBox, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
if cvlLauncherConfig.has_section("CVL Launcher Preferences"):
if cvlLauncherConfig.has_option("CVL Launcher Preferences", "cvl_ssh_tunnel_cipher"):
self.cvlSshTunnelCipher = cvlLauncherConfig.get("CVL Launcher Preferences", "cvl_ssh_tunnel_cipher")
if cvlLauncherConfig.has_option("CVL Launcher Preferences", "cipher"):
self.cvlSshTunnelCipher = cvlLauncherConfig.get("CVL Launcher Preferences", "cipher")
else:
cvlLauncherConfig.set("CVL Launcher Preferences", "cvl_ssh_tunnel_cipher","")
with open(cvlLauncherPreferencesFilePath, 'wb') as cvlLauncherPreferencesFileObject:
cvlLauncherConfig.write(cvlLauncherPreferencesFileObject)
else:
cvlLauncherConfig.add_section("CVL Launcher Preferences")
with open(cvlLauncherPreferencesFilePath, 'wb') as cvlLauncherPreferencesFileObject:
cvlLauncherConfig.write(cvlLauncherPreferencesFileObject)
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.cvlShowDebugWindowLabel = wx.StaticText(self.cvlAdvancedLoginFieldsPanel, wx.ID_ANY, 'Show debug window')
self.cvlAdvancedLoginFieldsPanelSizer.Add(self.cvlShowDebugWindowLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
self.cvlDebugAndAutoExitPanel = wx.Panel(self.cvlAdvancedLoginFieldsPanel, wx.ID_ANY)
self.cvlDebugAndAutoExitPanelSizer = wx.FlexGridSizer(rows=1, cols=3, vgap=3, hgap=5)
self.cvlDebugAndAutoExitPanel.SetSizer(self.cvlDebugAndAutoExitPanelSizer)
self.cvlShowDebugWindowCheckBox = wx.CheckBox(self.cvlDebugAndAutoExitPanel, wx.ID_ANY, "")
self.cvlShowDebugWindowCheckBox.SetValue(False)
self.cvlShowDebugWindowCheckBox.Bind(wx.EVT_CHECKBOX, self.onDebugWindowCheckBoxStateChanged)
self.cvlDebugAndAutoExitPanelSizer.Add(self.cvlShowDebugWindowCheckBox, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
self.cvlAutomaticallyExitLabel = wx.StaticText(self.cvlDebugAndAutoExitPanel, wx.ID_ANY, " Automatically exit")
self.cvlDebugAndAutoExitPanelSizer.Add(self.cvlAutomaticallyExitLabel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, border=5)
self.cvlAutomaticallyExit = False
if cvlLauncherConfig.has_section("CVL Launcher Preferences"):
if cvlLauncherConfig.has_option("CVL Launcher Preferences", "cvl_automatically_exit"):
self.cvlAutomaticallyExit = cvlLauncherConfig.get("CVL Launcher Preferences", "cvl_automatically_exit")
if self.cvlAutomaticallyExit.strip() == "":
self.cvlAutomaticallyExit = False
else:
if self.cvlAutomaticallyExit==True or self.cvlAutomaticallyExit=='True':
self.cvlAutomaticallyExit = True
else:
self.cvlAutomaticallyExit = False
else:
cvlLauncherConfig.set("CVL Launcher Preferences", "cvl_automatically_exit","False")
with open(cvlLauncherPreferencesFilePath, 'wb') as cvlLauncherPreferencesFileObject:
cvlLauncherConfig.write(cvlLauncherPreferencesFileObject)
else:
cvlLauncherConfig.add_section("CVL Launcher Preferences")
with open(cvlLauncherPreferencesFilePath, 'wb') as cvlLauncherPreferencesFileObject:
cvlLauncherConfig.write(cvlLauncherPreferencesFileObject)
self.cvlAutomaticallyExitCheckBox = wx.CheckBox(self.cvlDebugAndAutoExitPanel, wx.ID_ANY, "")
self.cvlAutomaticallyExitCheckBox.SetValue(self.cvlAutomaticallyExit)
self.cvlDebugAndAutoExitPanelSizer.Add(self.cvlAutomaticallyExitCheckBox, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, border=5)
self.cvlDebugAndAutoExitPanel.Fit()
self.cvlAdvancedLoginFieldsPanelSizer.Add(self.cvlDebugAndAutoExitPanel, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=5)
self.cvlSimpleLoginFieldsPanel.SetSizerAndFit(self.cvlSimpleLoginFieldsPanelSizer)
if self.cvlConnectionProfileComboBox.GetValue()!="Other...":
self.cvlSimpleLoginFieldsPanelSizer.Show(self.cvlLoginHostLabel,False)
self.cvlSimpleLoginFieldsPanelSizer.Layout()
self.cvlAdvancedLoginFieldsPanel.SetSizerAndFit(self.cvlAdvancedLoginFieldsPanelSizer)
self.cvlAdvancedLoginFieldsPanel.Show(False)
self.cvlLoginDialogPanelSizer.Add(self.cvlSimpleLoginFieldsPanel, flag=wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, border=15)
self.cvlLoginDialogPanelSizer.Add(self.cvlAdvancedLoginFieldsPanel, 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)
lastUsedTabIndexAsString = "0"
if globalLauncherConfig.has_section("Global Preferences"):
if globalLauncherConfig.has_option("Global Preferences", "last_used_tab_index"):
lastUsedTabIndexAsString = globalLauncherConfig.get("Global Preferences", "last_used_tab_index")
if lastUsedTabIndexAsString.strip() == "":
lastUsedTabIndexAsString = "0"
lastUsedTabIndex = int(lastUsedTabIndexAsString)
MASSIVE_TAB_INDEX = 0
CVL_TAB_INDEX = 1
self.tabbedView.ChangeSelection(lastUsedTabIndex)
self.massiveTabSelected = (lastUsedTabIndex==MASSIVE_TAB_INDEX)
self.cvlTabSelected = (lastUsedTabIndex==CVL_TAB_INDEX)
# 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)
self.preferencesButton = wx.Button(self.buttonsPanel, wx.ID_ANY, 'Preferences')
self.buttonsPanelSizer.Add(self.preferencesButton, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT, border=10)
self.Bind(wx.EVT_BUTTON, self.onOptions, id=self.preferencesButton.GetId())
self.exitButton = wx.Button(self.buttonsPanel, wx.ID_ANY, 'Exit')
self.buttonsPanelSizer.Add(self.exitButton, flag=wx.TOP|wx.BOTTOM|wx.LEFT|wx.RIGHT, border=10)
self.Bind(wx.EVT_BUTTON, self.onExit, id=self.exitButton.GetId())
self.loginButton = wx.Button(self.buttonsPanel, wx.ID_ANY, '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=self.loginButton.GetId())
self.buttonsPanel.SetSizerAndFit(self.buttonsPanelSizer)
self.preferencesButton.Show(False)
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)