Commit 9b0f83fd authored by Valentin Samir's avatar Valentin Samir

[sip/asterisk/sms_daemon] Erreur via levée d'exceptions

parent efa97540
...@@ -111,14 +111,14 @@ class Sms(object): ...@@ -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()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment