Question

This is a little bit of a strange question, but I have a bunch of automation scripts (using Sikuli/Jython), that i want to run from a parent script for regression purposes. Now I also have a method of capturing exceptions that I want to log to a text file. SO here's how it currently works:

Master Script --> specific test script
              --> specific test script
              --> etc (how ever many scripts there are)

I was talking to a friend of mine, and he recommended that each script handles its own errors, and that the parent script just opens a file, makes the file location a global variable, and the child scripts just append to that file.

Basically, do I need to do anything special in python to make this possible? or is the master script basically just "touching" a file that other scripts can use.

Here is an example of the "parent script" (this does not have any code to handle errors in it, nor does it open a file, just executes the scripts)

for dirpath, dirnames, filenames in os.walk("c:\directory\to\the\scripts"):
    for filename in [f for f in filenames if f.endswith(".py")]:
        directory.append(os.path.join(dirpath, filename))
for entry in directory:
    execfile(entry)
Was it helpful?

Solution

Now I also have a method of capturing exceptions that I want to log to a text file.

Use logging. http://docs.python.org/library/logging.html

The problem has already been solved by them. No work for you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top