2 # -*- coding: UTF-8 -*-
3 # vim: expandtab sw=4 ts=4 sts=4:
8 __author__
= 'Michal Čihař'
9 __email__
= 'michal@cihar.com'
11 Copyright © 2003 - 2010 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
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
33 # Try to import iconv_codec to allow working on chinese windows
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'):
45 win32api
.SetErrorMode(win32con
.SEM_NOOPENFILEERRORBOX
)
49 Displays version information.
51 print _('Wammu - Windowed Gammu version %s') % Wammu
.__version
__
58 print _('Usage: %s [OPTION...]' % os
.path
.basename(__file__
))
61 print '%-20s ... %s' % (
64 print '%-20s ... %s' % (
66 _('show program version'))
67 print '%-20s ... %s' % (
69 _('force using of locales from current directory rather than system ones'))
70 print '%-20s ... %s' % (
72 _('prints connection settings and tries to connect the phone'))
73 print '%-20s ... %s' % (
75 _('enables debug output to stderr'))
80 Displays configuration summary and tries to connect to phone.
82 import Wammu
.WammuSettings
86 settings
= Wammu
.WammuSettings
.WammuConfig()
87 section
= settings
.ReadInt('/Gammu/Section')
88 config
= settings
.gammu
.GetConfig(section
)
89 if config
['Connection'] == '' or config
['Device'] == '':
90 print _('Wammu is not configured!')
93 'StartInfo': settings
.ReadBool('/Gammu/StartInfo'),
94 'UseGlobalDebugFile': True,
95 'DebugFile': None, # Set on other place
96 'SyncTime': settings
.ReadBool('/Gammu/SyncTime'),
97 'Connection': config
['Connection'],
98 'LockDevice': settings
.ReadBool('/Gammu/LockDevice'),
99 'DebugLevel': 'textalldate', # Set on other place
100 'Device': config
['Device'],
101 'Model': config
['Model'],
104 # Compatibility with old Gammu versions
105 cfg
= Wammu
.Utils
.CompatConfig(cfg
)
107 print _('Wammu configuration:')
108 print '%-15s: %s' % (_('Connection'), cfg
['Connection'])
109 print '%-15s: %s' % (_('Model'), cfg
['Model'])
110 print '%-15s: %s' % (_('Device'), cfg
['Device'])
111 print _('Connecting...')
113 gammu
.SetDebugFile(sys
.stderr
)
114 gammu
.SetDebugLevel('textalldate')
115 sm
= gammu
.StateMachine()
118 print _('Getting phone information...')
119 Manufacturer
= sm
.GetManufacturer()
120 Model
= sm
.GetModel()
122 Firmware
= sm
.GetFirmware()
123 Code
= sm
.GetSecurityStatus()
124 print _('Phone infomation:')
125 print '%-15s: %s' % (_('Manufacturer'), Manufacturer
)
126 print '%-15s: %s (%s)' % (_('Model'), Model
[0], Model
[1])
127 print '%-15s: %s' % (_('IMEI'), IMEI
)
128 print '%-15s: %s' % (_('Firmware'), Firmware
[0])
130 print '%-15s: %s' % (_('Requested code'), Code
)
134 Processes program options.
137 opts
, args
= getopt
.getopt(sys
.argv
[1:],
139 ['help', 'version', 'local-locales', 'info', 'debug'])
140 except getopt
.GetoptError
, val
:
142 print _('Command line parsing failed with error:')
148 print _('Extra unrecognized parameters passed to program')
153 for opt
, dummy
in opts
:
154 if opt
in ('-l', '--local-locales'):
155 Wammu
.Locales
.UseLocal()
156 print _('Using local built locales!')
157 if opt
in ('-h', '--help'):
160 if opt
in ('-v', '--version'):
163 if opt
in ('-i', '--info'):
165 if opt
in ('-d', '--debug'):
172 if __name__
== '__main__':
175 # need to be imported after locales are initialised