Panel | ||||
---|---|---|---|---|
|
Prerequisites
...
The following products should be installed:
- VSCode Plugin 2.0.0
- uip-cli
...
- 2.0.0
...
...
- Universal Controller
...
- 7.4.0.0
...
- Universal Agent 7.
...
- 4.0.0
...
All work will be done in a Python 3.7.16 virtual environment. Make sure the uip-cli is installed in the virtual environment.
Introduction
We will create an Extension that uses the requests
module (pure Python) and psutil
module (not pure Python as it requires C runtime).
Step 1 - Initializing the Extension
Open VSCode to an empty folder (e.g. /tmp/tutorial
) and activate the virtual environment you wish to use.
Initialize the ue-task
extension by clicking:
For this tutorial, all parameters are suitable so, just pressing 'Enter' to select the default for each parameter is sufficient.
Once initialized, you should now have a file called requirements.txt
in your working folder:
Open the file and add requests==2.28.2
(version is optional) as follows:
Code Block | ||||
---|---|---|---|---|
| ||||
# # Specify any third-party Python modules that should be bundled with the # extension. uip-cli will automatically download and bundle the modules # upon running `uip build` or `uip push`. # # Refer to https://pip.pypa.io/en/stable/reference/requirements-file-format/ # for the expected format. # requests==2.28.2 |
Step 2 - Using requests
module
Open extension.py
and modify it as follows:
...
On lines 36-40, we call requests.get
on a sample url and print the status code
Step 3 - Pushing out Extension
We are ready to test out our extension!
...
Running the Push All command internally runs the Build All command followed by the Upload All command. The Build All command will download all dependencies specified in requirements.txt
to a folder called 3pp
and package the folder in the final package archive.