Now it's time to focus on our application code. First of all, I have added some guidelines at the beginning of this Python script as a single line or multi line comments. So that you have SCAP is basic functions and syntax at hand. However, you can go ahead and delete these comments in your application if you don't want this to clutter your code. Nevertheless, you should read the rest of the comments inside the script, and even add your own comments in order to be able to return to your code one year from now and still understand what each line of code does. Also remember that you can download the entire application code at the end of this course section and follow the videos or just write the code yourself while I'm going to analyze it line by line.
Either way, let's start the analysis. After the introductory part of the script containing some references on scampi, we have to import the necessary modules as always, so we're going to need the logging Sub process sees and date time built in modules. And from within the time, we only need the date time class. So notice that we are using various ways to import either an entire module using the import statement, or just some functionality from within a certain module using from import. Next, remember those annoying messages that Skippy throws when starting it from the Linux terminal. Let me show you again what I mean.
So sudo scampi by THON, okay, so these messages right here, of course, we don't want those messages to appear in the output of our network application. So we should suppress any log messages to have a clean output. For that we need these lines of code right here, using the get logger and set level methods from within the logging module. I haven't come up with these lines of code myself, but I've made some basic research when I first used scampi years ago on how to suppress these warnings. This was the first solution I found at that time. And that's what I always use in my applications whenever I need to include it in the code.
So don't forget to add these lines of code when using scampi in your scripts, otherwise you will end up with a messy output. The last thing to do is to import scaffold itself. According to the official documentation, the recommended way to import scampi is to use from SCAP e dot all import asterisk instead of from SCAP e import asterisk or just the import scabies statements. This is the preferred way the recommended way you should import scampi into your code and we will go with this version. Also, if by any chance you forget to install SCAP, e before running this application, I've used a try except block to handle the import error exception in an elegant way by printing out a customized message and then quitting the program allowing you to go back and install Skippy first. Finally we're going to print out a message to the screen This one right here, reminding the user that he or she should run this application as a root in a Linux environment.
By the way, if you are using Cappy inside any of your applications, remember to use sudo in order to run that application as the root and avoid any permission related errors. Okay, that's it for now. I'll see you in the next lecture to continue our code analysis for this application.