diff options
author | ache <ache@ache.one> | 2021-09-09 08:35:10 +0200 |
---|---|---|
committer | ache <ache@ache.one> | 2021-09-09 08:35:10 +0200 |
commit | d383d8dcde7c1b7eb344b0925ba8b58564cc69fe (patch) | |
tree | e811eb4d87d1a6404af761fe8603eb2a91c444f4 | |
parent | Last update of autoDHCP.sh (diff) |
Set autoMMS as a script
-rwxr-xr-x | autoMMS.py | 64 |
1 files changed, 33 insertions, 31 deletions
@@ -3,37 +3,39 @@ import os import binascii import sys +import time """ 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 "Text01 = " 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') -# or -# a = "00060401BEAF848C8298356F69377978793245656D6E6841416D756672443041008D928918802B33333736393132313834342F545950453D504C4D4E0086808A808F818E02EF8183687474703A2F2F3231332E3232382E322E382F6D6D732E7068703F35 -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)) - -for yeah in d: - if 'http' in yeah: - url = yeah[yeah.find('http'):] -os.system("wget \"" + url + "\" -q -O /tmp/mmsFile") +if __name__ == "__main__": + 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' + elif line.startswith('Text'): + info += line[9:-1] + if line.startswith('DateTime'): + date = line[9:-1] + time = time.strptime(date, '%Y%m%dT%H%M%S') + if info : + a = info + else: + print("Error : MMS invalide format, no data info found") + exit(2) + # a = "00060401BEAF848C82986B317844755F58374565656E6841416D756672443041008D928918802B33333635313037323235372F545950453D504C4D4E0086818A808F818E0308712383687474703A2F2F3231332E3232382E322E382F6D6D732E7068703F".encode('utf8') + # or + # a = "00060401BEAF848C8298356F69377978793245656D6E6841416D756672443041008D928918802B33333736393132313834342F545950453D504C4D4E0086808A808F818E02EF8183687474703A2F2F3231332E3232382E322E382F6D6D732E7068703F35 + 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)) + + for yeah in d: + if 'http' in yeah: + url = yeah[yeah.find('http'):] + os.system("wget \"" + url + "\" -q -O /tmp/mmsFile") |