Browse Source

Minor fixes in the code

Phyks (Lucas Verney) 5 years ago
parent
commit
61dc456224
1 changed files with 9 additions and 10 deletions
  1. 9
    10
      emails_sms_free.py

+ 9
- 10
emails_sms_free.py View File

@@ -1,7 +1,7 @@
1 1
 #!/usr/bin/env python
2 2
 # -*- coding:utf-8-*-
3 3
 
4
-from __future__ import print_function #print function python 2 and 3 compatible
4
+from __future__ import print_function
5 5
 
6 6
 import email
7 7
 import hashlib
@@ -11,14 +11,13 @@ import requests
11 11
 import sys
12 12
 import time
13 13
 
14
-#This is used to import library depending on the python version used.
15 14
 try:
16
-	#for python 3
17
-	import json
15
+    # For python 3
16
+    import json
18 17
 except ImportError:
19
-	# for python 2
20
-	import simplejson as json
21
-	print('Error importing lib as python3, switching to python 2 libraries')
18
+    # For python 2
19
+    import simplejson as json
20
+    print('Error importing lib as python3, switching to python 2 libraries')
22 21
 
23 22
 msg_ids = {}
24 23
 
@@ -45,12 +44,12 @@ def send(url, user, password, msg, i=0):
45 44
         elif r.status_code == 402:
46 45
             if i < 3:
47 46
                 print('Trop de SMS ont été envoyés en trop peu de temps, ' +
48
-                    'le script réessayera dans 30 secondes.')
47
+                      'le script réessayera dans 30 secondes.')
49 48
                 time.sleep(30)
50 49
                 send(url, user, password, msg, i+1)
51 50
             else:
52 51
                 print('Impossible d\'envoyer le message dans la dernière minute ' +
53
-                    'et demie.')
52
+                      'et demie.')
54 53
                 return False
55 54
         elif r.status_code == 403:
56 55
             print('Identifiants incorrects ou service non activé.')
@@ -64,7 +63,7 @@ def send(url, user, password, msg, i=0):
64 63
 
65 64
 def get_emails(imap_server, imap_user, imap_password, inbox, uid):
66 65
     global msg_ids
67
-    
66
+
68 67
     print('Connecting to '+imap_server+'… ', end='')
69 68
     conn = imaplib.IMAP4_SSL(imap_server)
70 69
     print('Connected')