Deleting a file via session setup
Published: August 5, 2024 - 2:39 PM
Hello everyone,
I'm trying to create a package for installing the Asana application; the application needs to be installed in the user's environment, so I'm using a session setup:
setup.py
However, the binary placed in C:\temp is not deleted at the end of the session setup, do you have any idea what my mistake is?
Thank you all for your help
I'm trying to create a package for installing the Asana application; the application needs to be installed in the user's environment, so I'm using a session setup:
setup.py
Code: Select all
# -*- coding: utf-8 -*-
from setuphelpers import *
import time
import glob
r"""
Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()
"""
# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls
bin_name = "AsanaSetup.exe"
bin_tempdir = makepath('C:\\temp')
binaries = makepath(bin_tempdir, bin_name)
user_app_dir = makepath(user_local_appdata, "Asana")
processes_to_kill = ["Asana"]
def install():
# Declaring local variables
print("Copying binaries in C:\temp")
filecopyto(bin_name, bin_tempdir)
def session_setup():
# Installing the package in user env
print("Installing: %s in user env" % "Asana")
install_exe_if_needed(binaries, killbefore="Asana.exe")
register_windows_uninstall(control)
time.sleep(20)
remove_file(binaries)
print("ASANA is Installed ")
def uninstall():
killalltasks(processes_to_kill)
print("Uninstalling: %s in user env" % "Asana")
unregister_uninstall("Asana")
Thank you all for your help