[SOLVED] Test script locally

Share your tips or issues concerning the WAPT Console or WAPT Agent here
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
david999
Messages: 8
Registration: July 9, 2018 - 9:44 AM

July 10, 2018 - 12:12

Hello,

sorry if the answer seems obvious, but I'm a beginner in Python.
Currently, I create several packages on the WAPT server and then deploy them.
If I need to make changes, I modify the package's setup.py file on the server, then rebuild the package and redeploy it.
The problem is that during testing, I end up rebuilding the package countless times just to test a function or syntax.

Isn't there a way to execute functions from the client machine directly in setuphelpers to perform these tests?
When I try to import setuphelpers on the client machine, I get the error message: "
No module named setuphelpers".


If anyone has a solution, I'd be very grateful!

Thanks in advance.
Last edited by david999 on Jul 12, 2018 - 23:31, edited 1 time.
User avatar
htouvet
WAPT Expert
Messages: 436
Registration: March 16, 2015 - 10:48
Contact :

July 10, 2018 - 7:54 PM

See PyScripter and the test configurations:
https://www.wapt.fr/fr/doc/CreationPaqu ... index.html

Wapt has its own Python installation (=virtualenv).
Your local test environment must therefore be configured to use Wapt's virtualenv.

With PyScripter, it is very easy to test your package and the setuphelpers functions (integrated Python shell: "from setuphelpers import *").
Tranquil IT
david999
Messages: 8
Registration: July 9, 2018 - 9:44 AM

July 11, 2018 - 6:40 PM

Hello htouvet,

thank you very much for your reply.
However, I'm having trouble launching PyScripter.
After installing it on the client machine via WAPT, I can't open it. When I try to launch it, I get the error message: "
Could not load a Python engine."

I saw that a 32-bit version of Python needs to be installed for it to work with PyScripter.
https://github.com/pyscripter/pyscripte ... nstall.txt

I also saw a workaround by adding a batch file to the PyScripter executable folder:
https://groups.google.com/forum/#!topic ... BbYQSCO0uQ

The batch file contains:
SET PYTHONHOME=C:\Python27
PyScripter --PYTHON27 --PYTHONDLLPATH "C:\Python27"

Despite this, I still can't open PyScripter.
According to the error message "Could not open DLL file: Error 193", this appears to be an architecture issue incompatible with the DLL.
The machine is running Windows 7 64-bit.
Do I need to download a specific Python27.dll file? And if so, where can I find it?


Thank you in advance for your help.

David
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

July 11, 2018 - 6:53 PM

You need to launch PyScripter through Wapt.

Right-click on a package and select Edit.

Alternatively, use the "Package Builder Wizard" from the console.

Or, open an existing PsProj file with C:\Program Files (x86)\wapt\waptpyscripter.bat.
In PyScripter, go to Project > Open Project > Open PsProj.
david999
Messages: 8
Registration: July 9, 2018 - 9:44 AM

July 11, 2018 - 7:36 PM

Hello,

thank you for this information.
I can now open the psproj file of the package in question from PyScripter.
However, when I run the code in the setup.py file, it returns the error: "
No module named setuphelpers".

In the psproj directory structure in PyScripter, I do see a setuphelpers file, but:
1. I don't know how to point to it
. 2. The setuphelpers file is empty!

Sorry, I imagine my question is very basic and simple, but I'm not sure how to proceed...


Thanks again for your help.


David
User avatar
htouvet
WAPT Expert
Messages: 436
Registration: March 16, 2015 - 10:48
Contact :

July 12, 2018 - 09:23

Hello,

Rest assured, what you're asking isn't trivial...
There are potentially two problems:
- Python environment
- Paths in the wapt.psproj file.

Python Environment:

Wapt actually has its own Python interpreter and environment (in c:\program files(x86)\wapt).
And PyScripter doesn't initially know about this environment.

If you have version 3.4.1 of PyScripter (the one in our repository), there's a function that allows you to add the path to Wapt's Python environment to PyScripter, so that all the associated libraries (including setuphelpers) are available.

the Run menu / Python Versions / Setup Python
. Click the + button and select the Wapt directory (by default, c:\program files(x86)\wapt).
In the "Unregistered Versions" list, select the Wapt folder and click the first button in the top left corner (Activate selected python version).

From there, you can test and debug without errors.

There's a button (Python icon) in the PyScript toolbar to do the same thing.

Another solution is to use the Waptconsole to edit the package. When the console launches PyScript, it sets the correct environment variables and arguments so that PyScript uses the Wapt interpreter.

Alternatively, you can use the command line:
`wapt-get edit`

This does the same thing as in the console.

Paths in the wapt.psproj file:

The wapt.psproj file stores the paths (absolute in earlier versions of Wapt...) to, among other things, the wapt-get.py file.

wapt-get.py is used to test packages.

You must verify this by right-clicking on the run configuration (Run configuration), for example, "install" / Edit run configuration.

The Python script / File name: must point to the correct directory for your installation. Normally c:\Program Files (x86)\wapt, but previously it was c:\wapt).
Tranquil IT
david999
Messages: 8
Registration: July 9, 2018 - 9:44 AM

July 12, 2018 - 09:52

Hello htouvet,

a huge THANK YOU!
After adding the Wapt folder path to "Unregistered Versions" and enabling it, everything works!
I can finally run all my tests locally on my test machine.

The server solution is also interesting, but in this case, it's mainly for testing things on a specific machine.
And, indeed, the paths in the wapt.psproj file point to the old Wapt installation folder.
So I was able to change them.

Again, thank you so much for your help and all these detailed explanations!!!


Have a good day,

David
Locked