Hi All
 
I have a mail function in my pythin code and seems like due to that I am getting this error when ever I am running the pythin code. Any idea, how to resolve this?
 
Error is = (10053, 'Software caused connection abort')
 
 
My code is
 
=============================================================================
 
"test.py"
import os
import sys
import smtplib
def df():
    """
    This function checks the Available space in each drive.
    """
    #Command for C drive df -k | grep /cygdrive/c | awk '{print $5}' | awk -F"%" '{print $1}'
    cmd = "df -k | grep cygdrive"#| grep /cygdrive/c | awk '{print $5}' | awk -F"%" '{print $1}'")
    text = ''
    try:
        f = os.popen (cmd + " 2>&1")
        text = f.readlines()
        if len(text)!=0:
            drive=[]
            for i in range(0,len(text)):
                temp = text[i].split()
                if len(temp[0])==2:
                    perct = int(temp[4].rstrip("%"))
                    if perct>=20:
                        drive.append((temp[0],perct))
            if len(drive)>0:
                sendmailTo(drive)
        retval = f.close ()
        if retval!= None:
            raise Exception(text + "\nCommand '%s' failed with return value:%d" % (command, retval))
    except Exception, ex:
        print ex
def sendmailTo(drv):
    """
    """
   
    fromaddr="[EMAIL PROTECTED]'
    toaddrs=['[EMAIL PROTECTED]','[EMAIL PROTECTED]']
    msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (fromaddr, ", ".join(toaddrs),"Test mail"))
    server = smtplib.SMTP('mail.smtpmail.com')
    print "TESTSSS"
    server.sendmail(fromaddr, toaddrs, msg)
    server.quit()
   
df()
 
 
=============================================================================
 
 
 


Thanks a lot to all in advance

====================
Thanks & Regards
CSaha

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to