1+ import os
2+ import shutil
3+ from src .processthread import ProcessThread
4+ from src .utils import get_private_plugins_unpack_path , get_ae_plugins_dir , get_wineprefix_dir
5+
6+
7+ class PluginThread (ProcessThread ):
8+ def __init__ (self ):
9+ super ().__init__ ()
10+
11+ def set_plugin_zip_filename (self , filename : str ):
12+ self .plugin_zip_filename = filename
13+
14+ def run (self ):
15+ self .log_signal .emit ('[DEBUG] Unpacking plugins from the archive...' )
16+ self .progress_signal .emit (5 )
17+ self .remove_ppu_dir ()
18+
19+ ppu_dir = get_private_plugins_unpack_path ()
20+ self .unpack_zip (self .plugin_zip_filename , ppu_dir .as_posix ())
21+ self .progress_signal .emit (15 )
22+
23+ self .install_aex_plugins ()
24+ self .install_cep_extensions ()
25+ self .install_presets ()
26+ self .run_installers ()
27+
28+ self .remove_ppu_dir ()
29+ self .progress_signal .emit (95 )
30+ self .log_signal .emit ('[INFO] The plugins have been installed' )
31+
32+ self .finished_signal .emit (True )
33+ self .progress_signal .emit (100 )
34+
35+ def install_aex_plugins (self ):
36+ self .log_signal .emit ('[DEBUG] Installing aex plugins...' )
37+
38+ ppu_dir = get_private_plugins_unpack_path ()
39+ aex_src = ppu_dir .joinpath ('aex' )
40+
41+ for item in os .listdir (aex_src .as_posix ()):
42+ if self ._is_cancelled :
43+ self .cancelled .emit ()
44+ return
45+ src_path = aex_src .joinpath (item )
46+ dst_path = get_ae_plugins_dir ().joinpath (item )
47+
48+ if os .path .isdir (src_path ):
49+ shutil .copytree (src_path , dst_path , dirs_exist_ok = True )
50+ else :
51+ shutil .copy2 (src_path , dst_path )
52+
53+ self .log_signal .emit ('[INFO] AEX plugins installed' )
54+ self .progress_signal .emit (30 )
55+
56+ def install_presets (self ):
57+ self .log_signal .emit ('[DEBUG] Installing presets...' )
58+
59+ ppu_dir = get_private_plugins_unpack_path ()
60+ preset_src = ppu_dir .joinpath ('preset-backup' )
61+ preset_dest = get_wineprefix_dir ().joinpath ('drive_c/users/relative/Documents/Adobe/After Effects 2024/User Presets' )
62+
63+ os .makedirs (preset_dest , exist_ok = True )
64+ for item in os .listdir (preset_src ):
65+ if self ._is_cancelled :
66+ self .cancelled .emit ()
67+ return
68+ src_path = preset_src .joinpath (item )
69+ dst_path = preset_dest .joinpath (item )
70+ if os .path .isdir (src_path ):
71+ shutil .copytree (src_path , dst_path , dirs_exist_ok = True )
72+ else :
73+ shutil .copy2 (src_path , dst_path )
74+
75+ self .log_signal .emit ("[INFO] Presets installed" )
76+ self .progress_signal .emit (55 )
77+
78+ def run_installers (self ):
79+ self .log_signal .emit ('[DEBUG] Running installers...' )
80+ ppu_dir = get_private_plugins_unpack_path ()
81+ install_src = ppu_dir .joinpath ('installer' )
82+
83+ installers_counter = 0
84+
85+ for exe in os .listdir (install_src .as_posix ()):
86+ if exe .endswith ('.exe' ) and exe not in ['E3D.exe' , 'saber.exe' ]:
87+ self .progress_signal .emit (55 + installers_counter * 3 )
88+
89+ self .log_signal .emit (f"[INFO] Installing: { exe } " )
90+ self .run_command (
91+ ['wine' , exe , '/verysilent' , '/suppressmsgboxes' ],
92+ install_src .as_posix (), True
93+ )
94+
95+ self .progress_signal .emit (70 )
96+
97+ # Special handling for E3D and saber
98+ for exe in ['E3D.exe' , 'saber.exe' ]:
99+ self .log_signal .emit (f"[INFO] Please manually install: { exe } " )
100+ self .run_command (
101+ ['wine' , exe ],
102+ install_src .as_posix (), True
103+ )
104+
105+ self .progress_signal .emit (85 )
106+ self .copy_element_files ()
107+
108+ def copy_element_files (self ):
109+ self .log_signal .emit ('[DEBUG] Copying Element files...' )
110+
111+ ppu_dir = get_private_plugins_unpack_path ()
112+ install_src = ppu_dir .joinpath ('installer' )
113+
114+ video_copilot_dir = get_ae_plugins_dir ().joinpath ("VideoCopilot" )
115+ element_files = [
116+ ("Element.aex" , "Element.aex" ),
117+ ("Element.license" , "Element.license" )
118+ ]
119+
120+ for src_name , dst_name in element_files :
121+ src_path = install_src .joinpath (src_name )
122+ if os .path .exists (src_path ):
123+ shutil .copy2 (src_path , os .path .join (video_copilot_dir , dst_name ))
124+ self .log_signal .emit (f"[INFO] { src_name } copied successfully" )
125+
126+ self .log_signal .emit ("[INFO] Element installed" )
127+ self .progress_signal .emit (90 )
128+
129+ def install_cep_extensions (self ):
130+ self .log_signal .emit ('[DEBUG] Installing CEP extensions...' )
131+
132+ ppu_dir = get_private_plugins_unpack_path ()
133+ cep_dir = ppu_dir .joinpath ('CEP' )
134+
135+ cep_reg_file = cep_dir .joinpath ("AddKeys.reg" )
136+ self .run_command (['wine' , "regedit" , cep_reg_file .as_posix ()], in_prefix = True )
137+
138+ self .install_flow ()
139+
140+ self .log_signal .emit ("[INFO] CEP extensions installed" )
141+ self .progress_signal .emit (45 )
142+
143+ def install_flow (self ):
144+ ppu_dir = get_private_plugins_unpack_path ()
145+ cep_dir = ppu_dir .joinpath ('CEP' )
146+
147+ self .log_signal .emit ('[DEBUG] Installing Flow...' )
148+
149+ flow_src = cep_dir .joinpath ("flowv1.4.2" )
150+ cep_dst = get_wineprefix_dir ().joinpath ("drive_c/Program Files (x86)/Common Files/Adobe/CEP/extensions" )
151+
152+ os .makedirs (cep_dst , exist_ok = True )
153+ shutil .copytree (flow_src , os .path .join (cep_dst , "flowv1.4.2" ), dirs_exist_ok = True )
154+ self .log_signal .emit ("[INFO] Flow installed" )
155+
156+ def remove_ppu_dir (self ):
157+ ppu_dir = get_private_plugins_unpack_path ()
158+ try :
159+ shutil .rmtree (ppu_dir .as_posix ())
160+ self .log_signal .emit ('[DEBUG] Temporary folder removed successfully.' )
161+ except OSError as e :
162+ self .log_signal .emit (f'[WARNING] Failed to remove temporary folder { ppu_dir } : { e } ' )
0 commit comments