# -*- coding: utf-8 -*-
from setuphelpers import *
uninstallkey = []
# Place your Mesh Agent binaries in the package and adapt bin_name variables
# Defining variables
bin_name_x86 = 'meshagent32-computers.exe'
bin_name_x64 = 'meshagent64-computers.exe'
silent_args = '-fullinstall'
silent_uninst_args = '-fulluninstall'
app_uninstallkey = 'Mesh Agent'
app_name = 'Mesh Agent'
app_bin = 'MeshAgent.exe'
app_dir = makepath(programfiles, 'Mesh Agent')
app_path = makepath(app_dir, app_bin)
processes_to_kill = [app_bin]
def install():
# Initializing variables
package_version = control.version.split('-')[0]
# Installing the package
if need_install(app_uninstallkey, package_version):
if iswin64():
print('Installing: %s' % bin_name_x64)
run_notfatal('"%s" %s' % (bin_name_x64, silent_args))
#run((bin_name_x64, silent_args), accept_returncodes=[0,1,3010])
else:
print('Installing: %s' % bin_name_x86)
run_notfatal('"%s" %s' % (bin_name_x86, silent_args))
#run((bin_name_x86, silent_args), accept_returncodes=[0,1,3010])
else:
print("%s is already installed in correct version" % app_name)
def uninstall():
# Uninstalling the package
killalltasks(processes_to_kill)
run_notfatal(app_path, silent_uninst_args)
#run((app_path, silent_uninst_args), accept_returncodes=[0,1,3010])
def update_package():
# Initializing variables
package_version = control.version.split('-')[0]
version = get_version_from_binary(bin_name_x86, parameter='FileVersion')
if not version:
version = package_version
# Incrementing version of the package
control.version = '%s-%s'%(version,int(control.version.split('-')[-1])+1)
control.save_control_to_wapt()
print('Changing package version to: %s in WAPT\\control' % control.version)
def get_version_from_binary(filename, parameter='ProductVersion'):
if filename.endswith('.msi'):
return get_msi_properties(filename)[parameter]
else:
return get_file_properties(filename)[parameter]