bg translation, thanks to "Svetoslav Stefanov" <lfu.project@gmail.com>
[wammu.git] / wammu-configure.py
blobe05f2bc7a4935e2dd80c0e13e9f039b002ba8a20
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 for configuration
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 wx
31 import time
32 import Wammu
33 import Wammu.GammuSettings
34 import Wammu.Locales
36 # Try to import iconv_codec to allow working on chinese windows
37 try:
38 import iconv_codec
39 except ImportError:
40 pass
42 def version():
43 '''
44 Displays version information.
45 '''
46 print (_('Wammu Configurator - Wammu and Gammu configurator version %s')
47 % Wammu.__version__)
49 def usage():
50 '''
51 Shows program usage.
52 '''
53 version()
54 print _('Usage: %s [OPTION...]' % os.path.basename(__file__))
55 print
56 print _('Options:')
57 print '%-20s ... %s' % (
58 '-h/--help',
59 _('show this help'))
60 print '%-20s ... %s' % (
61 '-v/--version',
62 _('show program version'))
63 print '%-20s ... %s' % (
64 '-l/--local-locales',
65 _('force using of locales from current directory rather than system ones'))
66 print
68 def parse_options():
69 '''
70 Processes program options.
71 '''
72 try:
73 opts, args = getopt.getopt(sys.argv[1:],
74 'hvl',
75 ['help', 'version', 'local-locales'])
76 except getopt.GetoptError, val:
77 usage()
78 print _('Command line parsing failed with error:')
79 print val
80 sys.exit(2)
82 if len(args) != 0:
83 usage()
84 print _('Extra unrecognized parameters passed to program')
85 sys.exit(3)
87 for opt, dummy in opts:
88 if opt in ('-l', '--local-locales'):
89 Wammu.Locales.UseLocal()
90 print _('Using local built locales!')
91 if opt in ('-h', '--help'):
92 usage()
93 sys.exit()
94 if opt in ('-v', '--version'):
95 version()
96 sys.exit()
98 def do_wizard():
99 '''
100 Runs configuration wizard.
102 app = Wammu.PhoneWizard.WizardApp()
104 wammu_cfg = Wammu.WammuSettings.WammuConfig()
106 config = Wammu.GammuSettings.GammuSettings(wammu_cfg)
108 position = config.SelectConfig(new = True)
110 if position is None:
111 sys.exit()
113 result = Wammu.PhoneWizard.RunConfigureWizard(None, position)
114 if result is not None:
115 busy = wx.BusyInfo(_('Updating gammu configuration...'))
116 time.sleep(0.1)
117 wx.Yield()
118 config.SetConfig(result['Position'],
119 result['Device'],
120 result['Connection'],
121 result['Name'])
122 del busy
123 app.Destroy()
125 if __name__ == '__main__':
126 Wammu.Locales.Init()
127 parse_options()
128 # need to be imported after locales are initialised
129 import Wammu.PhoneWizard
130 import Wammu.WammuSettings
131 do_wizard()