Packs for Spark

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
fred-gie
Messages: 5
Registration: February 5, 2021 - 5:20 PM

February 8, 2021 - 11:39

Hello, I'm new to WAPT and Python

I use the Spark instant messaging client in my company, and I would like to deploy Spark using WAPT.
I created the package for version 2.9.4, installation and uninstallation which works very well.
I would also like to copy a config file into "user_appdata".
And that's where I need a helping hand.

I would like to verify that the Spark folder exists in the user's Roaming folder.
If so, I'll copy my file into it.
If not, I create the Spark folder and copy my file into it.

Here are the lines of code I created, but it doesn't work, something must be missing, but I can't see what.

Code: Select all

def session_setup():
    user_config_dir = makepath(user_appdata(),'Spark')
    Spark_Config = 'spark.properties'

     if not isdir(user_config_dir):
        mkdirs(user_config_dir)
        filecopyto (Spark_Config,user_config_dir)
    if isdir(user_config_dir):
        filecopyto (Spark_Config,user_config_dir)
Thank you in advance for your help.

WAPT Server version: 1.8.2
WAPT Agent version: 1.8.2.7334
WAPT Setup version: 1.8.2.7334
WAPT Deploy version: 1.8.2.7334
User avatar
dcardon
WAPT Expert
Messages: 1932
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

February 11, 2021 - 1:45 PM

The Python code is good, but the execution context must be taken into account. When `session_setup()` is executed, the package has already been installed, and the files are no longer available in the execution context. They must be copied to a location on the machine (for example, the Spark directory in Program Files or the WAPT persistent directory) to retrieve them when `session_setup()` is executed
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
fred-gie
Messages: 5
Registration: February 5, 2021 - 5:20 PM

February 12, 2021 - 2:52 PM

Hello and thank you for your reply.
I modified my script and now it works if I run "session-setup" from pyscripter, but not with WAPTConsole.
I have the impression that it does not execute the "session_setup" section during installation.

Here's the script if you have any ideas

Code: Select all

from setuphelpers import *

uninstallkey = []

def install():
    def vers_spark(key):
        return key['name'].replace('Spark','')
    install_exe_if_needed("spark_2_9_4-with-jre.exe",silentflags='-q',key='3057-7228-2063-7466',min_version='2.9.4',killbefore=['spark.exe'],get_version=vers_spark)
    uninstallkey.remove('3057-7228-2063-7466')

    #Copie du fichier config dans dossier d'install:
    Cpy_conf = makepath(programfiles32,'Spark')

    isdir(Cpy_conf)
    filecopyto ('spark.properties',Cpy_conf)
    copytree2 ('PHX-32.adiumemoticonset',makepath(programfiles32,'Spark','PHX-32.adiumemoticonset'))

def uninstall():
    run('"%s" -q' % makepath(programfiles32,'Spark','uninstall.exe'))


def session_setup():

    user_config_dir = makepath(user_appdata(),'Spark')
    Spark_Config = 'spark.properties'
    #Creation répertoire dans roaming et copie du fichiers config.
    if not isdir(user_config_dir):
        mkdirs(user_config_dir)
        filecopyto (Spark_Config,user_config_dir)
        copytree2 ('PHX-32.adiumemoticonset',makepath(user_appdata(),'Spark','xtra','emoticons','PHX-32.adiumemoticonset'))
    if isdir(user_config_dir):
        filecopyto (Spark_Config,user_config_dir)
        copytree2 ('PHX-32.adiumemoticonset',makepath(user_appdata(),'Spark','xtra','emoticons','PHX-32.adiumemoticonset'))

THANKS
fred-gie
Messages: 5
Registration: February 5, 2021 - 5:20 PM

February 17, 2021 - 11:32

Hello,

I'm having trouble executing the `def session_setup()` section.
It works when I test it in PyScripter, but nothing happens during installation.
code `session_setup`into the `install` , it works.
Is an argument required to force the execution of this section?

Thank you in advance for your help.

WAPT Server Debian version: 1.8.2
WAPT Agent version: 1.8.2.7334
WAPT Setup version: 1.8.2.7334
WAPT Deploy version: 1.8.2.7334
User avatar
dcardon
WAPT Expert
Messages: 1932
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

February 18, 2021 - 10:49

The session_setup() function is launched using the command wapt-get.exe session_setup ALL in the user's session.
On a standard WAPT agent installation, the command wapt-get.exe session_setup ALL is executed by default.
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
fred-gie
Messages: 5
Registration: February 5, 2021 - 5:20 PM

February 19, 2021 - 12:39

Hello, and thank you for your reply.

I rewrote the script several times, but unfortunately not everything works.

- Installing the application, uninstalling it, creating a tmp folder in the Install directory, and copying files and folders into the tmp all work.

Code: Select all

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

uninstallkey = []

def install():
    def vers_spark(key):
        return key['name'].replace('Spark','')
    install_exe_if_needed("spark_2_9_4-with-jre.exe",silentflags='-q',key='3057-7228-2063-7466',min_version='2.9.4',killbefore=['spark.exe'],get_version=vers_spark)
    uninstallkey.remove('3057-7228-2063-7466')

    #Creation du dossier tmp et copie du fichier config et répertoire smilley.
    isdir(makepath(programfiles32,'Spark'))
    mkdirs (makepath(programfiles32,'Spark','tmp'))
    filecopyto ('spark.properties', makepath(programfiles32,'Spark','tmp'))
    copytree2 ('xtra', makepath(programfiles32,'Spark','tmp','xtra'))
    if not isdir(makepath(user_appdata,'Spark')):
        mkdirs(makepath(user_appdata,'Spark'))
        filecopyto (makepath(programfiles32,'Spark','tmp','spark.properties'),makepath(user_appdata,'Spark'))
        copytree2 (makepath(programfiles32,'Spark','tmp'),makepath(user_appdata,'Spark'))
    if isdir(makepath(user_appdata,'Spark')):
        filecopyto (makepath(programfiles32,'Spark','tmp','spark.properties'),makepath(user_appdata,'Spark'))
        copytree2 (makepath(programfiles32,'Spark','tmp'),makepath(user_appdata,'Spark'))
    
 def uninstall():
    run('"%s" -q' % makepath(programfiles32,'Spark','uninstall.exe'))
Moving the contents of the tmp folder to user_appdata works locally "on my PC" via PyScripter, but does not work with the agent on the destination machine.
I modified the wapt-get.ini file on the PC in question and set loglevel=debug, but I don't have any more information on how it works.
The "if not" and "if" parts are not processed by the agent, regardless of its position in the "def install()": or "def session():" script
Is this a problem with the agent or with the script?
fred-gie
Messages: 5
Registration: February 5, 2021 - 5:20 PM

March 9, 2021 - 11:37

It works, but it's not instantaneous.
I get the impression that the installation happens in several stages, perhaps even finalizing after the PC reboots.
Locked