Configurable values when Wammu assumes rest of memory is empty (thanks to Tomasz...
[wammu.git] / wammu.py
blobc334878b9b20d86ed8077fb8ec5d39ba7f15406a
1 #!/usr/bin/env python
2 # -*- coding: UTF-8 -*-
3 # vim: expandtab sw=4 ts=4 sts=4:
4 '''
5 Wammu - Phone manager
6 Execution script
7 '''
8 __author__ = 'Michal Čihař'
9 __email__ = 'michal@cihar.com'
10 __license__ = '''
11 Copyright © 2003 - 2008 Michal Čihař
13 This program is free software; you can redistribute it and/or modify it
14 under the terms of the GNU General Public License version 2 as published by
15 the Free Software Foundation.
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
20 more details.
22 You should have received a copy of the GNU General Public License along with
23 this program; if not, write to the Free Software Foundation, Inc.,
24 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 '''
27 import os
28 import sys
29 import getopt
30 import Wammu
31 import Wammu.Locales
33 # Try to import iconv_codec to allow working on chinese windows
34 try:
35 import iconv_codec
36 except ImportError:
37 pass
39 # Disable warning about missing files
40 # This can be caused by attempt to import Python modules, which don't
41 # have all DLLs satisfied.
42 if sys.platform.startswith('win'):
43 import win32api
44 import win32con
45 win32api.SetErrorMode(win32con.SEM_NOOPENFILEERRORBOX)
47 def version():
48 '''
49 Displays version information.
50 '''
51 print _('Wammu - Windowed Gammu version %s') % Wammu.__version__
53 def usage():
54 '''
55 Shows program usage.
56 '''
57 version()
58 print _('Usage: %s [OPTION...]' % os.path.basename(__file__))
59 print
60 print _('Options:')
61 print '%-20s ... %s' % (
62 '-h/--help',
63 _('show this help'))
64 print '%-20s ... %s' % (
65 '-v/--version',
66 _('show program version'))
67 print '%-20s ... %s' % (
68 '-l/--local-locales',
69 _('force using of locales from current directory rather than system ones'))
70 print
72 def parse_options():
73 '''
74 Processes program options.
75 '''
76 try:
77 opts, args = getopt.getopt(sys.argv[1:],
78 'hvl',
79 ['help', 'version', 'local-locales'])
80 except getopt.GetoptError, val:
81 usage()
82 print _('Command line parsing failed with error:')
83 print val
84 sys.exit(2)
86 if len(args) != 0:
87 usage()
88 print _('Extra unrecognized parameters passed to program')
89 sys.exit(3)
91 for opt, dummy in opts:
92 if opt in ('-l', '--local-locales'):
93 Wammu.Locales.UseLocal()
94 print _('Using local built locales!')
95 if opt in ('-h', '--help'):
96 usage()
97 sys.exit()
98 if opt in ('-v', '--version'):
99 version()
100 sys.exit()
102 if __name__ == '__main__':
103 Wammu.Locales.Init()
104 parse_options()
105 # need to be imported after locales are initialised
106 import Wammu.App
107 Wammu.App.Run()