Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Panel

Table of Contents
maxLevel3

Prerequisites

It is assumed the VSCode Plugin and uip-cli version 2.0.0 are installed.

...

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:

Image Modified

Open the file and add requests==2.28.2 (version is optional) as follows:

Code Block
titlerequirements.txt
linenumberstrue
#
# 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!

...