[sip/asterisk/sms_daemon] Erreur via levée d'exceptions
This commit is contained in:
parent
efa975404a
commit
9b0f83fd33
1 changed files with 4 additions and 4 deletions
|
@ -111,14 +111,14 @@ class Sms(object):
|
||||||
num = params['Peer'].split('/')[1]
|
num = params['Peer'].split('/')[1]
|
||||||
conn = psycopg2.connect(self.sql_params)
|
conn = psycopg2.connect(self.sql_params)
|
||||||
cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
|
cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
|
||||||
cur.execute('SELECT * FROM %s WHERE "user"=%%s' % self.database, (num,))
|
cur.execute('SELECT * FROM %s WHERE "user"=%%s ORDER BY "date" ASC' % self.database, (num,))
|
||||||
for sms in cur.fetchall():
|
for sms in cur.fetchall():
|
||||||
status, params = manager.messageSend(sms['from'], sms['to'], sms['body'], body_type='base64')
|
try:
|
||||||
if status == 'Success':
|
manager.messageSend(sms['from'], sms['to'], sms['body'], body_type='base64')
|
||||||
syslog.syslog("Message from %s successfully delivered to %s" % (sms['from'], sms['to']))
|
syslog.syslog("Message from %s successfully delivered to %s" % (sms['from'], sms['to']))
|
||||||
cur.execute('DELETE FROM %s WHERE id=%%s' % self.database, (sms['id'],))
|
cur.execute('DELETE FROM %s WHERE id=%%s' % self.database, (sms['id'],))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
elif status == 'Error':
|
except AsteriskError as error:
|
||||||
syslog.syslog("Message from %s to %s : %s" % (sms['from'], sms['to'], params['Message']))
|
syslog.syslog("Message from %s to %s : %s" % (sms['from'], sms['to'], params['Message']))
|
||||||
cur.close()
|
cur.close()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue