Page 1 of 1

Session setup

Published: January 23, 2017 - 2:23 PM
by gaelds
Good morning,
I'm trying to use session_setup to copy a SketchUp plugin to the users' appdata/roaming directory. But the files are never copied when the session starts. If I manually run the command "wapt-get session-setup dst-sketchup-make", I get:

Configuring dst-sketchup-make ... Done


Here is my session_setup code in setup.py:

Code: Select all

def session_setup():
    # Copie des fichiers de l'extension SPL vers C:\Users\<USER>\AppData\Roaming\SketchUp\SketchUp 2017\SketchUp\Plugins
    if not isdir(makepath(user_appdata(),'SketchUp','SketchUp 2017','SketchUp','Plugins')):
            print('creation du dossier Plugins')
            mkdirs(makepath(user_appdata(),'SketchUp','SketchUp 2017','SketchUp','Plugins'))
    for fn in glob.glob('sketchup-stl-2.1.6/*'):
        filecopyto(fn,makepath(user_appdata(),'SketchUp','SketchUp 2017','SketchUp','Plugins'))
        print('Copie des fichiers du plugin SPL Sketchup')

Re: Session setup

Published: January 23, 2017 - 2:59 PM
by sfonteneau
Hello, as indicated in the documentation:

https://www.wapt.fr/fr/doc/CreationPaqu ... sion-setup

, with session_setup, it is not possible to access files contained within the package.

You will need to copy them beforehand to a directory.

Re: Session setup

Published: January 24, 2017 - 07:10
by gaelds
Thank you! Sorry, I hadn't read the documentation properly :oops:
To launch a program at each startup, prefer the use of a startup script contained in (shell:startup) or Startup All Users (shell:common startup), or via a local startup group policy.
Can we use the "shell:startup", "shell:Personal", etc. instructions in makepath?

Re: Session setup

Published: January 24, 2017 - 09:29
by sfonteneau
Hello

, yes, it's not very clear in the documentation, I'll redo it...

You can call `startup(1)` for the path to the startup directory for all users

, and you can call `startup(0)` for the path to the startup directory for the current user. (Only in session-setup)

The principle is therefore to copy the script you're interested in into the startup directory you're interested in.

Re: Session setup

Published: January 24, 2017 - 11:16 AM
by gaelds
So I'm having trouble copying the directory to a temporary folder. The goal is to then copy it to each user's AppData/Roaming directory during session setup. During installation, I tried copying it to a C:\tmp directory, but wapt apparently doesn't have the correct permissions.

Excerpt from install():

Code: Select all

        mkdirs(makepath('C:','tmp','sketchup-stl-2.1.6'))
        for fn in glob.glob('sketchup-stl-2.1.6/*'):
             filecopyto(fn,makepath('C:','tmp','sketchup-stl-2.1.6'))

Code: Select all

Extrait du session_setup():
        if not isdir(makepath(user_appdata(),"SketchUp","SketchUp 2017","SketchUp","Plugins")):
            mkdirs(makepath(user_appdata(),"SketchUp","SketchUp 2017","SketchUp","Plugins"))
        copytree2(makepath('C:','tmp','sketchup-stl-2.1.6'),makepath(user_appdata(),"SketchUp","SketchUp 2017","SketchUp","Plugins"))

Re: Session setup

Published: January 25, 2017 - 2:49 PM
by gaelds
Here is the error when copying to "C:\tmp" or "C:\windows\temp\":

IOError: [Errno 13] Permission denied: 'sketchup-stl-2.1.6\\sketchup-stl'

Code: Select all

        for fn in glob.glob('sketchup-stl-2.1.6/*'):
             filecopyto(fn,makepath('C:','windows','temp','sketchup-stl-2.1.6'))