2 # -*- coding: UTF-8 -*-
3 # vim: expandtab sw=4 ts=4 sts=4:
5 Gammu SMS backup generator.
7 __author__
= 'Michal Čihař'
8 __email__
= 'michal@cihar.com'
10 Copyright © 2003 - 2010 Michal Čihař
12 This program is free software; you can redistribute it and/or modify it
13 under the terms of the GNU General Public License version 2 as published by
14 the Free Software Foundation.
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 # Work in both common location when this can be executed:
30 os
.chdir('tests/at-sms-encode/')
32 os
.chdir('at-sms-encode/')
34 # Numbers we're going to test
42 # Text parts we're going to test
46 'This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.',
68 def write_text(f
, text
):
70 Writes text splitted and encoded in same way as Gammu does it for SMS backups.
72 encoded
= text
.encode('UTF-16-BE').encode('HEX')
74 while len(encoded
) > 0:
75 f
.write('Text%02d = %s\n' % (line
, encoded
[:200]))
76 encoded
= encoded
[200:]
79 def generate_message(index
, folder
, coding
, smscnum
, num
, text
):
81 Generates single message file.
83 f
= file('%02d.backup' % index
, 'w')
92 f
.write('Sent = 20070605T135630\n')
93 write_text(f
, TEXTS
[text
])
98 Generates test data based on NUMBERS and TEXTS variables.
102 for smscnum
in range(len(NUMBERS
)):
103 for num
in range(len(NUMBERS
)):
104 for text
in range(len(TEXTS
)):
105 for coding
in range(len(CODINGS
)):
106 for folder
in [1, 2]:
107 generate_message(index
,
115 if __name__
== '__main__':