Installing Apache

Apache is the most popular web server on the Internet. It is available for multiple operating systems, including Windows and Linux. Although Apache itself is extremely customizable, the installation of the web server is fairly straightforward. Although the examples in this chapter are all based on Windows including the installs , installation on Linux UNIX is fairly straightforward, and the instructions here can still be used as a basic guide to the order of install steps. Note also that the...

Modules 1

For this application, there are two modules, the snapshot module the main program and the snapshothelper module. In addition to being the main program that users will run, the snapshot module also contains the code for displaying the menu and responding to user selections. Table 2-1 shows the function used in the snapshot module. Displays a menu and receives a user selection through keyboard input returns the selection to the calling program The snapshothelper module contains the functions that...

writeCSVLogname phone email comment

The writeCSVLog function, as the name implies, writes an entry to the log file. Here is the code def writeCSVLog name, phone, email, comment if python_exec.find exe -1 dir_root usr local logs today row today, name, phone, email, comment writer csv.writer open dir_root feedbacklog.csv, The function definition line accepts the required parameters def writeCSVLog name, phone, email, comment It then takes the current date and formats it into a string variable, for use in the log entry today The...

The emailreq name phone email comment

The e-mail function is the main function for the program. It takes the parameters from the HTML file, sends the e-mail message, and calls the function to write to the log file. Here is the entire function def email req, name, phone, email, comment make sure the user provided all the parameters if not name and phone and email and comment return A required parameter is missing, please go back and correct the error create the message text msg n email, WEBMASTER, comment, name, phone conn...

Running the Debugger

The Python debugger can be utilized in several different ways The pdb module is the Python debugger. You can access it by importing it directly either in a script or in the Python console With the debugger module imported, you then have access to many different functions for debugging. This is especially useful if you import the module from Python's interactive interpreter, so let's look at an example of doing that now. Download the supplemental code from the website for Chapter 10. From that...

Generating an HTML Test Report

If you type 4 and press Enter to generate an HTML test report, you'll get the following screen Type the date of an existing test run and press Enter. After the report is generated, you will see the following status displayed on the screen Enter the date of the test run in the following format '01-01-2008' 01-14-2008 -- HTML Report Generated -Press Enter to continue The report is stored in the test_report_html directory under the program directory, and is saved as mm - dd-yyyy.html. In other...

Running the Python Web Server

Before you run the Python web server, you'll need to determine what port you want to run it on. It needs to be a port that isn't being used by some other program. This chapter's example uses port 8006. You will want to run the Python web server from any server that you want to monitor for HTTP response performance. To run it, you just need to open a command prompt window and navigate to the Chapter 4 application directory and type python webserver.py 8006. Notice that you need to type the name...

Downloading the WinAll Package

Python For Windows Extensions

Win32All requires that Python minimum version 2.2 already be installed on a Windows system. In a web browser, navigate to You will see the Python for Windows Extensions window shown in Figure B-14. Click the Download the Python for Windows Extensions link. Scroll down the page to the section that is shown in Figure B-15. Notice that downloads are available for versions of Python from 2.2 through 2.6. Click the appropriate link for the version of Python you have installed and you'll get a prompt...

The winserviceutil Module Manage Windows Services

Windows services are processes that run on a Windows desktop or a Windows server machine. They can be remotely started, stopped, restarted, and queried for status. To manage Windows services, there is the win32serviceutil module, found in Mark Hammond's win32all package. For information on how to get the win32all package, please see Appendix B. The following example shows how to start a service, stop a service, restart a service, or get service status through Python def service_info action,...

Testing Eib

There are several moving parts with this application, so there are several potential areas for testing The tests in this application are fairly simple and trivial. You could expand on the test suite by testing a real application, and see what issues or problems arise. This framework could even be used with the Python unittest module, which is covered in Chapter 10. Examine the XML files that are being created, to verify that the format of the files is consistent and expected. Create a suite...

The winnet Module Access Windows Networking Features

The win32net module, also part of Mark Hammond's win32all library of modules, includes many functions and constants to make the management of Windows networks easier. This module enables you to add, modify, delete, enumerate, and query for users, groups, shares, servers, and networks. The following example enumerates the users, groups, shares, and servers found on a computer. In this example, it simply searches the local machine, but it could easily be modified to enable selecting and...

Testing Internal Web Server Performance

If you type 2 at the main menu and press Enter to test internal web server performance, you'll get the following prompt WEB PERFORMANCE TESTER - INTERNAL WEBSERVER CHECK Enter the ip addresses of the web servers running the Python Webserver, seperated by spaces For example, if you had two servers running the Python web server and their IP addresses were 192.168.1.102 and 192.168.1.103, at the prompt you would type the following When I typed the preceding addresses and pressed Enter, the...

Design Tws

Plone has a basic, standard layout, as shown in Figure 8-11 taken from the plone.org website Certainly you can deviate from this basic design, but your design should still contain certain elements commonly found on all Plone sites such as the Login link and the Site Setup link . As mentioned earlier, the www.plone.org website itself is a great example of a Plone website. Two others include the following, as shown in Figure 8-12 and Figure 8-13, respectively. Discover Magazine...

Running the Program CommandLine Syntax

You can get to the program by navigating to the directory corresponding to this chapter. Once again, the files are available for download from the website www.wrox.com . To run the application, simply go to a command prompt, and from the directory on your system where the Chapter 7 program files are located, type the following python version_checker.py lt ip address gt lt applications gt Telnet is an Internet protocol used on Internet or Local Area Network LAN networks. Basically, Telnet...

The winreg Module Manipulate the Windows Registry

The Windows Registry is a database that contains program and system information and settings. Often it can be useful to access the Registry to read from it or write to it via a script. The winreg module makes this easy to do in Python. The following example queries a particular key in the Registry and outputs all the subkeys for that key list values owned by this registry key name, value, type _winreg.EnumValue explorer, i print repr name , i 1 The following is the output for this program I...

The winsound Module

The winsound module enables a script to access the sound-playing functionality of Windows platforms. It includes functions and several built-in constants. The module enables a script to play Windows system sounds or WAV files. The following example shows how to play various sounds with the winsound module import winsound print Play Windows exit sound. winsound.SND_ALIAS print Probably play Windows default sound winsound.PlaySound , winsound.SND_ALIAS print Play a message beep...

Modifying the Program Nsm

There are several ways this project could be enhanced, including the following Currently, the application saves test data by date, such that multiple runs on one day overwrite each other. You could change this behavior by having the files use a date-time stamp. You could have an option to look at test history, which takes the name of a test as input and then goes through each test run and produces a report of each result, based on the date. You could create command-line arguments so that, for...