Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Putting Everything Together

00:00 Putting Everything Together. So far, your site connectivity checker project has a function that checks if a website is online, and it also has a CLI that you quickly built using the argparse module.

00:14 In this step, you’ll write the glue code—the code that will bring all of these components together and make your application work as a full-fledged command-line application. First, you’ll start by setting up the application’s main script or entry-point script.

00:29 This script will contain the main() function and some high-level code that will help you connect the CLI in the front-end with the connectivity checking functionality in the back-end.

00:40 The next step in building the app is to define the entry-point script with a suitable main() function. To do this, you’ll use the file that lives in the rpchecker package.

00:51 Including a file in a Python package enables you to run the package as an executable program using the command scene on-screen.

01:01 To start populating with code, open it in your file editor and add the code seen on-screen.

01:12 After importing read_user_cli_args() from the cli module, you define the app’s main() function. Inside main(), you’ll find a few lines of code that don’t work yet.

01:24 Here’s what the code should do after you provide the missing functionality. This line calls read_user_cli_args() to parse the command-line arguments.

01:35 The resulting Namespace object is then stored in the user_args local variable. This puts together a list of target URLs by calling a helper function that you’ll be coding in a moment. Here, you define an if statement to check if the list of URLs is empty.

01:53 If that is the case, then the if block prints an error message to the user and exits the application.

02:00 This line invokes a function, which takes a list of target URLs as an argument and runs the connectivity check over each URL. As the name points out, this function will run the connectivity check synchronously, or one after another. Again, you’ll be coding this function in a moment.

02:20 With main() in place, you can start coding the missing pieces to make it work correctly. And that’s what you’ll be doing next.

Become a Member to join the conversation.