Page 1 of 1

Deleting a file via session setup

Published: August 5, 2024 - 2:39 PM
by jorico
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 :)

Re: Deleting a file via session setup

Published: August 5, 2024 - 3:42 PM
by t.heroult
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.

Re: Deleting a file via session setup

Published: August 5, 2024 - 3:52 PM
by jorico
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')

Re: Deleting a file via session setup

Published: August 5, 2024 - 4:10 PM
by t.heroult
It's surprising to get this error during session setup; you'll have to wait for support to reply :)

Re: Deleting a file via session setup

Published: August 14, 2024 - 1:22 PM
by sfonteneau
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').