-
Notifications
You must be signed in to change notification settings - Fork 0
/
CG_MAIN.py
2414 lines (1722 loc) · 105 KB
/
CG_MAIN.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
import logging # used for the loggin window in PyQt
import os
import shutil
import subprocess
import sys
from PyQt5.Qt import QDesktopServices, QUrl
from PyQt5.QtCore import (QSettings, QSize, Qt, QThreadPool, QTimer)
from PyQt5.QtGui import QColor, QFont, QIcon, QPalette, QPixmap
from PyQt5.QtWidgets import (QApplication, QCheckBox, QComboBox,
QFileDialog, QFormLayout, QFrame,
QGridLayout, QGroupBox, QHBoxLayout, QHeaderView,
QLabel, QLineEdit, QMainWindow,
QProgressBar, QPushButton, QRadioButton,
QSplashScreen, QStatusBar,
QTableWidget, QTableWidgetItem, QTabWidget,
QTextEdit, QVBoxLayout, QWidget)
logging.basicConfig(level=logging.INFO)
# logging.basicConfig(level=logging.DEBUG)
import platform
import tempfile
#PROJECT MODULES IMPORT
import CG_License
import CG_Nightlies
import CG_Uninstall
import CG_Utilities
import CG_ZIP_Installer
if platform.system() == 'Windows':
import CG_Registry
#HANDLE COMMAND LINE ARGUMENTS:
try:
killApp = False
args = sys.argv
args.pop(0)
print('Argument List:', str(args))
# logging.info(args)
for item in args:
print(item)
if '-install=' in item or item.endswith('.exe'):
if '-install=' in item:
build_full_path = item[len('-install='):]
else:
build_full_path = item
index = build_full_path.rfind('\\') + 1
build_name = build_full_path[index:]
build_path = build_full_path[:index]
print('Build Name = {}'.format(build_name))
print('Build Path = {}'.format(build_path))
data = CG_ZIP_Installer.instance.getZipVersionsFromString(input_string=build_name)
CG_Utilities.instance.install(download_path=build_path,
build_file= build_name,
productName=data['productName'],
productVersion= data['productVersion'],
platformName=data['platformName'],
platformVersion=data['platformVersion'])
killApp = True
except:
pass
if killApp == True:
exit()
#RESOURCES:
#MULTITHREADING/DOWNLAOD FREEZE ISSUE: https://www.learnpyqt.com/courses/concurrent-execution/multithreading-pyqt-applications-qthreadpool/
#MULTITHREADING TUTORIAL TO RESOLVE FREEZES: https://www.learnpyqt.com/courses/concurrent-execution/multithreading-pyqt-applications-qthreadpool/
class ChaosGroup(QMainWindow): #THIS IS THE MAIN WINDOW, THE ONE THAT EVERYTHING IS BUILD ON
download_path = os.path.realpath(tempfile.gettempdir()) + "/Chaos-Installer/"
mounted_volumes = []
# SETTINGS
#Computer\HKEY_USERS\S-1-5-21-2633894342-2101855249-4104172794-1001\Software\svetlozar.draganov\Chaos Group Installer
#(MACOS) /Users/support/Library/Preferences/com.svetlozar-draganov.Chaos-Installer
settings_global = QSettings('svetlozar.draganov', 'Chaos-Installer')
def __init__(self):
super().__init__()
#MENUBAR
self.bar = self.menuBar()
# self.file = self.bar.addMenu("File")
# self.file.addAction("Sample Menu 1")
#MAIN WINDOW PROPERTIES
self.setMinimumSize(QSize(650,425))
self.setWindowTitle("Chaos Installer")
self.setWindowIcon(QIcon('images/logo.png'))
#HIDE TITLEBAR
#https://www.geeksforgeeks.org/pyqt5-how-to-hide-the-title-bar-of-window/
# self.setWindowFlag(Qt.FramelessWindowHint)
#STATUSBAR
self.statusBar = StatusBar()
self.setStatusBar(self.statusBar)
# LOAD WINDOW SETTINGS
try:
self.resize(ChaosGroup.settings_global.value('window size'))
self.move(ChaosGroup.settings_global.value('window position'))
ChaosGroup.download_path = ChaosGroup.settings_global.value('install folder')
except:
logging.info('Cannot Load Settings!')
pass
#CREATE DOWNLOAD FOLDER IF NOT EXIST
if not os.path.exists(ChaosGroup.download_path):
os.makedirs(ChaosGroup.download_path)
#TRY LOADING SUDO PASSWORD FROM SETTINGS
if platform.system() != 'Windows':
try:
ChaosGroup.sudo_password = ChaosGroup.settings_global.value('sudo_password')
#CHECK IF PASSWORD IS RIGHT, IF NOT THROWN AN ERROR AND EXECUTE THE EXCEPT BLOCK
subprocess.check_output('sudo -k -S echo success', shell=True, input=ChaosGroup.sudo_password)
logging.info('Sudo-password successfully loaded')
#IF LOGIN IS SUCCESSFULL CREATE TABS
self.tab_MAIN = Tab_MAIN(self)
self.setCentralWidget(self.tab_MAIN)
#IF PASSWORD IS INCORRECT BUILD THE GUI FOR THE SUDO-INPUT-WINDOW
except:
logging.info('Cannot load sudo-password')
self.sudo_login = Sudo_Login()
self.setCentralWidget(self.sudo_login)
self.tab_MAIN = Tab_MAIN(self)
self.tab_MAIN.hide()
#IF SYSTEM IS WINDOWS, JUST CREATE TABS
else:
self.tab_MAIN = Tab_MAIN(self)
self.setCentralWidget(self.tab_MAIN)
def closeEvent(self, *args, **kwargs):
# STORE SETTINGS
CG.tab_MAIN.tab_Settings.storeSettings()
class StatusBar(QStatusBar):
def __init__(self):
super().__init__()
# self.statusBar = QStatusBar()
self.platformName = QLabel("Host App:")
self.platformName.setStyleSheet("QLabel{font-weight: bold;color: grey}")
self.addPermanentWidget(self.platformName)
self.platormPath = QLabel("host-app-path")
self.addPermanentWidget(self.platormPath)
self.productName = QLabel("product-name:")
self.productName.setStyleSheet("QLabel{font-weight: bold;color: grey}")
self.addPermanentWidget(self.productName)
self.version = QLabel("xx.xx.xx")
self.addPermanentWidget(self.version)
self.productName2 = QLabel("V-Ray:")
self.productName2.setStyleSheet("QLabel{font-weight: bold;color: grey}")
self.productName2.hide()
self.addPermanentWidget(self.productName2)
self.version2 = QLabel("xx.xx.xx")
self.version2.hide()
self.addPermanentWidget(self.version2)
# self.statusBar.showMessage("Sample Message Status Bar:")
def update_visibility(self, productName = '', platformName =''):
CG.statusBar.productName.show()
CG.statusBar.version.show()
CG.statusBar.platformName.show()
CG.statusBar.platormPath.show()
CG.statusBar.productName2.show()
CG.statusBar.version2.show()
CG.statusBar.platformName.show()
CG.statusBar.platormPath.show()
# HIDE/SHOW STATUS BAR TEXTS:
if productName in ['Lavina', 'Chaos Vantage', 'License Server', 'PDPlayer', 'V-Ray AppSDK']:
CG.statusBar.platformName.hide()
CG.statusBar.platormPath.hide()
CG.statusBar.productName2.hide()
CG.statusBar.version2.hide()
if platform.system() != 'Windows' and productName == 'PDPlayer':
CG.statusBar.productName.hide()
CG.statusBar.version.hide()
elif productName == 'V-Ray' and platformName != 'Standalone':
CG.statusBar.productName2.hide()
CG.statusBar.version2.hide()
elif (productName == 'V-Ray' and platformName == 'Standalone') or (productName == 'V-Ray Swarm'):
CG.statusBar.platformName.hide()
CG.statusBar.platormPath.hide()
CG.statusBar.productName2.hide()
CG.statusBar.version2.hide()
#HIDE ALL THE STATUSBAR ITEMS
elif productName == 'V-Ray Benchmark':
CG.statusBar.productName.hide()
CG.statusBar.version.hide()
CG.statusBar.platformName.hide()
CG.statusBar.platormPath.hide()
CG.statusBar.productName2.hide()
CG.statusBar.version2.hide()
CG.statusBar.platformName.hide()
CG.statusBar.platormPath.hide()
# elif productName == 'Phoenix FD':
# pass
def update_versions(self, productName='', productVersion = '', platformName='', platformVersion=''):
self.update_visibility(productName=productName, platformName=platformName)
#reg = CG_Registry.Registry()
# UPDATE CG-VERSION
CG.statusBar.productName.setText(productName)
if platform.system() == 'Windows':
cg_version = CG_Registry.Registry().getCGproductVer(productName, platformName, platformVersion)
elif platform.system() == 'Darwin':
cg_version = CG_Uninstall.CG_Uninstall().getChaosProductVersion(productName=productName, platformName=platformName, platformVersion=platformVersion)
elif platform.system() == 'Linux':
cg_version = CG_Uninstall.CG_Uninstall().getChaosProductVersion(productName=productName, platformName=platformName, platformVersion=platformVersion)
CG.statusBar.version.setText(cg_version)
if cg_version == 'Not Installed':
CG.statusBar.version.setStyleSheet("QLabel{color: red}")
else:
CG.statusBar.version.setStyleSheet("")
# UPDATE PLATFORM PATH
if platform.system() == 'Windows':
platform_path = CG_Registry.registry.getHostAppPath(platformName=platformName, platformVersion=platformVersion,
productVersion=productVersion)
elif platform.system() == 'Linux':
platform_path = CG_Utilities.instance.linux_get_host_app_path(platformName=platformName, platformVersion=platformVersion)
elif platform.system() == 'Darwin':
platform_path = CG_Utilities.instance.mac_get_host_app_path(platformName=platformName, platformVersion=platformVersion)
#REMOVE THE STRING DATA AFTER THE .APP
if '.app' in platform_path:
split_index = platform_path.find('.app') + len('.app')
platform_path = platform_path[:split_index]
CG.statusBar.platormPath.setText(platform_path)
if platform_path == 'Not Installed':
CG.statusBar.platormPath.setStyleSheet("QLabel{color: red}")
else:
CG.statusBar.platormPath.setStyleSheet("")
# UPDATE CG-VERSION2 WHEN PHOENIXFD IS THE PRODUCT NAME
if platform.system() != 'Darwin':
if platform.system() == 'Windows':
cg_version2 = CG_Registry.Registry().getCGproductVer('V-Ray', platformName, platformVersion)
elif platform.system() == 'Linux':
cg_version2 = CG_Uninstall.CG_Uninstall().getChaosProductVersion(productName='V-Ray', platformName=platformName, platformVersion=platformVersion)
#cg_version2 = 'Not Installed'
CG.statusBar.version2.setText(cg_version2)
if cg_version2 == 'Not Installed':
CG.statusBar.version2.setStyleSheet("QLabel{color: red}")
else:
CG.statusBar.version2.setStyleSheet("")
class Tab_MAIN(QWidget): #HERE THE WINDOW IS SPLIT ON MULTIPLE TABS, AND INFO IS ADDED INTO EACH TAB
def __init__(self, parent):
super(QWidget, self).__init__(parent)
self.mainLayout = QVBoxLayout()
#CREATE TABS
self.tab_Widget = QTabWidget(self)
self.tab_Install = Tab_Installer()
self.tab_Uninstall = Tab_Uninstaller()
self.tab_License = Tab_License()
# self.tab_Logging = Tab_Logging()
self.tab_Settings = Tab_Settings()
#ADD TABS TO TAB-WIDGET
self.tab_Widget.addTab(self.tab_Install, "Installer")
self.tab_Widget.addTab(self.tab_Uninstall, "Uninstaller")
self.tab_Widget.addTab(self.tab_License, "License Listener")
self.tab_Widget.addTab(self.tab_Settings, 'Settings')
#ADD PROGRESS BAR
self.progress_bar = QProgressBar()
# self.progress_bar.setAlignment(Qt.AlignCenter)
self.progress_bar.setMaximumHeight(5)
self.progress_bar.setTextVisible(False)
self.progress_bar.hide()
#ADD WIDGETS TO LAYOUT
self.mainLayout.addWidget(self.tab_Widget)
self.mainLayout.addWidget(self.progress_bar)
self.setLayout(self.mainLayout)
def progress_bar_update(self, data):
self.progress_done = data['progress_done']
self.downloaded_mb = data['downloaded_mb']
self.total_mb = data['total_mb']
if self.progress_done != 100:
CG.tab_MAIN.progress_bar.show()
CG.tab_MAIN.progress_bar.setValue(self.progress_done)
CG.statusBar.showMessage("Downloading " + str(self.progress_done) + "% " + str(self.downloaded_mb) + "MB/" + str(self.total_mb) + "MB")
else:
CG.tab_MAIN.progress_bar.hide()
CG.statusBar.clearMessage()
class Tab_Installer(QWidget): #THIS WIDGET IS SPLIT INTO SEPARATE GROUPS, EACH GROUP HAS IT'S OWN SET OF FUCTIONALITY
def __init__(self):
super().__init__()
#CREATE LAYOUT
self.mainLayout = QVBoxLayout()
self.bottomLayout = QHBoxLayout()
self.bottomLayout.setAlignment(Qt.AlignLeft)
self.tab_installer_ref = self #REFERENCE TO THIS TAB_INSTALLER IS NEEDED IN ORDER TO LATER ADD OFFICIAL WIDGET AFTER LOGIN
self.group_login = Group_LogIn(self.tab_installer_ref)
# self.group_official = Group_Official() #OFFICIAL-DOWNLOAD WIDGET WILL BE ADDED IN THE LOGIN TAB
self.group_nightly = Group_Nightly()
self.group_zip = Group_ZIP()
self.rbtn_install_silent = QRadioButton("Silent Install")
self.rbtn_install_silent.setChecked(True)
self.rbtn_install_gui = QRadioButton("GUI Install")
self.chbox_start_host_app_after_install = QCheckBox('Start Host-App')
self.qcheck_quit_after_installation = QCheckBox('Quit after install')
#ADD WIDGETS TO LAYOUT
self.mainLayout.addWidget(self.group_login.groupBox_Login)
# self.mainLayout.addWidget(self.group_official.groupBox_Official) #OFFICIAL-DOWNLOAD WIDGET WILL BE ADDED IN THE LOGIN TAB
self.mainLayout.addWidget(self.group_nightly.groupBox_Nightly)
self.mainLayout.addWidget(self.group_zip.groupBox_ZIP_Installer)
self.bottomLayout.addWidget(self.rbtn_install_silent)
self.bottomLayout.addWidget(self.rbtn_install_gui)
self.bottomLayout.addWidget(self.chbox_start_host_app_after_install)
self.bottomLayout.addWidget(self.qcheck_quit_after_installation)
self.mainLayout.addLayout(self.bottomLayout)
#mainLayout.addStretch(1)
self.setLayout(self.mainLayout)
#VARIABLE TO STORE BUILD ID VALUE NEEDED FOR THE DOWNLOAD FUNCTION OF CG_OFFICIAL FILE
self.build_id_list = []
self.buildFile_list = []
class Group_LogIn(QWidget):
#THIS CLASS PROVIDES USER-LOGIN FUNCTIONALITY WITH CHAOS-ACCOUNT
#IF LOGIN IS NOT SUCCESFULL THE REST OF THE UI REMAINS HIDDEN FOR THE USER
def __init__(self, tab_installer_ref):
super().__init__()
self.groupBox_Login = QGroupBox("www.chaosgroup.com")
mainLayout = QHBoxLayout()
self.tab_installer_ref = tab_installer_ref
#CHAOSGROUP.COM LOGIN
try:
ChaosGroup.username = ChaosGroup.settings_global.value('username')
ChaosGroup.password = ChaosGroup.settings_global.value('password')
except:
logging.info('Cannot load log-in credentials')
#CHECK IF USERNAME AND PASSWORD ARE CORRECT BY LOGGING TO CHAOSGROUP.COM
self.log_in_chaosgroup = CG_Official.GetBuildsList(username=ChaosGroup.username, password=ChaosGroup.password)
#SHOW LOGON SCREEN IF LOGIN IS NOT SUCCESSFULL
if self.log_in_chaosgroup.status_code != 200:
#ADD WIDGETS
self.qlabel_username = QLabel('Username:')
self.qline_username = QLineEdit()
self.qlabel_password = QLabel('Password')
self.qline_password = QLineEdit()
self.qline_password.setEchoMode(QLineEdit.Password)
self.qcheckbox_remember_credentials = QCheckBox('Remember Credentials')
self.btn_log_in = QPushButton('Log In')
self.btn_log_in.clicked.connect(lambda: self.LogInButtonPress(username=self.qline_username.text(),
password=self.qline_password.text()))
mainLayout.addWidget(self.qlabel_username)
mainLayout.addWidget(self.qline_username)
mainLayout.addWidget(self.qlabel_password)
mainLayout.addWidget(self.qline_password)
mainLayout.addWidget(self.qcheckbox_remember_credentials)
mainLayout.addWidget(self.btn_log_in)
self.groupBox_Login.setLayout(mainLayout)
else:
#IF LOGGIN IS SUCCESSFULL PASS THE BUILDS LIST TO OFFICIAL-GROUP, ADD OFFICIAL GROUP TO TAB-WIDGET, AND HIDE LOGGIN GROUP
self.group_official = Group_Official(builds_list = self.log_in_chaosgroup)
self.tab_installer_ref.mainLayout.addWidget(self.group_official.groupBox_Official)
self.groupBox_Login.hide()
#SET V-RAY AS DEFAULT PRODUCT FOR OFFICIAL AND NIGHTLY GROUP
def LogInButtonPress(self, username, password):
self.log_in_chaosgroup = CG_Official.GetBuildsList(username=username, password=password)
#IF LOGIN IS SUCCESFULL PROCEED WITH ADDING THE REST OF THE UI-MENUS
if self.log_in_chaosgroup.status_code == 200:
logging.info('Succesfull login')
#STORE USERNAME/PASSWORD IN SETTINGS
if self.qcheckbox_remember_credentials.isChecked() == True:
ChaosGroup.settings_global.setValue('username', self.qline_username.text())
ChaosGroup.settings_global.setValue('password', self.qline_password.text())
#STORE USERNAME/PASSWORD IN GENERAL VARIABLES, CAUSE THOSE ARE USED IN OFFICIAL-SECTION,
#AND SINCE THEY ARE ONLY LOADED IN THE BEGINING OF THE SCTIPT THEY WILL NOT BE UPDATED WHEN LOGIN SCREEN APPEARS
ChaosGroup.username = self.qline_username.text()
ChaosGroup.password = self.qline_password.text()
#INNITIALIZE OFFICIAL INSTALLER AFTER SUCCESSFULL LOGIN
self.group_official = Group_Official(builds_list = self.log_in_chaosgroup)
self.tab_installer_ref.group_login.groupBox_Login.hide()
self.tab_installer_ref.mainLayout.insertWidget(0, self.group_official.groupBox_Official)
#SET V-RAY AS A CURRENT PRODUCT FOR THE OFFICIAL INSTALLER
vray_index = self.group_official.cbox_official_productName.findText('V-Ray')
self.group_official.cbox_official_productName.setCurrentIndex(vray_index)
else:
error_msg = 'Cannot not log-in, are you using the correct username and password'
more_information = 'Try to log-in https://download.chaosgroup.com/ in a web-browser.'
CG_Utilities.instance.PyQTerrorMSG(error_msg=error_msg, more_information=more_information, App=CG)
class Group_Official(QWidget):
def __init__(self, builds_list):
super().__init__()
self.groupBox_Official = QGroupBox("Official Installer (download.chaos.com)")
self.topLayout = QHBoxLayout()
self.bottonLayout = QHBoxLayout()
self.mainLayout = QVBoxLayout()
# SELECT PRODUCT COMBOBOX
self.cbox_official_productName = QComboBox()
#CREATE A SET OF PRODUCTS IN ORDER TO REMOVE DUPLICATES
self.official_cg_product_set = set()
#GET BUILDS LIST FROM WEBSITE
self.get_builds_list = builds_list #CG_Official.GetBuildsList(username=ChaosGroup.username,password=ChaosGroup.password)
for item in self.get_builds_list.builds_list:
self.official_cg_product_set.add(item['productName'])
self.official_cg_product_set = sorted(self.official_cg_product_set)
#ADD PRODUCT SET TO COMBOBOX
for item in self.official_cg_product_set:
self.cbox_official_productName.addItem(item)
self.cbox_official_productName.currentTextChanged.connect(self.cbox_official_productName_function) #RUN A FUNCTION WHEN COMBOX OPTION IS CHANGED
# SELECT HOST APPLICATION COMBOBOX
self.cbox_official_platformName = QComboBox()
self.cbox_official_platformName.addItem("-")
self.cbox_official_platformName.currentTextChanged.connect(self.cbox_official_platformName_function) #RUN A FUNCTION WHEN COMBOX OPTION IS CHANGED
#SELECT HOST APP VERSION COMBOBOX
self.cbox_official_platformVersion = QComboBox()
self.cbox_official_platformVersion.addItem("-")
self.cbox_official_platformVersion.currentTextChanged.connect(self.cbox_official_platformVersion_function) #RUN A FUNCTION WHEN COMBOX OPTION IS CHANGED
# SELECT VRAY VERSION COMBOBOX
self.cbox_official_version = QComboBox()
self.cbox_official_version.addItem("-")
self.cbox_official_version.currentTextChanged.connect(self.cbox_official_version_function)
#INSTALL BUTTON
self.official_install = QPushButton('Install', self)
self.official_install.clicked.connect(self.click_btn_official_install)
#ADD WIDGETS TO LAYOUT
self.topLayout.addWidget(self.cbox_official_productName)
self.topLayout.addWidget(self.cbox_official_platformName)
self.topLayout.addWidget(self.cbox_official_platformVersion)
self.topLayout.addWidget(self.cbox_official_version)
self.bottonLayout.addWidget(self.official_install)
self.mainLayout.addLayout(self.topLayout)
self.mainLayout.addLayout(self.bottonLayout)
self.groupBox_Official.setLayout(self.mainLayout)
# self.setLayout(self.mainLayout)
# OFFICIAL INSTALL - CONNECT BUTTON/MENUS FUNCTIONS
def cbox_official_productName_function(self):
logging.info('ProductName = %s', self.cbox_official_productName.currentText())
# REMOVE EXISTING ITEMS FROM VARIABLES, NEEDED IN ORDER TO ADD NEW ONES
self.build_id_list = []
self.buildFile_list = []
#IF PRODUCT == V-RAY, PHOENIXFD ADD HOST HOST PLATFORMS TO HOST-APP COMBOBOX
if self.cbox_official_productName.currentText() == "V-Ray" or \
self.cbox_official_productName.currentText() == "Phoenix FD":
#CLEAR OTHER COMBOBOXES
self.cbox_official_platformName.clear()
self.cbox_official_platformName.show()
self.cbox_official_platformVersion.clear()
self.cbox_official_platformVersion.show()
self.cbox_official_version.clear()
#ADD PLATFORM TO COMBOBOX
platformName_set = set()
for item in self.get_builds_list.builds_list:
if item['productName'] == self.cbox_official_productName.currentText():
platformName_set.add(item['platformName'])
#print(item['platformName'])
#SORT HOST APP SET BEFORE ADDING ITEMS TO MENU
platformName_set = sorted(platformName_set)
for item in platformName_set:
self.cbox_official_platformName.addItem(item)
#IF PRODUCT == PDPLAYER, V-Ray AppSDK, License Server, Lvina
if self.cbox_official_productName.currentText() == "PDPlayer" or \
self.cbox_official_productName.currentText() == "V-Ray AppSDK" or \
self.cbox_official_productName.currentText() == "License Server" or \
self.cbox_official_productName.currentText() == "Chaos Vantage" or \
self.cbox_official_productName.currentText() == "V-Ray Benchmark" or\
self.cbox_official_productName.currentText() == "V-Ray Swarm" or\
self.cbox_official_productName.currentText() == "Enterprise License Server" or\
self.cbox_official_productName.currentText() == "Cosmos Browser":
#CLEAR/HIDE OTHER COMBOBOXES
self.cbox_official_platformName.hide()
self.cbox_official_platformName.clear()
self.cbox_official_platformVersion.hide()
self.cbox_official_platformVersion.clear()
self.cbox_official_version.clear()
#ADD VERSIONS TO VERSION-COMBOBOX
for item in self.get_builds_list.builds_list:
if item['productName'] == self.cbox_official_productName.currentText():
self.cbox_official_version.addItem(item['version'])
self.build_id_list.append(item['id'])
self.buildFile_list.append(item['buildFile'])
#SET HOST APP TYPE FUCNTION
def cbox_official_platformName_function(self):
#IF PLATFORMNAME COMBOBOX IS NOT EMPTY
if self.cbox_official_platformName.currentText() != '':
logging.debug(self.cbox_official_platformName.currentText())
# REMOVE EXISTING ITEMS FROM VARIABLES, NEEDED IN ORDER TO ADD NEW ONES
self.build_id_list = []
self.buildFile_list = []
self.cbox_official_platformVersion.clear()
self.cbox_official_platformVersion.show()
if self.cbox_official_platformName.currentText() == 'Modo' or \
self.cbox_official_platformName.currentText() == 'Revit'or \
self.cbox_official_platformName.currentText() == 'SketchUp'or \
self.cbox_official_platformName.currentText() == 'Standalone'or \
self.cbox_official_platformName.currentText() == 'Unreal':
self.cbox_official_platformVersion.hide()
self.cbox_official_version.clear()
for item in self.get_builds_list.builds_list:
if item['platformName'] == self.cbox_official_platformName.currentText() and \
item['productName'] == self.cbox_official_productName.currentText():
self.cbox_official_version.addItem(item['version'])
self.build_id_list.append(item['id'])
self.buildFile_list.append(item['buildFile'])
if self.cbox_official_platformName.currentText() == '3ds Max' or \
self.cbox_official_platformName.currentText() == 'Maya' or \
self.cbox_official_platformName.currentText() == 'Houdini' or \
self.cbox_official_platformName.currentText() == 'Nuke' or \
self.cbox_official_platformName.currentText() == 'Rhino' or \
self.cbox_official_platformName.currentText() == 'Cinema 4D' :
platformName_set = set()
for item in self.get_builds_list.builds_list:
if item['platformName'] == self.cbox_official_platformName.currentText() and \
item['productName'] == self.cbox_official_productName.currentText():
platformName_set.add(item['platformVersion'])
platformName_set = sorted(platformName_set, reverse=True)
for item in platformName_set:
self.cbox_official_platformVersion.addItem(item)
#3DSMAX VERSION 9.0 IS BY DEFAULT ON TOP, REMOVE IT FROM THE TOP AND ADD IT BACK TO THE BOTTOM
if self.cbox_official_productName.currentText() == 'V-Ray' and self.cbox_official_platformName.currentText() == '3ds Max':
self.cbox_official_platformVersion.removeItem(0)
self.cbox_official_platformVersion.addItem(list(platformName_set)[0])
#SET HOST APP VERSION FUNCTION
def cbox_official_platformVersion_function(self):
#IF PLATFORM VERSION COMBOBOX IS NOT EMPTY:
if self.cbox_official_platformVersion.currentText() != '':
logging.info('<OFFICIAL> Platform Version = %s',self.cbox_official_platformVersion.currentText())
#REMOVE EXISTING ITEMS FROM VARIABLES, NEEDED IN ORDER TO ADD NEW ONES
self.build_id_list = []
self.buildFile_list = []
#ADD VERSIONS TO COMBOBOX
self.cbox_official_version.clear()
logging.info('<OFFICIAL> Platform Name = %s', self.cbox_official_platformName.currentText())
for item in self.get_builds_list.builds_list:
if item['platformName'] == self.cbox_official_platformName.currentText() and \
item['platformVersion'] == self.cbox_official_platformVersion.currentText() and \
item['productName'] == self.cbox_official_productName.currentText():
if self.cbox_official_productName.currentText() == "V-Ray":
self.cbox_official_version.addItem(item['version'])
self.build_id_list.append(item['id'])
self.buildFile_list.append(item['buildFile'])
if self.cbox_official_productName.currentText() == "Phoenix FD":
self.cbox_official_version.addItem(item['productNameExtended'][11:])
self.build_id_list.append(item['id'])
self.buildFile_list.append(item['buildFile'])
def cbox_official_version_function(self):
#IF VERSION COMBOBOX IS NOT EMPTY
if self.cbox_official_version.currentText() != '':
logging.info('<OFFICIAL> Product Version = %s', self.cbox_official_version.currentText())
# print(self.cbox_official_version.currentText())
#UPDATE STATUSBAR
CG.statusBar.update_versions(productName=self.cbox_official_productName.currentText(),
productVersion = self.cbox_official_version.currentText(),
platformName=self.cbox_official_platformName.currentText(),
platformVersion=self.cbox_official_platformVersion.currentText())
#CLICK ON OFFICIAL INSTALL BUTTON
def click_btn_official_install(self):
#CHECK IF HOST APP IS AVAILABLE:
platformName=self.cbox_official_platformName.currentText()
platformVersion = self.cbox_official_platformVersion.currentText()
productName = self.cbox_official_productName.currentText()
host_app_is_installed = CG_Utilities.instance.check_host_app_is_installed(productName=productName, platformName=platformName, platformVersion=platformVersion, App=CG)
if host_app_is_installed == True:
self.build_id = self.build_id_list[self.cbox_official_version.currentIndex()]
logging.debug('id = %s', self.build_id_list[self.cbox_official_version.currentIndex()])
self.build_file = self.buildFile_list[self.cbox_official_version.currentIndex()]
logging.info('buildFile = %s', self.buildFile_list[self.cbox_official_version.currentIndex()])
#BUILD DOWNLOADING
#NEEDED IN ORDER TO RUN DOWNLOAD PROCESS AS A SEPARATE THREAD
self.threadpool = QThreadPool()
logging.debug("Multithreading with maximum %d threads" % self.threadpool.maxThreadCount())
#SESSION KEEPS THE COOKIES FROM THE DOWNLOAD PAGE, THOSE NEEDS TO BE PASSED TO DOWNLOAD FUNCTION AS WELL
self.download_build = CG_Official.DownloadBuild(self.build_id, self.build_file, ChaosGroup.download_path, ChaosGroup.username, ChaosGroup.password)
#SIGNALS NEEDED TO UPDATE PROGRESS BAR, TITLE BAR, AND DETERMINE DONWLOAD COMPLETION
self.download_build.signals.finished.connect(self.run_installer)
#UPDATE PROGRESS BAR
self.download_build.signals.progress_data_signal.connect(CG.tab_MAIN.progress_bar_update)
#START DOWNLOAD PROCESS ON A SEPARATE THREAD
self.threadpool.start(self.download_build)
else:
logging.info('Installation canceled')
def run_installer(self):
#START INSTALLATION
CG_Utilities.instance.install(download_path = ChaosGroup.download_path,
build_file = self.build_file,
productName = self.cbox_official_productName.currentText(),
productVersion = self.cbox_official_version.currentText(),
platformName = self.cbox_official_platformName.currentText(),
platformVersion = self.cbox_official_platformVersion.currentText(),
silent_install = CG.tab_MAIN.tab_Install.rbtn_install_silent.isChecked(),
start_host_app = CG.tab_MAIN.tab_Install.chbox_start_host_app_after_install.isChecked(),
remove_files_after_install = CG.tab_MAIN.tab_Settings.qcheck_remove_official_files.isChecked(),
quit_after_install= CG.tab_MAIN.tab_Install.qcheck_quit_after_installation.isChecked(),
App = CG)
#UPDATE STATUS BAR
CG.statusBar.update_versions(productName=self.cbox_official_productName.currentText(),
productVersion = self.cbox_official_version.currentText(),
platformName=self.cbox_official_platformName.currentText(),
platformVersion=self.cbox_official_platformVersion.currentText())
#UPDATE UNINSTALL TAB
#CG.tab_MAIN.tab_Uninstall.add_update_table_items()
class Group_Nightly(QWidget):
def __init__(self):
super().__init__()
self.groupBox_Nightly = QGroupBox("Nightly Installer (nightlies.chaos.com)")
self.cg_nightlies = CG_Nightlies.Nightlies()
#CHECK IF FTP IS ACCESSIBLE
if self.cg_nightlies.ftp_status == False:
self.mainLayout = QVBoxLayout()
self.mainLayout.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
self.qlabel_ftp_not_accessible = QLabel('Chaos Nightlies FTP Server is not accessible! \n Make sure you are in the office network or use VPN!')
boldFont = QFont()
boldFont.setBold(True)
self.qlabel_ftp_not_accessible.setFont(boldFont)
self.mainLayout.addWidget(self.qlabel_ftp_not_accessible)
self.groupBox_Nightly.setLayout(self.mainLayout)
#IF FTP IS ACCESSIBLE PROCEED WITH THE REST OF THE WIDGETS
else:
self.topLayout = QHBoxLayout()
self.middleLayout = QHBoxLayout()
self.bottomLayout = QHBoxLayout()
self.mainLayout = QVBoxLayout()
self.Top_Layout()
def Top_Layout(self):
# SELECT PRODUCT
self.cbox_nightly_productName = QComboBox()
product_names = list(self.cg_nightlies.productsNames)
#remove product names for macOs
remove_items = []
if platform.system() == 'Darwin':
for item in product_names:
if item == 'Chaos Vantage' or item == 'Phoenix FD':
remove_items.append(item)
#remove product names for Linux
elif platform.system() == 'Linux':
for item in product_names:
if item == 'Chaos Vantage':
remove_items.append(item)
for item in remove_items:
product_names.remove(item)
self.cbox_nightly_productName.addItems(product_names)
self.cbox_nightly_productName.setToolTip("cbox_nightly_productName")
self.cbox_nightly_productName.currentTextChanged.connect(self.cbox_nightly_productName_function)
#SELECT PLATFORM TYPE
self.cbox_nightly_platformName = QComboBox()
self.cbox_nightly_platformName.setToolTip("cbox_nightly_platformName")
self.cbox_nightly_platformName.currentTextChanged.connect(self.cbox_nightly_platformName_function)
# SELECT PRODUCT VERSION
self.cbox_nightly_version = QComboBox()
self.cbox_nightly_version.setToolTip("cbox_nightly_version")
self.cbox_nightly_version.currentTextChanged.connect(self.cbox_nightly_version_function)
#INSTALL TYPE - NORMAL/ZIP
self.cbox_install_type = QComboBox()
self.cbox_install_type.addItems(['Standard Install', 'ZIP Install'])
self.cbox_install_type.currentTextChanged.connect(self.cbox_install_type_function)
# OPEN PAGE BUTTON
self.open_page = QPushButton('Open Web')
self.open_page.setMaximumWidth(150)
self.open_page.clicked.connect(self.open_nightly_website_function)
# INSTALL BUTTON
self.nightly_install = QPushButton('Install')
#self.nightly_install.setMaximumWidth(150)
self.nightly_install.clicked.connect(self.nightly_install_function)
# ADD WIDGETS TO LAYOUT
self.topLayout.addWidget(self.cbox_nightly_productName)
self.topLayout.addWidget(self.cbox_nightly_platformName)
self.topLayout.addWidget(self.cbox_nightly_version)
self.topLayout.addWidget(self.cbox_install_type)
self.topLayout.addWidget(self.open_page)
self.bottomLayout.addWidget(self.nightly_install)
self.mainLayout.addLayout(self.topLayout)
self.mainLayout.addLayout(self.middleLayout)
self.mainLayout.addLayout(self.bottomLayout)
self.groupBox_Nightly.setLayout(self.mainLayout)
def Bottom_Layout(self, widget_id = 0, path=None):
self.ftp_path = path
while True:
try:
self.cg_nightlies.ftp.cwd(path)
items = self.cg_nightlies.ftp.nlst()
#SORT NIGHTLY/STABLE/BETA/RELEASE
items = sorted(items, reverse=True)
def sort_function(input_value):
if input_value.startswith('n'):
return 0
elif input_value.startswith('s'):
return 1
else:
return 2
if 'nightly' in items or 'stable' in items or 'alpha' in items or 'beta' in items or 'release' in items:
items = sorted(items, key=sort_function )
#REMOVE SOME OF THE ITEMS FROM MENUS DEPENDING ON THE OPERATING SYSTEM
remove_items = []
if platform.system() == 'Windows':
#INSTALL TYPE = STANDARD
if self.cbox_install_type.currentText() == 'Standard Install':
for item in items:
if 'release_notes' in item or '.txt' in item or '.7z' in item or 'archive.zip' in item or 'mavericks' in item or \
'centos' in item or 'linux' in item or '_zip.' in item or 'dmg' in item or 'json' in item or \
'changelog' in item or 'mac' in item or 'scenes' in item or \
('houdini' in item and 'install' not in item) or \
('appsdk' in item and 'zip' in item) or \
('revit' in item and 'edge' in item):
remove_items.append(item)
#INSTALL TYPE = ZIP
else:
for item in items:
if 'release_notes' in item or '.txt' in item or 'mavericks' in item or 'centos' in item or 'linux' in item \
or 'install.zip' in item or 'dmg' in item or 'json' in item or 'changelog' in item or '_install_windows.zip' in item \
or '_mac.zip' in item or 'mac_' in item or '.exe' in item:
remove_items.append(item)
if platform.system() == 'Darwin':
#INSTALL TYPE = STANDARD
if self.cbox_install_type.currentText() == 'Standard Install':
for item in items:
if '.exe' in item or '.txt' in item:
remove_items.append(item)
if '.zip' in item:
if 'mavericks' not in item and 'snow_leopard' not in item and 'mac' not in item:
remove_items.append(item)
if 'mac' in item and 'install' not in item:
remove_items.append(item)
if 'mavericks' in item and 'install' not in item:
remove_items.append(item)
#INSTALL TYPE = ZIP
else:
for item in items:
if 'release_notes' in item or '.txt' in item:
remove_items.append(item)
if 'maya' in item:
if not (('archive' in item) and ('mavericks' in item)):
remove_items.append(item)
if 'houdini' in item:
if 'install' in item or 'windows' in item or 'linux' in item:
remove_items.append(item)