aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2018-01-11 06:47:07 +0100
committerache <ache@ache.one>2018-01-11 06:47:07 +0100
commit1e40becf6fa3646c697b0474a1d659a9eec63e60 (patch)
tree6f9a9a3ce8eba1e239c4fcd37d6d32be9b31142d
parentFix a arg of the command (diff)
Init autoMMS.py
-rwxr-xr-xautoMMS.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/autoMMS.py b/autoMMS.py
new file mode 100755
index 0000000..0640889
--- /dev/null
+++ b/autoMMS.py
@@ -0,0 +1,36 @@
+#!/bin/env python
+
+import os, binascii, sys
+
+
+""" Read MMS from gammu file format"""
+
+if len(sys.argv) < 2 :
+ print("Usage : autoMMS.py [FILE]...")
+ exit(1)
+
+info = ""
+
+with open(sys.argv[1],'r') as f:
+ for line in f:
+ if "Text00 = " in line:
+ info = line[9:-1] # 9 = len('Text00 = ') ,strip the final '\n'
+
+
+if info :
+ a = info
+else:
+ print("Error : MMS invalide format, no data info found")
+ exit(2)
+
+# a = "00060401BEAF848C82986B317844755F58374565656E6841416D756672443041008D928918802B33333635313037323235372F545950453D504C4D4E0086818A808F818E0308712383687474703A2F2F3231332E3232382E322E382F6D6D732E7068703F".encode('utf8')
+b = binascii.unhexlify(a).split(b'\x00')
+c = list(map( (lambda b_: bytes(filter( (lambda x : x>0x1F and x<0x7F), b_))), b))
+d = list(map( lambda x: x.decode('utf8'), c))
+
+
+print(d)
+
+url = d[-1][2:]+d[1]
+print(url)
+os.system("wget \"" + url + "\" -N -q -o /tmp/mmsFile")