[SOLVED] Error creating a package via the Windows portable application package generator

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
Locked
elux
Messages: 11
Registration: December 12, 2022 - 09:02

August 18, 2023 - 4:11 PM

Good morning,
I get an error message when I try to install a package generated by the WAPT console.
The product is W11Classicmenu, and to install it, you need to copy the directory. So I used the "Windows portable application" option
Unfortunately, here is the error message I get when I try to install it:

Code: Select all

Traceback (most recent call last):
  File "C:\Program Files (x86)\wapt\common.py", line 4009, in install_wapt
    setup = import_setup(setup_filename)
  File "C:\Program Files (x86)\wapt\waptutils.py", line 1525, in import_setup
    py_mod = imp.load_source(modulename, setupfilename)
  File "imp.py", line 171, in load_source
  File "<frozen importlib._bootstrap>", line 702, in _load
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 839, in exec_module
  File "<frozen importlib._bootstrap_external>", line 976, in get_code
  File "<frozen importlib._bootstrap_external>", line 906, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\WINDOWS\TEMP\wapt1fubbh_4\setup.py", line 26
    print("Copying directory: %%s to: %%s" %% (dir_name, app_dir))
                                            ^
SyntaxError: invalid syntax

SyntaxError: invalid syntax (setup.py, line 26)

The setup.py file seems correct to me:

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *

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
dir_name = 'W11ClassicMenu'
app_name = 'W11ClassicMenu'
app_exe = 'W11ClassicMenu.exe'
app_dir = makepath(programfiles32, dir_name)
app_path = makepath(app_dir, app_exe)


def install():
    # Initializing variables

    # Installing software
    print("Installing: mgp-W11ClassicMenu")
    killalltasks(control.get_impacted_process_list())
    mkdirs(app_dir)
    if isdir(app_dir):
        remove_tree(app_dir)
    mkdirs(app_dir)
    print("Copying directory: %%s to: %%s" %% (dir_name, app_dir))
    copytree2(dir_name, app_dir)

    # Creating shortcuts
    create_desktop_shortcut(app_name, app_path)
    create_programs_menu_shortcut(app_name, app_path)


def uninstall():
    # Uninstalling software
    killalltasks(control.get_impacted_process_list())
    if isdir(app_dir):
        remove_tree(app_dir)

    # Removing shortcuts
    remove_desktop_shortcut(app_name)
    remove_programs_menu_shortcut(app_name)


def audit():
    # Declaring local variables
    package_version = '1.2.0.0'

    # Getting installed software version
    if isfile(app_path):
        installed_version = get_version_from_binary(app_path)
    else :
        installed_version = None

    # Auditing software
    print("Auditing: mgp-W11ClassicMenu")
    if installed_version is None or installed_version < package_version:
        print("%%s version is incorrect (%%s)" %% (app_name, installed_version))
        return "ERROR"
    else:
        print("%%s is installed in correct version (%%s)" %% (app_name, installed_version))
        return "OK"


If you have any idea what the problem might be...
Thanks in advance
Eric
Last edited by elux on August 28, 2023 - 3:48 PM, edited 1 time.
User avatar
t.heroult
Messages: 307
Registration: December 8, 2020 - 10:13 AM

August 21, 2023 - 09:19

Good morning

In WAPT packages, generally only one "%" is used and not two.

instead of

Code: Select all

print("Copying directory: %%s to: %%s" %% (dir_name, app_dir))
I would try with

Code: Select all

print("Copying directory: %s to: %s" % (dir_name, app_dir))
Sincerely,
Tom
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
blemoigne
Messages: 178
Registration: July 17, 2020 - 11:29

August 21, 2023 - 10:54

Good morning,
Python even recommends using the following syntax now:

Code: Select all

print(f"Copying directory: {dir_name} to:  {app_dir}")
an f for "format" before the string and curly braces for each variable.

Best regards,
Bertrand
elux
Messages: 11
Registration: December 12, 2022 - 09:02

August 28, 2023 - 3:48 PM

Hello,
Yes, that solved the problem, thank you very much!
Resolved
Locked