-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
wammu-configure.py
executable file
·137 lines (119 loc) · 3.4 KB
/
wammu-configure.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
# Copyright © 2003 - 2018 Michal Čihař <[email protected]>
#
# This file is part of Wammu <https://wammu.eu/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
'''
Wammu - Phone manager
Execution script for configuration
'''
from __future__ import print_function
import os
import sys
import getopt
import wx
import time
import Wammu
import Wammu.GammuSettings
import Wammu.Locales
from Wammu.Locales import ugettext as _
def version():
'''
Displays version information.
'''
print((_('Wammu Configurator - Wammu and Gammu configurator version %s')
% Wammu.__version__))
def usage():
'''
Shows program usage.
'''
version()
print(_('Usage: %s [OPTION…]' % os.path.basename(__file__)))
print()
print(_('Options:'))
print('%-20s ... %s' % (
'-h/--help',
_('show this help')
))
print('%-20s ... %s' % (
'-v/--version',
_('show program version')
))
print('%-20s ... %s' % (
'-l/--local-locales',
_('force using of locales from current directory rather than system ones')
))
print()
def parse_options():
'''
Processes program options.
'''
try:
opts, args = getopt.getopt(
sys.argv[1:],
'hvl',
['help', 'version', 'local-locales']
)
except getopt.GetoptError as val:
usage()
print(_('Command line parsing failed with error:'))
print(val)
sys.exit(2)
if len(args) != 0:
usage()
print(_('Extra unrecognized parameters passed to program'))
sys.exit(3)
for opt, dummy in opts:
if opt in ('-l', '--local-locales'):
Wammu.Locales.UseLocal()
print(_('Using local built locales!'))
if opt in ('-h', '--help'):
usage()
sys.exit()
if opt in ('-v', '--version'):
version()
sys.exit()
def do_wizard():
'''
Runs configuration wizard.
'''
app = Wammu.PhoneWizard.WizardApp()
wammu_cfg = Wammu.WammuSettings.WammuConfig()
config = Wammu.GammuSettings.GammuSettings(wammu_cfg)
position = config.SelectConfig(new=True)
if position is None:
sys.exit()
result = Wammu.PhoneWizard.RunConfigureWizard(None, position)
if result is not None:
busy = wx.BusyInfo(_('Updating gammu configuration…'))
time.sleep(0.1)
wx.Yield()
config.SetConfig(
result['Position'],
result['Device'],
result['Connection'],
result['Name']
)
del busy
app.Destroy()
if __name__ == '__main__':
Wammu.Locales.Init()
parse_options()
# need to be imported after locales are initialised
import Wammu.PhoneWizard
import Wammu.WammuSettings
do_wizard()