Minor fixes in the code
This commit is contained in:
parent
5391d8d1dd
commit
61dc456224
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding:utf-8-*-
|
# -*- coding:utf-8-*-
|
||||||
|
|
||||||
from __future__ import print_function #print function python 2 and 3 compatible
|
from __future__ import print_function
|
||||||
|
|
||||||
import email
|
import email
|
||||||
import hashlib
|
import hashlib
|
||||||
@ -11,14 +11,13 @@ import requests
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
#This is used to import library depending on the python version used.
|
|
||||||
try:
|
try:
|
||||||
#for python 3
|
# For python 3
|
||||||
import json
|
import json
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# for python 2
|
# For python 2
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
print('Error importing lib as python3, switching to python 2 libraries')
|
print('Error importing lib as python3, switching to python 2 libraries')
|
||||||
|
|
||||||
msg_ids = {}
|
msg_ids = {}
|
||||||
|
|
||||||
@ -45,12 +44,12 @@ def send(url, user, password, msg, i=0):
|
|||||||
elif r.status_code == 402:
|
elif r.status_code == 402:
|
||||||
if i < 3:
|
if i < 3:
|
||||||
print('Trop de SMS ont été envoyés en trop peu de temps, ' +
|
print('Trop de SMS ont été envoyés en trop peu de temps, ' +
|
||||||
'le script réessayera dans 30 secondes.')
|
'le script réessayera dans 30 secondes.')
|
||||||
time.sleep(30)
|
time.sleep(30)
|
||||||
send(url, user, password, msg, i+1)
|
send(url, user, password, msg, i+1)
|
||||||
else:
|
else:
|
||||||
print('Impossible d\'envoyer le message dans la dernière minute ' +
|
print('Impossible d\'envoyer le message dans la dernière minute ' +
|
||||||
'et demie.')
|
'et demie.')
|
||||||
return False
|
return False
|
||||||
elif r.status_code == 403:
|
elif r.status_code == 403:
|
||||||
print('Identifiants incorrects ou service non activé.')
|
print('Identifiants incorrects ou service non activé.')
|
||||||
|
Loading…
Reference in New Issue
Block a user