52
52
'org.wicd.daemon.config'
53
53
)
54
54
except dbus .DBusException :
55
- print 'Error: Could not connect to the daemon. ' + \
56
- 'Please make sure it is running.'
55
+ print ( 'Error: Could not connect to the daemon. ' + \
56
+ 'Please make sure it is running.' )
57
57
sys .exit (3 )
58
58
59
59
if not daemon :
60
- print 'Error connecting to wicd via D-Bus. ' + \
61
- 'Please make sure the wicd service is running.'
60
+ print ( 'Error connecting to wicd via D-Bus. ' + \
61
+ 'Please make sure the wicd service is running.' )
62
62
sys .exit (3 )
63
63
64
64
parser = optparse .OptionParser ()
88
88
op_performed = False
89
89
90
90
if not (options .wireless or options .wired ) and not options .status :
91
- print "Please use --wireless or --wired to specify " + \
92
- "the type of connection to operate on."
91
+ print ( "Please use --wireless or --wired to specify " + \
92
+ "the type of connection to operate on." )
93
93
94
94
if options .status :
95
95
status , info = daemon .GetConnectionStatus ()
104
104
connected = False
105
105
status_msg = misc ._const_status_dict [status ]
106
106
107
- print _ ('Connection status' ) + ': ' + status_msg
107
+ print ( _ ('Connection status' ) + ': ' + status_msg )
108
108
if connected :
109
- print _ ('Connection type' ) + ': ' + conn_type
109
+ print ( _ ('Connection type' ) + ': ' + conn_type )
110
110
if status == misc .WIRELESS :
111
111
strength = daemon .FormatSignalForPrinting (info [2 ])
112
- print _ ('Connected to $A at $B (IP: $C)' ) \
112
+ print ( _ ('Connected to $A at $B (IP: $C)' ) \
113
113
.replace ('$A' , info [1 ]) \
114
114
.replace ('$B' , strength ) \
115
- .replace ('$C' , info [0 ])
116
- print _ ('Network ID: $A' ) \
117
- .replace ('$A' , info [3 ])
115
+ .replace ('$C' , info [0 ]))
116
+ print ( _ ('Network ID: $A' ) \
117
+ .replace ('$A' , info [3 ]))
118
118
else :
119
- print _ ('Connected to wired network (IP: $A)' ) \
120
- .replace ('$A' , info [0 ])
119
+ print ( _ ('Connected to wired network (IP: $A)' ) \
120
+ .replace ('$A' , info [0 ]))
121
121
else :
122
122
if status == misc .CONNECTING :
123
123
if info [0 ] == 'wired' :
124
- print _ ('Connecting to wired network.' )
124
+ print ( _ ('Connecting to wired network.' ) )
125
125
elif info [0 ] == 'wireless' :
126
- print _ ('Connecting to wireless network "$A".' ) \
127
- .replace ('$A' , info [1 ])
126
+ print ( _ ('Connecting to wireless network "$A".' ) \
127
+ .replace ('$A' , info [1 ]))
128
128
op_performed = True
129
129
130
130
# functions
131
131
def is_valid_wireless_network_id (network_id ):
132
132
""" Check if it's a valid wireless network. '"""
133
133
if not (network_id >= 0 \
134
134
and network_id < wireless .GetNumberOfNetworks ()):
135
- print 'Invalid wireless network identifier.'
135
+ print ( 'Invalid wireless network identifier.' )
136
136
sys .exit (1 )
137
137
138
138
def is_valid_wired_network_id (network_id ):
139
139
""" Check if it's a valid wired network. '"""
140
140
num = len (wired .GetWiredProfileList ())
141
141
if not (network_id < num and \
142
142
network_id >= 0 ):
143
- print 'Invalid wired network identifier.'
143
+ print ( 'Invalid wired network identifier.' )
144
144
sys .exit (4 )
145
145
146
146
def is_valid_wired_network_profile (profile_name ):
147
147
""" Check if it's a valid wired network profile. '"""
148
148
if not profile_name in wired .GetWiredProfileList ():
149
- print 'Profile of that name does not exist.'
149
+ print ( 'Profile of that name does not exist.' )
150
150
sys .exit (5 )
151
151
152
152
if options .scan and options .wireless :
@@ -161,17 +161,17 @@ def is_valid_wired_network_profile(profile_name):
161
161
162
162
if options .list_networks :
163
163
if options .wireless :
164
- print '#\t BSSID\t \t \t Channel\t ESSID'
164
+ print ( '#\t BSSID\t \t \t Channel\t ESSID' )
165
165
for network_id in range (0 , wireless .GetNumberOfNetworks ()):
166
- print '%s\t %s\t %s\t %s' % (network_id ,
166
+ print ( '%s\t %s\t %s\t %s' % (network_id ,
167
167
wireless .GetWirelessProperty (network_id , 'bssid' ),
168
168
wireless .GetWirelessProperty (network_id , 'channel' ),
169
- wireless .GetWirelessProperty (network_id , 'essid' ))
169
+ wireless .GetWirelessProperty (network_id , 'essid' )))
170
170
elif options .wired :
171
- print '#\t Profile name'
171
+ print ( '#\t Profile name' )
172
172
i = 0
173
173
for profile in wired .GetWiredProfileList ():
174
- print '%s\t %s' % (i , profile )
174
+ print ( '%s\t %s' % (i , profile ) )
175
175
i += 1
176
176
op_performed = True
177
177
@@ -184,24 +184,24 @@ def is_valid_wired_network_profile(profile_name):
184
184
network_id = wireless .GetCurrentNetworkID (0 )
185
185
is_valid_wireless_network_id (network_id )
186
186
# we're connected to a network, print IP
187
- print "IP: %s" % wireless .GetWirelessIP (0 )
187
+ print ( "IP: %s" % wireless .GetWirelessIP (0 ) )
188
188
189
- print "Essid: %s" % wireless .GetWirelessProperty (network_id , "essid" )
190
- print "Bssid: %s" % wireless .GetWirelessProperty (network_id , "bssid" )
189
+ print ( "Essid: %s" % wireless .GetWirelessProperty (network_id , "essid" ) )
190
+ print ( "Bssid: %s" % wireless .GetWirelessProperty (network_id , "bssid" ) )
191
191
if wireless .GetWirelessProperty (network_id , "encryption" ):
192
- print "Encryption: On"
193
- print "Encryption Method: %s" % \
194
- wireless .GetWirelessProperty (network_id , "encryption_method" )
192
+ print ( "Encryption: On" )
193
+ print ( "Encryption Method: %s" % \
194
+ wireless .GetWirelessProperty (network_id , "encryption_method" ))
195
195
else :
196
- print "Encryption: Off"
197
- print "Quality: %s" % \
198
- wireless .GetWirelessProperty (network_id , "quality" )
199
- print "Mode: %s" % \
200
- wireless .GetWirelessProperty (network_id , "mode" )
201
- print "Channel: %s" % \
202
- wireless .GetWirelessProperty (network_id , "channel" )
203
- print "Bit Rates: %s" % \
204
- wireless .GetWirelessProperty (network_id , "bitrates" )
196
+ print ( "Encryption: Off" )
197
+ print ( "Quality: %s" % \
198
+ wireless .GetWirelessProperty (network_id , "quality" ))
199
+ print ( "Mode: %s" % \
200
+ wireless .GetWirelessProperty (network_id , "mode" ))
201
+ print ( "Channel: %s" % \
202
+ wireless .GetWirelessProperty (network_id , "channel" ))
203
+ print ( "Bit Rates: %s" % \
204
+ wireless .GetWirelessProperty (network_id , "bitrates" ))
205
205
op_performed = True
206
206
207
207
# network properties
@@ -216,14 +216,14 @@ def is_valid_wired_network_profile(profile_name):
216
216
network_id = wireless .GetCurrentNetworkID (0 )
217
217
is_valid_wireless_network_id (network_id )
218
218
if not options .set_to :
219
- print wireless .GetWirelessProperty (network_id ,
220
- options .network_property )
219
+ print ( wireless .GetWirelessProperty (network_id ,
220
+ options .network_property ))
221
221
else :
222
222
wireless .SetWirelessProperty (network_id , \
223
223
options .network_property , options .set_to )
224
224
elif options .wired :
225
225
if not options .set_to :
226
- print wired .GetWiredProperty (options .network_property )
226
+ print ( wired .GetWiredProperty (options .network_property ) )
227
227
else :
228
228
wired .SetWiredProperty (options .network_property , options .set_to )
229
229
op_performed = True
@@ -232,13 +232,13 @@ def is_valid_wired_network_profile(profile_name):
232
232
daemon .Disconnect ()
233
233
if options .wireless :
234
234
if wireless .GetCurrentNetworkID (0 ) > - 1 :
235
- print "Disconnecting from %s on %s" % \
235
+ print ( "Disconnecting from %s on %s" % \
236
236
(wireless .GetCurrentNetwork (0 ),
237
- wireless .DetectWirelessInterface ())
237
+ wireless .DetectWirelessInterface ()))
238
238
elif options .wired :
239
239
if wired .CheckPluggedIn ():
240
- print "Disconnecting from wired connection on %s" % \
241
- wired .DetectWiredInterface ()
240
+ print ( "Disconnecting from wired connection on %s" % \
241
+ wired .DetectWiredInterface ())
242
242
op_performed = True
243
243
244
244
if options .connect :
@@ -247,16 +247,16 @@ def is_valid_wired_network_profile(profile_name):
247
247
is_valid_wireless_network_id (options .network )
248
248
name = wireless .GetWirelessProperty (options .network , 'essid' )
249
249
encryption = wireless .GetWirelessProperty (options .network , 'enctype' )
250
- print "Connecting to %s with %s on %s" % (name , encryption ,
251
- wireless .DetectWirelessInterface ())
250
+ print ( "Connecting to %s with %s on %s" % (name , encryption ,
251
+ wireless .DetectWirelessInterface ()))
252
252
wireless .ConnectWireless (options .network )
253
253
254
254
check = wireless .CheckIfWirelessConnecting
255
255
status = wireless .CheckWirelessConnectingStatus
256
256
message = wireless .CheckWirelessConnectingMessage
257
257
elif options .wired :
258
- print "Connecting to wired connection on %s" % \
259
- wired .DetectWiredInterface ()
258
+ print ( "Connecting to wired connection on %s" % \
259
+ wired .DetectWiredInterface ())
260
260
wired .ConnectWired ()
261
261
262
262
check = wired .CheckIfWiredConnecting
@@ -277,10 +277,10 @@ def is_valid_wired_network_profile(profile_name):
277
277
# the loop check
278
278
if next_ == "done" :
279
279
break
280
- print message ()
280
+ print ( message () )
281
281
last = next_
282
- print "done!"
283
- if status () != u 'done' :
282
+ print ( "done!" )
283
+ if status () != 'done' :
284
284
exit_status = 6
285
285
op_performed = True
286
286
@@ -295,12 +295,12 @@ def str_properties(prop):
295
295
if options .wireless and options .list_encryption_types :
296
296
et = misc .LoadEncryptionMethods ()
297
297
# print 'Installed encryption templates:'
298
- print '%s\t %-20s\t %s' % ('#' , 'Name' , 'Description' )
298
+ print ( '%s\t %-20s\t %s' % ('#' , 'Name' , 'Description' ) )
299
299
i = 0
300
300
for t in et :
301
- print '%s\t %-20s\t %s' % (i , t ['type' ], t ['name' ])
302
- print ' Req: %s' % str_properties (t ['required' ])
303
- print '---'
301
+ print ( '%s\t %-20s\t %s' % (i , t ['type' ], t ['name' ]) )
302
+ print ( ' Req: %s' % str_properties (t ['required' ]) )
303
+ print ( '---' )
304
304
# don't print optionals (yet)
305
305
#print ' Opt: %s' % str_properties(type['optional'])
306
306
i += 1
@@ -315,7 +315,7 @@ def str_properties(prop):
315
315
op_performed = True
316
316
317
317
if not op_performed :
318
- print "No operations performed."
318
+ print ( "No operations performed." )
319
319
320
320
sys .exit (exit_status )
321
321
0 commit comments