Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/12/2013, 12:38
Montes28
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 13 años, 7 meses
Puntos: 6
Como evitar que se pare la ejecucion de un script

hola amigos espero me puedan ayudar, necesito que el script no deje de ejecutarse, en la imagen http://imageshack.us/photo/my-images/856/c2d5.png/ se puede observar el error, creería que esto se soluciona con una exepcion pero no se implementarla, me podrían indicar un poco

este es mi codigo

Código Python:
Ver original
  1. # -*- coding: utf-8 -*-
  2. import pyinotify
  3. import psycopg2
  4.  
  5. class EventHandler(pyinotify.ProcessEvent):
  6.  
  7.     def process_IN_CREATE(self, event):
  8.     archivo = event.name
  9.     print "Archivo:",archivo
  10.     anno=archivo[5:9]
  11.     mes=archivo[9:11]
  12.     dia=archivo[11:13]
  13.     hora=archivo[14:16]
  14.     minuto=archivo[16:18]
  15.     segundo=archivo[18:20]
  16.     ruta=event.pathname
  17.     conn = psycopg2.connect(database="python", user="postgres", password="hoe798css", host="192.168.102.6", port="5432")
  18.     #conn = psycopg2.connect(database="python", user="postgres", password="hoe798cs", host="127.0.0.1", port="5432")
  19.     print "Opened database successfully"
  20.     cur = conn.cursor()
  21.     #print "INSERT INTO prueba VALUES(6,'2004-10-19 10:23:54','" + anno + "')"
  22.     cur.execute("INSERT INTO prueba VALUES(nextval('prueba_id_seq'),'"+ anno +"-"+ mes +"-"+ dia +" "+ hora +":"+ minuto +":"+ segundo +"','http://192.168.102.8/repo_webcam/balcones-ruiz/"+ archivo + "','"+ ruta +"')");
  23.    
  24.     conn.commit()
  25.     print "Records created successfully";
  26.     conn.close()
  27.    
  28.     print archivo
  29.  
  30. wm = pyinotify.WatchManager()
  31. mask = pyinotify.IN_CREATE
  32.  
  33. handler = EventHandler()
  34. notifier = pyinotify.Notifier(wm, handler)
  35. wdd = wm.add_watch('/monitoreo/camip/guali-ruiz', mask, rec=True)
  36. notifier.loop()


Última edición por Montes28; 06/12/2013 a las 12:59