send_sms: shabang + secrets_new
This commit is contained in:
parent
336b2eafb1
commit
a83dba0dcd
1 changed files with 6 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/bin/bash /usr/scripts/python.sh
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
|
@ -13,9 +13,7 @@ https://github.com/grengojbo/sipclients
|
|||
"""
|
||||
|
||||
import sys
|
||||
sys.path.append('/usr/scripts/gestion/secrets')
|
||||
from secrets import asterisk_sms_passwd
|
||||
sys.path.pop()
|
||||
import gestion.secrets_new as secrets
|
||||
import os
|
||||
import getpass
|
||||
import sys
|
||||
|
@ -26,10 +24,7 @@ parser.add_argument('-d', '--dst', default=None,
|
|||
help="Destinataire, peut être de la forme sip:13570. (Défaut: soi-même)")
|
||||
|
||||
# Attention: on a besoin d'importer le module sip de /usr/scripts
|
||||
# il existe déjà un module sip dans les libs python.
|
||||
# il faut donc mettre notre path, avant
|
||||
sys.path.insert(0, '/usr/scripts/')
|
||||
|
||||
# et non celui des libs python
|
||||
import lc_ldap.shortcuts
|
||||
from sip.asterisk import Manager
|
||||
|
||||
|
@ -43,7 +38,8 @@ if __name__ == '__main__':
|
|||
# rajouter @crans.org ne semble pas marcher, pourquoi ?
|
||||
own = "sip:1" + str(adh['aid'][0]) + "@crans.org"
|
||||
# TODO utiliser le vrai caller id
|
||||
# profile_manager = Profile("dbname='django' user='crans' host='pgsql.adm.crans.org'", "voip_profile")
|
||||
# profile_manager = Profile("dbname='django' user='crans' " +
|
||||
# "host='pgsql.adm.crans.org'", "voip_profile")
|
||||
# callerid = profile_manager.num_to_callerid(own)
|
||||
callerid = os.path.basename(__file__)
|
||||
caller = '"%s" <%s>' % (callerid, own)
|
||||
|
@ -52,7 +48,7 @@ if __name__ == '__main__':
|
|||
if not dst:
|
||||
dst = "sip:1" + str(adh['aid'][0])
|
||||
|
||||
ast_manager = Manager('sms', asterisk_sms_passwd)
|
||||
ast_manager = Manager('sms', secrets.get('asterisk_sms_passwd'))
|
||||
|
||||
# TODO mode hors ligne
|
||||
ast_manager.messageSend(caller, dst, sys.stdin.read())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue