
#############################################################
# README
# 09/24/12
This is a Python demo program to be run from the command line
of a PC, on either Windows or Linux.
                                    
Before running this demo,make sure that:

1) You're in a full-sized command screen
2) Python is instlled on your computer. You can get it for free
   from 'www.python.org'.
3) the following directories and files, contained in this zipfile,
   are present in your current directory. (They should be, if they
   unzipped correctly.)
                                    
        file    pyDemo.py           # main pgm, general testing
        file    CIntegrate.py       # tests embedded C pgm
        file    classPyDemo.py      # tests Python's O-O
        file    dirPyDemo.py        # tests directory handling
        file    ftpPyDemo.py        # tests ftp client
        file    httpPyDemo.py       # tests http client
        file    listPyDemo.py       # tests list handling
        file    mathdictPyDemo.py   # tests dictionary and math funct
        file    sockClientPyDemo.py # runs socket client
        file    sockServerPyDemo.py # runs socket server
        file    SQLPyDemo.py        # tests database & SQL
        file    XMLPyDemo.py        # tests xml handling

        file    C30PyIntegrate.c    # v. 30 source used by CIntegrate.py
        file    C26PyIntegrate.c    # v. 26 source used by CIntegrate.py
        file    setup.py            # setup for embedded C test
        file    pysetup.bat         # Windows: run setup for embedded C test
        file    pyDemoSocketServ.bat
                                    # Windows: run background process
                                    # 'sockServerPyDemo.py'
                                    # (Must be started in a second window)
        file    pydemo.bat          # Windows command file
          
        file    pyDemoConfig.dat    # configuration file
        file    pythonGuide.txt     # Python features cheatsheet
        file    version.obj         # Python vers. pickle file
        file    SQLdb.db            # test database for SQLPyDemo.py
        file    SQLDEPTTABLE.csv    # database input for department table
        file    SQLEMPTABLE.csv     # database input for employee table
        file    SQLUSERTABLE.csv    # database input for user table
        file    my.html             # test file to upload to website
        file    README              # this file

        dir     pyDemoSubpath
                file    pyDemoImport1.py
                file    pyDemoImport2.py
                file    __init__.py


First, some preparation:
If the 'cs' flag is set in 'pyDemo.bat', that is, 
you want to run the 'cs' test (default is, yes, you do)
IF YOU'RE ON WINDOWS, OPEN UP A SECOND COMMAND PROMPT
SO YOU CAN RUN THIS PROCESS IN THE BACKGROUND, THEN
Run: 'sockServerPyDemo.py'
THEN, IF YOU'RE IN WINDOWS, GO BACK TO YOUR FIRST COMMAND WINDOW
AND CONTINUE FROM THIS POINT.
'sockServerPyDemo.py' will run in the background
in your second window, and will lock the screen until this program
is finished.
If you're on Linux, run this program in the background by adding
the ampersand behind the command, like 'python sockServerPyDemo.py &'.
See Option 'cs' below for details about all this.

If, AND ONLY IF, you want to test how Python can call
an embedded C module  on Windows,
type in: 'pysetup.bat'

BE ADVISED THAT IT PROBABLY WON'T WORK -- YOU HAVE TO
CONFIGURE WINDOWS WITH SOME SPECIFIC VERSION OF VC++ STUFF FIRST.
THIS IS UNDER-DOCUMENTED. I DIDN'T KNOW IT WOULD BE A PROBLEM
TILL I RE-INSTALLED MY SYSTEM WITHUT VC++.

BUT IF YOU REALLY WANT TO EXPERIMENT, SEE THE LINK:
http://eggbung.blogspot.com/2010/05/setuptools-easyinstall-cant-find.html
I DON'T ADVISE YOU TO DO THIS, IF YOU'RE ON WINDOWS.
(BUT IF YOU MUST, ADD A '-c' OPTION TO YOUR COMMAND LINE.
SEE BELOW.)

ON LINUX, IT SHOULDN'T BE A PROBLEM. SO ADD THE 'c' OPTION, AND

On Linux: type in:
'del C30PyIntegrate.so' or 'del C26PyIntegrate.so',
    depending on whether you're running Python 3.0 or 2.6
'python setup.py build_ext --inplace'
and wait for it to complete.

This will run a server process that's required for the
embedded C-module integration test.
You must be sure to delete the existing 'pyd' or 'so' file
before compiling another one with 'setup.py'


Now, you're ready to test by typing in:

on Windows: 'pydemo.bat'

on Linux: 'python pyDemo.py' (with args described below)

Note that on Windows you may change command options in 'pydemo.bat',

'pydemo.bat' contains a couple of not-processed options that are
syntactically similar to options below, just to remind you.

Or, on Linux, you can add options to the command like:
'python pydemo.py -i -data', for example.

Here are the options:
                     

        -30     specifies whether you are running Python 2.6
        -26     (which also allows 2.7) or Python 3.0 (allows 3.2)
                THIS IS IMPORTANT!
                This demo will not run if option 2.6 is specified
                and you're running 3.0, or vice-versa.
                26 is the default on Windows (from the .bat file)
            
        -intro  prints out an introduction to the program
                and what it will offer. Good for first-time run

        -v      verbose. More extensive details given  on
                what we're doing. You'll probably want this.
                   
        -c      Allows us to call the C-program-test.
                To test this feature, YOU MUST RUN 'setup.py'
                BEFORE YOU RUN THIS 'pyDemo.py' TEST PROGRAM.
                (I've mentioned 'setup.py' above)
                The C-program-test ('CIntegrate.py') will
                prompt you whether you've run 'setup.py'
                or not.If you have, you'll notice that it has
                created a 'build' subdirectory and a
                shared file called 'CIntegrate.pyd' on
                Windows; it may be called 'CIntegrate.so' on
                Linux.
                If you answer 'Yes', wait for the results.
                If you answer 'No', the entire testing process
                will will end. That's OK -- this is the last
                test to run anyway.
                Default is to have this option off (no -c parm).
                See my comments above.
                                      
        -i      interactive. The default. Does the following:

                1) Gives a prompt for the user to enter 'ni' or
                something. Just a simple test.

                Note: if you want to direct the output of the
                entire test to a stream, you might want to disable
                the 'i' option. Otherwise, when you run the
                program, you'll have to rememeber that it will
                pause (twice, indefinitely) and expect you to
                enter something.

                2) Allows 'cs' option.
                This is tricky. See below

                3) Allows you to see the screen output better.
                This is actually the main reason for using it.

        -data   also types out a rather lengthly description
                of Python, my primary 'cheat sheet'.
                Probably easier just to print it out
                separately and omit this option. The file is
                called 'pythonGuide.txt'.
                Some of its contents duplicate what we are
                demonstrating here.

        -ftp    if present, imports and runs 'ftpPyDemo.py'
                which makes an ftp connection and uploads
                and downloads files. As of 09/17/12 I have
                disabled this, for security reasons.
                See 'pyDemo.py' comments on how to restore it. 
				The code 'ftpPyDemo.py' is still viewable.

        -cs     if present, imports and runs a client process
                which sends a simple message to a server
                process for processing. This is done via
                the 'socket' mechanism. It's (still) a good
                way to exchange data between processes.
                BUT:
                YOU HAVE TO START THE 'sockServerPyDemo.py'
                PROCESS IN THE BACKGROUND FOR THIS TO WORK.
                OTHERWISE, THIS ENTIRE TEST WILL HANG.
                IF YOU'RE IN WINDOWS, THEN, OPEN UP A
                SEPARATE COMMAND WINDOW BEFORE YOU RUN
                THIS DEMO!!!
                IF IN UNIX, JUST START 'sockServerPyDemo.py'
                IN THE BACKGROUND BEFORE YOU RUN THIS DEMO!
              
        Typical 2.6 session command (contents of 'pydemo.bat')
        'python pyDemo.py -i -intro -v -26 '

        Typical 3.0 session command (contents of 'pydemo.bat')
        'python pyDemo.py -i -intro -v -30 '


author: Dave Renner, dmrenne@comcast.net
date: 09/03/2011
REV:  09/24/2012
