27 lines
837 B
Python
Executable file
27 lines
837 B
Python
Executable file
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
import sys
|
|
import psycopg2
|
|
sys.path.append('/usr/scripts/gestion')
|
|
sys.path.append('/usr/scripts/')
|
|
sys.path.append('/etc/crans/secrets/')
|
|
|
|
import lc_ldap.shortcuts
|
|
|
|
try:
|
|
conn = psycopg2.connect("dbname='django' user='crans' host='pgsql.adm.crans.org'")
|
|
cur = conn.cursor()
|
|
cur.execute("""SELECT caller_id from voip_profile WHERE num='%s'""" % sys.argv[1])
|
|
caller_id = cur.fetchall()[0][0]
|
|
|
|
if caller_id == 'full_name' or caller_id == 'both':
|
|
conn=lc_ldap.shortcuts.lc_ldap_admin()
|
|
aid=int(sys.argv[1][1:])
|
|
adh=conn.search('aid=%s' % aid)[0]
|
|
sys.stdout.write('%s %s' % (adh['prenom'][0],adh['nom'][0]))
|
|
else:
|
|
sys.stdout.write(sys.argv[1])
|
|
except:
|
|
sys.stdout.write(sys.argv[1])
|