<div dir="ltr"><div><div>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">That&#39;s why you should write an error log ;)</blockquote>

<div>&nbsp;</div>
The error log is a valid point. Is there a way to capture the error
messages that go the the terminal window or command prompt rather than
all my print statements? Can this be set up as a global thing for the
whole application rather than inside each thread?<br><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div dir="ltr"><div class="gmail_quote"><div>try:</div><div>&nbsp;&nbsp; &nbsp;put your function here</div>

<div>except:</div><div>&nbsp;&nbsp; &nbsp;print &#39;oops! an error occurred!&#39;</div></div></div></blockquote><br>
I&#39;ll probably resort to this and have done in a couple of other
occasions, but thought it was generally frowned upon! I Guess I could
do that and print out anything caught by the exception into a log and
go more specific at a later date.<br>
<br>
Cheers,<br>
<br>
Wesley Brooks<br><br>&nbsp;</div><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote"><div class="Ih2E3d">On Mon, Oct 20, 2008 at 3:30 PM, Wesley Brooks <span dir="ltr">&lt;<a href="mailto:wesbrooks@gmail.com" target="_blank">wesbrooks@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr">Unfortunately due to the nature of the program the error
has normally happened hours ago and the error message has disappeared
from the buffer of the command prompt.</div></blockquote><div><br></div></div><div>That&#39;s why you should write an error log ;)</div><div class="Ih2E3d">
<div>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div dir="ltr"><br>This is the function:<br><br>def CommandFileWriter(self, command):<br>
&nbsp; name1 = os.path.join(self.commandsdir, command + &#39;.temp&#39;)<br>
&nbsp; name2 = os.path.join(self.commandsdir, command)<br>&nbsp; comfile = open(name1, &#39;w&#39;)<br>
&nbsp; comfile.close()<br>&nbsp; if not os.path.exists(name2):<br>&nbsp;&nbsp;&nbsp; os.rename(name1, name2)<br>&nbsp; else:<br>&nbsp;&nbsp;&nbsp; os.remove(name1)<br><br>This
was the best way I could come up with doing the function. So the file
is written to the correct directory with a wrong name (so the other
program will ignore it) then it&#39;s name is changed to the correct name
with os.rename. Unfortunately I think in freak occations the other
program can read and delete the file (running on a multicore processor
system) during the rename operation. Can you suggest which errors I
should be trying to catch?</div>
</blockquote><div><br></div></div><div>I&#39;m not sure what errors to
catch, but it&#39;s always possible to use a general catchall (I&#39;m not sure
if this is particularly pythonic)</div><div><br></div><div>try:</div><div>&nbsp;&nbsp; &nbsp;put your function here</div><div>except:</div><div>&nbsp;&nbsp; &nbsp;print &#39;oops! an error occurred!&#39;</div><div><br></div><div>Or
do something besides print an error (such as write a message to a
logfile. If you include the time stamp and some other info that might
be helpful that may give you some more insight as to where the problem
is, and if it&#39;s something you can fix.)</div></blockquote>

</div></div>