Module AsteriskSoftHangupOldChannels
|
|
1
2 '''
3 Created on 18/12/2009
4 Programa que permite colgar llamadas de un Asterisk
5 con mas de X tiempo.
6
7 @version: 0.0.1
8 @organization: Sapian SA
9 @author: Sebastian Rojo
10 '''
11 from Asterisk.Manager import Manager
12 from Config import Config
13
14 if not Config().get_max_time_for_calls():
15 _tiempo_max_de_llamada = 3600
16 else:
17 _tiempo_max_de_llamada = Config().get_max_time_for_calls()
18
20 ''' Esta Funcion cuelga los canales colagados en un servidor asterisk'''
21 datos_de_configuracion = Config().get_connection()
22 pbx = Manager(*datos_de_configuracion)
23 print "se conctara conel servidor asterisk" , datos_de_configuracion[0]
24 result = pbx.Status()
25 uno = " ";
26 contador = 0;
27 for canales in result:
28 status = canales.Status()
29 tiempo_de_llamada = status.get("Seconds")
30 if type(tiempo_de_llamada) == type(uno):
31 if int(tiempo_de_llamada) > int(_tiempo_max_de_llamada):
32 if contador == 0:
33 contador = 1
34 print "hay canales con mas de ", _tiempo_max_de_llamada \
35 , "Segundos"
36 print "el canal", canales.id, "tiene ", tiempo_de_llamada, \
37 "segundos. sera colgada en este instante";
38
39 else:
40 print "el canal ", canales.id, "tiene", tiempo_de_llamada
41 else:
42 print "el canal ", canales.id, "no tiene tiempo"
43
44 if __name__ == '__main__':
45 ColgarCanalesPegados(_tiempo_max_de_llamada)
46 pass
47