From: Arkalogic S. <par...@gm...> - 2007-07-02 10:34:10
|
hi all, i'm still a newbie in python so my question (and my script) is probably looks odd. i'm not sure wether i put my question in the right place or not (if it's not appropriate then please accept my pardon) i have a script to send a string from a linux computer using my account at gmail, the script is supposed to run in the background and send email to my own account every 15 minutes. it was running great, except for one part where the process causing any application connected to the computer by remote (LAN) got freeze... but it went back to normal again once the email was sent. here's the code : #!/usr/bin/python import libgmail import os import time class sendIP: def __init__(self): self.subject = 'IP Cibitung site' self.to = 'par...@gm...' self.body = os.popen("ifconfig ppp0|grep inet").readline() self.body = "tes email python libgmail\n" self.ga = libgmail.GmailAccount("us...@gm...","pass") def action(self): self.ga.login() self.folder = self.ga.getMessagesByFolder('inbox') for self.thread in self.folder: if 'Cibitung' in self.thread.subject.split(): self.ga.trashMessage(self.thread) print "message erased" self.gmsg = libgmail.GmailComposedMessage( self.to,self.subject,self.body) self.ga.sendMessage(self.gmsg) print 'kirim pesan' if __name__ == '__main__': email = sendIP() while 1: a = os.popen('ps ax|grep -v grep|grep pppd').readline() b = os.popen('ping -c 1 209.85.147.83').readline() if a != '' and b != '': os.system('rm /cannotPingGoogle') os.system('rm /ConnectionTimeOut') print time.localtime()[3:6] try: email.action() print time.localtime()[3:6] time.sleep(900) except: os.system('touch /ConnectionTimeOut') elif a == '': os.system('/bin/bash /etc/init.d/startXL start') else: os.system('touch /cannotPingGoogle') --------------------------------------------------------------------------------------- i really don't know what cause the freezing state... so, is there anyone can help me with this issue? sorry for my bad english.... |