コード例 #1
0
ファイル: monitor.py プロジェクト: heera-jaiswal/scripts

if __name__ == "__main__":
    # Use for debugging
    # process()
    while True:
        now = datetime.now()
        diff = (24 - now.hour) * 60 * 60 + (60 - now.minute) * 60 - now.second
        for i in range(diff + 10 * 60 * 60, 0, -1):
            print "\rSleeping for %s seconds..." % i,
            sys.stdout.flush()
            time.sleep(1)
        print
        message.Subject = ""
        message.Html = ""
        try:
            process()
        except KeyboardInterrupt:
            sys.exit()
        except:
            try:
                message.Subject = " InvoiceReport "
                message.Subject += datetime.now().strftime("%d-%m")
                message.To = "*****@*****.**"
                message.CC = "*****@*****.**"
                message.Html = "Invoice Script stopped Working"
                print "something wrong with the script"
                sender.send(message)
            except:
                print "Network problem"