Page 1 of 1

Packs for Spark

Published: February 8, 2021 - 11:39 AM
by fred-gie
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

Re: Packages for Spark

Published: February 11, 2021 - 1:45 PM
by dcardon
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

Re: Packages for Spark

Published: February 12, 2021 - 2:52 PM
by fred-gie
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

Re: Packages for Spark

Published: February 17, 2021 - 11:32 AM
by fred-gie
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

Re: Packages for Spark

Published: February 18, 2021 - 10:49 AM
by dcardon
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.

Re: Packages for Spark

Published: February 19, 2021 - 12:39 PM
by fred-gie
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?

Re: Packages for Spark

Published: March 9, 2021 - 11:37
by fred-gie
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.