Deleting a file via session setup

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Answer
jorico
Messages: 27
Registration: August 11, 2022 - 4:42 PM
Location: NIORT

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

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")

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 :)
WAPT Enterprise 2.5.5.15697
Server = Debian 11 Bullseye
Console = Windows Server 2019
--------------------------------------------------------------------------

Johan
User avatar
t.heroult
Messages: 307
Registration: December 8, 2020 - 10:13 AM

August 5, 2024 - 3:42 PM

Hello,
silly question, but does the user have the right to delete a file from the temp folder?
Don't forget that session-setup is done with the rights of the current user.
Server: WAPT Enterprise 2.6.1.17786 on Debian
Consoles: Windows 10 & 11
Infrastructure: Windows

Did you know? When parrotfish undergo smoltification, their osmoregulation mechanism is reversed!
jorico
Messages: 27
Registration: August 11, 2022 - 4:42 PM
Location: NIORT

August 5, 2024 - 3:52 PM

t.heroult wrote: August 5, 2024 - 3:42 PM Hello,
silly question, but does the user have the right to delete a file from the temp folder?
Don't forget that session-setup is done with the rights of the current user.
Hello t.heroult,

Thanks for your question; I hadn't considered that point. The user has the right to delete the file in the C:\temp folder

I just checked, I'm getting an error after installation:

CRITICAL Exception: The database is locked. There is probably another WAPT process currently running (WaptAgent, WaptSelfService, wapt-get, waptpython.exe). Please check running processes. Error: OperationalError('database is locked')
WAPT Enterprise 2.5.5.15697
Server = Debian 11 Bullseye
Console = Windows Server 2019
--------------------------------------------------------------------------

Johan
User avatar
t.heroult
Messages: 307
Registration: December 8, 2020 - 10:13 AM

August 5, 2024 - 4:10 PM

It's surprising to get this error during session setup; you'll have to wait for support to reply :)
Server: WAPT Enterprise 2.6.1.17786 on Debian
Consoles: Windows 10 & 11
Infrastructure: Windows

Did you know? When parrotfish undergo smoltification, their osmoregulation mechanism is reversed!
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

August 14, 2024 - 1:22 PM

The OperationalError('database is locked') problem

often occurs when two WAPT processes are running concurrently.

For example, the service might be performing an update, and at the same time, you run `wapt-get upgrade` from the administrator command line.

Two processes are therefore trying to access the same database, resulting in the OperationalError('database is locked').
Answer