pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Advertising: Credit Counseling - Loans - mobile phones - Loans
Python paste-bin - collaborative debugging tool View Help

Posted by puga on Sat 3rd Nov 19:37 (modification of post by view diff)
download | new post

  1. #!/usr/bin/python
  2.  
  3. def mon_log(argerr):
  4.  
  5.     from time import localtime
  6.  
  7.     log = open("monitor.log","a")
  8.     x = localtime()
  9.     msg = "[" + str(x[0]) + "-" + str(x[1]) + "-" + str(x[2]) + " | " + str(x[3]) + ":" + str(x[4]) + ":" + str(x[5]) + "] "
  10.     if argerr == 1:
  11.         msg = msg + "Erro na escrita de saida.\n"
  12.     elif argerr == 2:
  13.         msg = msg + "Erro no envio de e-mail.\n"
  14.     log.write(msg)
  15.     log.flush()
  16.     log.close()
  17.  
  18. def mon_mail():
  19.  
  20.     data = "[" + str(x[0]) + "-" + str(x[1]) + "-" + str(x[2]) + " | " + str(x[3]) + ":" + str(x[4]) + ":" + str(x[5]) + "] "
  21.     SENDMAIL = "/usr/sbin/sendmail" # sendmail location
  22.     p = os.popen("%s -t" % SENDMAIL, "w")
  23.     p.write("Subject: ALARME: RENK ZANINI\n")
  24.     p.write("\n") # blank line separating headers from body
  25.     p.write(data + "Houve indicacao de ALARME no link de E1.\n")
  26.     sts = p.close()
  27.     if sts != 0:
  28.         mon_log(2)
  29.  
  30. from os import system
  31. from time import localtime
  32.  
  33. base = open("base","r")
  34.  
  35. while(system("asterisk -rx 'dgv show alarms 1' | grep -v  - | grep 'ALARM'  > saida") != 0):
  36.     continue
  37.     #criar quebra de laco caso exceda determinado limite e chamar funcao de log
  38.  
  39. saida = open("saida","r")
  40.  
  41. if base != saida:
  42.     mon_mail()

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me
: