[sip/sms] Indentation fail
This commit is contained in:
parent
399bf75dbe
commit
f8f4d7e9ec
2 changed files with 13 additions and 28 deletions
|
@ -66,7 +66,7 @@ class Sms(object):
|
||||||
except (socket.error, asterisk.NullRecv):
|
except (socket.error, asterisk.NullRecv):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _mkdirs(path):
|
def _mkdirs(self, path):
|
||||||
try:
|
try:
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
except OSError as exc:
|
except OSError as exc:
|
||||||
|
@ -77,18 +77,18 @@ class Sms(object):
|
||||||
def sms_delay(self, src, dst, body, user, body_type='str'):
|
def sms_delay(self, src, dst, body, user, body_type='str'):
|
||||||
if not body_type in ["str", "base64"]:
|
if not body_type in ["str", "base64"]:
|
||||||
raise EnvironmentError("body_type sould be 'str' ou 'base64' not %r" % body_type)
|
raise EnvironmentError("body_type sould be 'str' ou 'base64' not %r" % body_type)
|
||||||
date = datetime.now().strftime('%Y%m%d%H%M%S.%f')
|
date = datetime.now().strftime('%Y%m%d%H%M%S.%f')
|
||||||
path = self.sms_dir + user + '/' + date + '/'
|
path = self.sms_dir + user + '/' + date + '/'
|
||||||
self._mkdirs(path)
|
self._mkdirs(path)
|
||||||
with open(path + 'from') as f:
|
with open(path + 'from', 'w') as f:
|
||||||
f.write(src)
|
f.write(src)
|
||||||
with open(path + 'to') as f:
|
with open(path + 'to', 'w') as f:
|
||||||
f.write(dst)
|
f.write(dst)
|
||||||
with open(path + 'body') as f:
|
with open(path + 'body', 'w') as f:
|
||||||
if body_type=='str':
|
if body_type=='str':
|
||||||
f.write(body)
|
f.write(body)
|
||||||
elif body_type=='base64':
|
elif body_type=='base64':
|
||||||
f.write(base64.encodestring(body).strip())
|
f.write(base64.encodestring(body).strip())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -311,17 +311,3 @@ class Manager(object):
|
||||||
if body_type == "str":
|
if body_type == "str":
|
||||||
body = base64.encodestring(body).strip()
|
body = base64.encodestring(body).strip()
|
||||||
return self._action('messageSend', {'to':dst, 'from':src, 'base64body':body})
|
return self._action('messageSend', {'to':dst, 'from':src, 'base64body':body})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,4 +5,3 @@ from asterisk import Sms
|
||||||
if __name__ == '__main__' :
|
if __name__ == '__main__' :
|
||||||
sms=Sms('/var/spool/asterisk/sms/')
|
sms=Sms('/var/spool/asterisk/sms/')
|
||||||
sms.sms_daemon('localhost',5038,'sms','6m6lTaEOTMsyM')
|
sms.sms_daemon('localhost',5038,'sms','6m6lTaEOTMsyM')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue