Page 1 of 2
[RESOLVED] Package Deployment Error
Published: March 23, 2020 - 4:02 PM
by Scud
Hello,
I've set up a WAPT server and I'm trying to deploy an .exe file with parameters sent via Python.
To be more precise, I'm deploying owncloud.exe and I've created code that automatically populates a .cfg file so users only have to enter their passwords.
In the server console, everything works fine. I can install and uninstall the program. I generate the package without any problems, BUT as soon as I deploy it to a user, I get an error.
Attached is the error message and a screenshot showing the WAPT version I'm using.
My server is running Windows Server 2012 R2 Datacenter. My
administration machine is Windows 10 Pro.
If you need me to provide my code, that's not a problem, but perhaps the error message will tell you something without overwhelming you with too much information.
Thank you in advance.
Re: Package Deployment Error
Published: March 24, 2020 - 09:23
by sfonteneau
Hello,
we are missing the setup.py file.
Could you also post the error (click on the machine with the error, click on the package with the error)? The package error is in the panel at the bottom right.
Re: Package Deployment Error
Published: March 24, 2020 - 12:13
by Scud
Hello,
Thank you for your reply.
I slightly modified my code this morning to use the latest version of Owncloud (in .msi format).
Now, the installation and uninstallation work, but my settings aren't being applied. I think it's giving me an encoding error, even though my environment and my configuration are correctly set to UTF-8.
I've attached setup.py
(and I've just added the error message as a .csv file).
The purpose of my script is to pre-fill the requested information after Owncloud installation.
That is, the username, the local storage path, and to write everything to a .cfg file in a Windows folder.
Locally, using Python with the install and remove functions, it works. But when I run it on another machine (a virtual one for now), my script doesn't seem to execute.
Thank you for your help.
Re: Package Deployment Error
Published: March 24, 2020 - 4:07 PM
by sfonteneau
When you want to interact with the user environment, you must use session_setup:
https://www.wapt.fr/fr/doc/wapt-create- ... index.html
I've reworked your code a bit:
Code: Select all
# -*- coding: utf-8 -*-
from setuphelpers import *
import os
uninstallkey = []
url_owncloud = 'https://cloud.test.fr'
def install():
print('installing frej-owncloud')
install_msi_if_needed('ownCloud-2.6.1.msi')
def session_setup():
homeowncloud = makepath(os.environ.get('HOMEPATH'),'ownCloud')
owncloud_appdata = makepath(application_data(),'ownCloud')
fichiercfg = makepath(owncloud_appdata,'owncloud.cfg')
mkdirs(homeowncloud)
mkdirs(owncloud_appdata)
inside_owncloud_file = r"""[General]
clientVersion=2.6.1 (build 12992)
confirmExternalStorage=false
newBigFolderSizeLimit=500
optionalDesktopNotifications=true
showInExplorerNavigationPane=true
useNewBigFolderSizeLimit=false
[Accounts]
version=2
0\Folders\1\localPath=c:/Users/%s/ownCloud
0\url=%s
0\http_user=%s
0\user=%s""" % (get_current_user(),url_owncloud,get_current_user(),get_current_user())
with open(fichiercfg, "w") as fichier:
fichier.write(inside_owncloud_file)
Re: Package Deployment Error
Published: March 24, 2020 - 5:08 PM
by Scud
Thanks for your reply.
Your code is much cleaner than mine, but excuse me, I've only been learning Python for two weeks.
However, I don't think it's writing the files to the right place, or even populating them.
But right now, my head's spinning, so I'm stopping coding for tonight. I'll run tests tomorrow and give you a full report.
Thanks again
Re: Package Deployment Error
Published: March 25, 2020 - 11:49
by sfonteneau
This is a session setup.
The session setup therefore starts when the session is opened.
Re: Package Deployment Error
Published: March 26, 2020 - 09:38
by Scud
Hello,
I must have made a mistake because it's not working. I replaced all my code with yours, but it's not writing anything to the .cfg file.
Regarding your code, I don't see where you define the `current_user` variable.
Since it's a known function of Wapt, I don't need to include it in the code, do I?
Similarly, for the `session_setup` variable, I'm having trouble understanding how it automatically retrieves all the variables (paths, etc.) and how it writes to the file. My code was more "raw" but easier for a beginner to understand.
Thank you for your help.
Re: Package Deployment Error
Published: March 26, 2020 - 12:50 PM
by sfonteneau
It works for me though
And at the top of the script, we import setuphelpers:
This explains why we already have a lot of things available; pyscripter offers auto-completion to help you.
For the different things to use:
- `get_current_user()` is in setuphelpers and retrieves the current user
- install_msi_if_needed is in setuphelpers, easily uninstalling an MSI
- os.environ.get('HOMEPATH') is roughly the value of %HOMEPATH%
- `makepath` is in setuphelpers, it allows you to transform this `makepath('c:','toto','tata')` into this `'c:\toto\tata'`
- mkdirs is in setuphelpers, create a folder
- url_owncloud is defined at the top of setup.py
- inside_owncloud_file represents the content of our file with the different variables (%s)
https://python.developpez.com/cours/Div ... trings.php
Re: Package Deployment Error
Published: March 26, 2020 - 3:19 PM
by Scud
I just ran another test.
I deleted the package from my private repository (and realized that if you keep the same name, you have to delete it as many times as you added it).
Once it was empty, I recreated a package using your code. Same result. Owncloud installs and uninstalls without any problems.
However, I close the session (or even restart) and don't create a folder, so I don't populate the .cfg file.
Re: Package Deployment Error
Published: March 26, 2020 - 3:22 PM
by sfonteneau
In a command prompt you can execute:
Code: Select all
wapt-get session-setup nomdevotrepaquet -f