//
archives

Python

This category contains 5 posts

Python – Terminating Threads

According to me Thread management in any language is a messy affair and probably there are a lot of examples that I have come across that illustrates how to terminate threads. Here is a very good and clean example of how to terminate threads from the main (Parent) The program also illustrates a very nice … Continue reading

Python – Redirect Stdout

There are two ways to redirect the Stdout to a file. The first technique is based on redirecting sys.sysout by assigning a writable object (such as a file object) to it. The print statements that follow will write to that object, instead of the default standard output. The drawback is that you should remember to reset sys.sysout … Continue reading

Python – Find and Replace

Here is a simple python script that would help in finding and replacing text in a file using python

Python – Monitor Process CPU using WMI

The following code lets us monitor a process running in windows using the WMI package designed for Python language. I have tested the same on multiple windows boxes and the results have been mostly accurate. Enjoy

Python – WMI

I’d probably the last person in the world to brag about this, but I am fine with it. I am building a monitoring and reporting framework using Python and wanted to measure the memory and cpu utilization along with per process cpu utilization.  Thanks to Tim Golden, most of my work was reduced. You can … Continue reading