Skip to content
This repository was archived by the owner on Apr 1, 2020. It is now read-only.

Commit 681beb1

Browse files
committed
2to3 transformation
1 parent 49523ed commit 681beb1

27 files changed

+541
-543
lines changed

.bzrignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ wicd/wpath.py
2828
dist/
2929
MANIFEST
3030
debian/
31+
.vscode/

cli/wicd-cli.py

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@
5252
'org.wicd.daemon.config'
5353
)
5454
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.')
5757
sys.exit(3)
5858

5959
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.')
6262
sys.exit(3)
6363

6464
parser = optparse.OptionParser()
@@ -88,8 +88,8 @@
8888
op_performed = False
8989

9090
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.")
9393

9494
if options.status:
9595
status, info = daemon.GetConnectionStatus()
@@ -104,49 +104,49 @@
104104
connected = False
105105
status_msg = misc._const_status_dict[status]
106106

107-
print _('Connection status') + ': ' + status_msg
107+
print(_('Connection status') + ': ' + status_msg)
108108
if connected:
109-
print _('Connection type') + ': ' + conn_type
109+
print(_('Connection type') + ': ' + conn_type)
110110
if status == misc.WIRELESS:
111111
strength = daemon.FormatSignalForPrinting(info[2])
112-
print _('Connected to $A at $B (IP: $C)') \
112+
print(_('Connected to $A at $B (IP: $C)') \
113113
.replace('$A', info[1]) \
114114
.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]))
118118
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]))
121121
else:
122122
if status == misc.CONNECTING:
123123
if info[0] == 'wired':
124-
print _('Connecting to wired network.')
124+
print(_('Connecting to wired network.'))
125125
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]))
128128
op_performed = True
129129

130130
# functions
131131
def is_valid_wireless_network_id(network_id):
132132
""" Check if it's a valid wireless network. '"""
133133
if not (network_id >= 0 \
134134
and network_id < wireless.GetNumberOfNetworks()):
135-
print 'Invalid wireless network identifier.'
135+
print('Invalid wireless network identifier.')
136136
sys.exit(1)
137137

138138
def is_valid_wired_network_id(network_id):
139139
""" Check if it's a valid wired network. '"""
140140
num = len(wired.GetWiredProfileList())
141141
if not (network_id < num and \
142142
network_id >= 0):
143-
print 'Invalid wired network identifier.'
143+
print('Invalid wired network identifier.')
144144
sys.exit(4)
145145

146146
def is_valid_wired_network_profile(profile_name):
147147
""" Check if it's a valid wired network profile. '"""
148148
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.')
150150
sys.exit(5)
151151

152152
if options.scan and options.wireless:
@@ -161,17 +161,17 @@ def is_valid_wired_network_profile(profile_name):
161161

162162
if options.list_networks:
163163
if options.wireless:
164-
print '#\tBSSID\t\t\tChannel\tESSID'
164+
print('#\tBSSID\t\t\tChannel\tESSID')
165165
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,
167167
wireless.GetWirelessProperty(network_id, 'bssid'),
168168
wireless.GetWirelessProperty(network_id, 'channel'),
169-
wireless.GetWirelessProperty(network_id, 'essid'))
169+
wireless.GetWirelessProperty(network_id, 'essid')))
170170
elif options.wired:
171-
print '#\tProfile name'
171+
print('#\tProfile name')
172172
i = 0
173173
for profile in wired.GetWiredProfileList():
174-
print '%s\t%s' % (i, profile)
174+
print('%s\t%s' % (i, profile))
175175
i += 1
176176
op_performed = True
177177

@@ -184,24 +184,24 @@ def is_valid_wired_network_profile(profile_name):
184184
network_id = wireless.GetCurrentNetworkID(0)
185185
is_valid_wireless_network_id(network_id)
186186
# we're connected to a network, print IP
187-
print "IP: %s" % wireless.GetWirelessIP(0)
187+
print("IP: %s" % wireless.GetWirelessIP(0))
188188

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"))
191191
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"))
195195
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"))
205205
op_performed = True
206206

207207
# network properties
@@ -216,14 +216,14 @@ def is_valid_wired_network_profile(profile_name):
216216
network_id = wireless.GetCurrentNetworkID(0)
217217
is_valid_wireless_network_id(network_id)
218218
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))
221221
else:
222222
wireless.SetWirelessProperty(network_id, \
223223
options.network_property, options.set_to)
224224
elif options.wired:
225225
if not options.set_to:
226-
print wired.GetWiredProperty(options.network_property)
226+
print(wired.GetWiredProperty(options.network_property))
227227
else:
228228
wired.SetWiredProperty(options.network_property, options.set_to)
229229
op_performed = True
@@ -232,13 +232,13 @@ def is_valid_wired_network_profile(profile_name):
232232
daemon.Disconnect()
233233
if options.wireless:
234234
if wireless.GetCurrentNetworkID(0) > -1:
235-
print "Disconnecting from %s on %s" % \
235+
print("Disconnecting from %s on %s" % \
236236
(wireless.GetCurrentNetwork(0),
237-
wireless.DetectWirelessInterface())
237+
wireless.DetectWirelessInterface()))
238238
elif options.wired:
239239
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())
242242
op_performed = True
243243

244244
if options.connect:
@@ -247,16 +247,16 @@ def is_valid_wired_network_profile(profile_name):
247247
is_valid_wireless_network_id(options.network)
248248
name = wireless.GetWirelessProperty(options.network, 'essid')
249249
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()))
252252
wireless.ConnectWireless(options.network)
253253

254254
check = wireless.CheckIfWirelessConnecting
255255
status = wireless.CheckWirelessConnectingStatus
256256
message = wireless.CheckWirelessConnectingMessage
257257
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())
260260
wired.ConnectWired()
261261

262262
check = wired.CheckIfWiredConnecting
@@ -277,10 +277,10 @@ def is_valid_wired_network_profile(profile_name):
277277
# the loop check
278278
if next_ == "done":
279279
break
280-
print message()
280+
print(message())
281281
last = next_
282-
print "done!"
283-
if status() != u'done':
282+
print("done!")
283+
if status() != 'done':
284284
exit_status = 6
285285
op_performed = True
286286

@@ -295,12 +295,12 @@ def str_properties(prop):
295295
if options.wireless and options.list_encryption_types:
296296
et = misc.LoadEncryptionMethods()
297297
# print 'Installed encryption templates:'
298-
print '%s\t%-20s\t%s' % ('#', 'Name', 'Description')
298+
print('%s\t%-20s\t%s' % ('#', 'Name', 'Description'))
299299
i = 0
300300
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('---')
304304
# don't print optionals (yet)
305305
#print ' Opt: %s' % str_properties(type['optional'])
306306
i += 1
@@ -315,7 +315,7 @@ def str_properties(prop):
315315
op_performed = True
316316

317317
if not op_performed:
318-
print "No operations performed."
318+
print("No operations performed.")
319319

320320
sys.exit(exit_status)
321321

curses/configscript_curses.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def main(argv):
4545
""" Main function. """
4646
global ui, frame
4747
if len(argv) < 2:
48-
print 'Network id to configure is missing, aborting.'
48+
print('Network id to configure is missing, aborting.')
4949
sys.exit(1)
5050

5151
ui = urwid.curses_display.Screen()
@@ -161,6 +161,6 @@ def run():
161161

162162
if __name__ == '__main__':
163163
if os.getuid() != 0:
164-
print "Root privileges are required to configure scripts. Exiting."
164+
print("Root privileges are required to configure scripts. Exiting.")
165165
sys.exit(0)
166166
main(sys.argv)

curses/curses_misc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import urwid
2626

2727
from wicd.translations import _
28+
from functools import reduce
2829

2930

3031
# Uses code that is towards the bottom
@@ -185,13 +186,12 @@ def get_masked_text(self):
185186
""" Get masked out text. """
186187
return self.mask_char * len(self.get_edit_text())
187188

188-
def render(self, (maxcol, ), focus=False):
189+
def render(self, xxx_todo_changeme, focus=False):
189190
"""
190191
Render edit widget and return canvas. Include cursor when in
191192
focus.
192193
"""
193-
# If we aren't masking anything ATM, then act like an Edit.
194-
# No problems.
194+
(maxcol, ) = xxx_todo_changeme
195195
if self.mask_mode == "off" or (self.mask_mode == 'no_focus' and focus):
196196
# pylint: disable-msg=E1101
197197
canv = self.__super.render((maxcol, ), focus)
@@ -235,7 +235,7 @@ def __init__(self, tab_str, tab_wid, title, bottom_part=None,
235235
column_list.append(('fixed', len(text), w))
236236
column_list.append(urwid.Text((attrtitle, title), align='right'))
237237

238-
self.tab_map = dict(zip(tab_str, tab_wid))
238+
self.tab_map = dict(list(zip(tab_str, tab_wid)))
239239
self.active_tab = tab_str[0]
240240
self.columns = urwid.Columns(column_list, dividechars=1)
241241
#walker = urwid.SimpleListWalker([self.columns, tab_wid[0]])
@@ -606,7 +606,7 @@ def run(self, ui, parent):
606606
raise DialogExit(-1)
607607
if k:
608608
self.unhandled_key(size, k)
609-
except DialogExit, e:
609+
except DialogExit as e:
610610
return self.on_exit(e.args[0])
611611

612612
def on_exit(self, exitcode):

curses/netentry_curses.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def set_values(self):
402402
bool(wired.GetWiredProperty('usedhcphostname'))
403403
)
404404
self.dhcp_h.set_sensitive(self.use_dhcp_h.get_state())
405-
self.dhcp_h.set_edit_text(unicode(dhcphname))
405+
self.dhcp_h.set_edit_text(str(dhcphname))
406406

407407
def save_settings(self):
408408
""" Save settings to disk. """
@@ -415,7 +415,7 @@ def save_settings(self):
415415
encrypt_methods[self.encryption_combo.get_focus()[1]]['type'])
416416
self.set_net_prop("encryption_enabled", True)
417417
# Make sure all required fields are filled in.
418-
for entry_info in encrypt_info.itervalues():
418+
for entry_info in encrypt_info.values():
419419
if entry_info[0].get_edit_text() == "" \
420420
and entry_info[1] == 'required':
421421
error(
@@ -428,7 +428,7 @@ def save_settings(self):
428428
)
429429
return False
430430

431-
for entry_key, entry_info in encrypt_info.iteritems():
431+
for entry_key, entry_info in encrypt_info.items():
432432
self.set_net_prop(entry_key, noneToString(entry_info[0].
433433
get_edit_text()))
434434
else:
@@ -584,7 +584,7 @@ def set_values(self):
584584
bool(wireless.GetWirelessProperty(networkID, 'usedhcphostname'))
585585
)
586586
self.dhcp_h.set_sensitive(self.use_dhcp_h.get_state())
587-
self.dhcp_h.set_edit_text(unicode(dhcphname))
587+
self.dhcp_h.set_edit_text(str(dhcphname))
588588

589589
def set_net_prop(self, option, value):
590590
""" Sets the given option to the given value for this network. """
@@ -606,7 +606,7 @@ def save_settings(self):
606606
encrypt_methods[self.encryption_combo.get_focus()[1]]['type']
607607
)
608608
# Make sure all required fields are filled in.
609-
for entry_info in encrypt_info.itervalues():
609+
for entry_info in encrypt_info.values():
610610
if entry_info[0].get_edit_text() == "" \
611611
and entry_info[1] == 'required':
612612
error(
@@ -619,7 +619,7 @@ def save_settings(self):
619619
)
620620
return False
621621

622-
for entry_key, entry_info in encrypt_info.iteritems():
622+
for entry_key, entry_info in encrypt_info.items():
623623
self.set_net_prop(entry_key, noneToString(entry_info[0].
624624
get_edit_text()))
625625
elif not self.encryption_chkbox.get_state() and \

curses/prefs_curses.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ def load_settings(self):
267267
""" Load settings to be used in the dialog. """
268268
### General Settings
269269
# ComboBox does not like dbus.Strings as text markups. My fault. :/
270-
wless_iface = unicode(daemon.GetWirelessInterface())
271-
wired_iface = unicode(daemon.GetWiredInterface())
270+
wless_iface = str(daemon.GetWirelessInterface())
271+
wired_iface = str(daemon.GetWiredInterface())
272272
self.wless_edit.set_edit_text(wless_iface)
273273
self.wired_edit.set_edit_text(wired_iface)
274274

@@ -312,7 +312,7 @@ def find_avail(apps):
312312
self.wpadrivers.append("ralink_legacy")
313313
self.wpadrivers.append('none')
314314
# Same as above with the dbus.String
315-
self.thedrivers = [unicode(w) for w in self.wpadrivers]
315+
self.thedrivers = [str(w) for w in self.wpadrivers]
316316
self.wpa_cbox.set_list(self.thedrivers)
317317

318318
# Pick where to begin first:
@@ -323,7 +323,7 @@ def find_avail(apps):
323323
pass # It defaults to 0 anyway (I hope)
324324

325325
self.backends = daemon.GetBackendList()
326-
self.thebackends = [unicode(w) for w in self.backends]
326+
self.thebackends = [str(w) for w in self.backends]
327327
self.backend_cbox.set_list(self.thebackends)
328328
cur_backend = daemon.GetSavedBackend()
329329
try:

0 commit comments

Comments
 (0)