# -*- coding: utf-8 -*-
##################################################
# This file is part of WAPT Enterprise
# All right reserved, (c) Tranquil IT Systems 2023
# For more information please refer to
# https://wapt.tranquil.it/store/licences.html
##################################################
from setuphelpers import *
import subprocess
import os
r"""
{
"key": "Dassault Systemes B22_0",
"name": "Dassault Systemes Software Version 5-6 Release 2012 (B22)",
"version": "",
"install_date": "",
"install_location": "",
"uninstall_string": '"C:\\Program Files\\Dassault Systemes\\B22\\win_b64\\code\\bin\\Uninstall.exe" "C:\\Program Files\\Dassault Systemes\\B22" "CODE" "GUI" "B22" "0"',
"publisher": "",
"system_component": 0,
"win64": true,
},
{
"key": "{CF1EB598-B424-436A-B15F-B763846BA970}",
"name": "Dassault Systemes Software Prerequisites x86-x64",
"version": "8.1.3",
"install_date": "2024-02-26 00:00:00",
"install_location": "",
"uninstall_string": "MsiExec.exe /X{CF1EB598-B424-436A-B15F-B763846BA970}",
"publisher": "Dassault Systemes",
"system_component": 0,
"win64": true,
},
{
"key": "{F2F2DEA7-36AB-4E13-907C-D8BDE775EF97}",
"name": "Dassault Systemes Software VC9 Prerequisites x86-x64",
"version": "9.1.2",
"install_date": "2024-02-26 00:00:00",
"install_location": "",
"uninstall_string": "MsiExec.exe /X{F2F2DEA7-36AB-4E13-907C-D8BDE775EF97}",
"publisher": "Dassault Systemes",
"system_component": 0,
"win64": true,
}
"""
sub_sources = "CATIA_V5-6R2012_SP4_64bits"
# bin_name = "StartB.exe"
editor_dir = makepath(programfiles, "Dassault Systemes")
# install_path = r"C:\Appli\Dassault Systemes\B22"
# C:\Program Files\Dassault Systemes\B22
install_path = makepath(editor_dir, "B22")
app_uninstallkey = "Dassault Systemes B22_0"
app_path = makepath(install_path, r"win_b64\code\bin\CNEXT.exe")
def install():
# Declaring local variables
package_version = control.get_software_version()
sources = makepath(sub_sources, "v5_6r2012_P2_x64")
# Unzipping sources
if not isdir(sub_sources):
unzip("CATIA_V5-6R2012_SP4_64bits.zip", ".")
# Install VC9 for CATIA (test is needed)
for vc_path in glob.glob("%s/**.msi" % makepath(basedir, sources, "WIN64")):
install_msi_if_needed(vc_path)
# Installation VBA
bin_path = makepath(basedir, sources, r"VBA\vba6.msi")
install_msi_if_needed(
bin_path,
properties="/qb-",
min_version=package_version,
)
# Installation CATIA V5-6R2012 (64 bits) # It will timeout on first installation
bin_path = os.path.join(basedir, sources, "WIN64", "StartB.exe")
## silentflags = ('-newdir -l "EX2.slt CPE.prd CPM.prd" -addUserPrivilegesForOrbix -noreboot')
exe_file = [bin_path,'-newdir','-l','"EX2.slt', 'CPE.prd', 'CPM.prd"','-noreboot']
print("Installing: %s" % bin_path)
subprocess.run(exe_file, timeout=420, check=True)
## Install timeout if use with install_exe_if_needed
## install_exe_if_needed(
## bin_path,
## silentflags=silentflags,
## key=app_uninstallkey,
## min_version="",
## accept_returncodes=[0,3],
## )
# # Copy license
# lic_dir = r"C:\ProgramData\DassaultSystemes\Licenses"
# lic_file = "DSLicSrv.txt"
# lic_path = makepath(lic_dir, lic_file)
# if not isdir(lic_dir):
# mkdirs(lic_dir)
# if not isfile(lic_path):
# copyfile(lic_file, lic_path)
# Installation Installation CATIA V5-6R2012 SP4 (64 bits)
sources = makepath(sub_sources, "v5_6r2012_SP4_x64")
bin_path = makepath(basedir, sources, r"WIN64\startSPKB.exe")
silentflags = r'-v -bC -u "%s" -killprocess' % install_path
if Version(get_version_from_binary(app_path)) < Version(package_version):
print("Installing: %s" % bin_path)
install_exe_if_needed(
bin_path,
silentflags=silentflags,
key="",
min_version=package_version,
timeout=3600,
)
# Clear the uninstallkeys to avoid the no-code audit and uninstall
uninstallkey.clear()
def uninstall():
# run(r'"C:\Appli\Dassaul0t Systemes\B423_Cloud\Uninstall.bat" -quiet')
## quiet_uninstall_string = installed_softwares(f"Dassault Systemes B22_0")[0]["uninstall_string"] +" -quiet"
## run(quiet_uninstall_string)
uninstaller_path = f"{install_path}\DSUninstall.bat" # makepath(install_path, "Uninstall.bat")
if isfile(uninstaller_path):
killalltasks(ensure_list(control.impacted_process))
# run('"%s" -quiet' % uninstaller_path)
run('"%s"' % uninstaller_path)
# Uninstalling the additionnal softwares
other_keys = ["{CF1EB598-B424-436A-B15F-B763846BA970}", "{F2F2DEA7-36AB-4E13-907C-D8BDE775EF97}"]
for key in other_keys:
to_uninstall = installed_softwares(uninstallkey=key)
if to_uninstall:
to_uninstall = to_uninstall[0]
else:
continue
print("Removing: %s (%s)" % (to_uninstall["name"], to_uninstall["version"]))
killalltasks(ensure_list(control.impacted_process))
run(uninstall_cmd(to_uninstall["key"]))
wait_uninstallkey_absent(to_uninstall["key"])
if installed_softwares(app_uninstallkey):
error("CATIA V5 IS NOT UNINSTALLED")
if isdir(editor_dir) and dir_is_empty(editor_dir):
remove_tree(editor_dir)