Commit 86906cc6 authored by Valentin Samir's avatar Valentin Samir

[sip] Alias dynamiques

parent 7c6a3959
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from asterisk import Profile
if __name__ == '__main__' :
if len(sys.argv)>1:
profile = Profile()
sys.stdout.write(profile.alias_to_num(sys.argv[1]))
else:
print >> sys.stderr, "Usage %s {alias}" % sys.argv[0]
......@@ -23,7 +23,7 @@ class AsteriskError(ValueError):
pass
class Profile(object):
def __init__(self, sql_params, database):
def __init__(self, sql_params=None, database=None):
self.sql_params = sql_params
self.database =database
......@@ -34,6 +34,17 @@ class Profile(object):
conn.commit()
cur.close()
conn.close()
def alias_to_num(self, alias):
try:
conn=lc_ldap.shortcuts.lc_ldap_readonly()
ret=conn.search(u"(|(uid=%(alias)s)(mailAlias=%(alias)s@crans.org)(canonicalAlias=%(alias)s@crans.org))" % {'alias' : alias})
if len(ret) == 1:
return "1" + str(ret[0]['aid'][0])
else:
return "NONE"
except:
return "NONE"
def num_to_callerid(self, num):
try:
......
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