mirror of
https://github.com/gryf/wicd.git
synced 2026-01-30 04:15:45 +01:00
2to3 transformation
This commit is contained in:
@@ -45,7 +45,7 @@ def main(argv):
|
||||
""" Main function. """
|
||||
global ui, frame
|
||||
if len(argv) < 2:
|
||||
print 'Network id to configure is missing, aborting.'
|
||||
print('Network id to configure is missing, aborting.')
|
||||
sys.exit(1)
|
||||
|
||||
ui = urwid.curses_display.Screen()
|
||||
@@ -161,6 +161,6 @@ def run():
|
||||
|
||||
if __name__ == '__main__':
|
||||
if os.getuid() != 0:
|
||||
print "Root privileges are required to configure scripts. Exiting."
|
||||
print("Root privileges are required to configure scripts. Exiting.")
|
||||
sys.exit(0)
|
||||
main(sys.argv)
|
||||
|
||||
@@ -25,6 +25,7 @@ wicd-curses.
|
||||
import urwid
|
||||
|
||||
from wicd.translations import _
|
||||
from functools import reduce
|
||||
|
||||
|
||||
# Uses code that is towards the bottom
|
||||
@@ -185,13 +186,12 @@ class MaskingEdit(urwid.Edit):
|
||||
""" Get masked out text. """
|
||||
return self.mask_char * len(self.get_edit_text())
|
||||
|
||||
def render(self, (maxcol, ), focus=False):
|
||||
def render(self, xxx_todo_changeme, focus=False):
|
||||
"""
|
||||
Render edit widget and return canvas. Include cursor when in
|
||||
focus.
|
||||
"""
|
||||
# If we aren't masking anything ATM, then act like an Edit.
|
||||
# No problems.
|
||||
(maxcol, ) = xxx_todo_changeme
|
||||
if self.mask_mode == "off" or (self.mask_mode == 'no_focus' and focus):
|
||||
# pylint: disable-msg=E1101
|
||||
canv = self.__super.render((maxcol, ), focus)
|
||||
@@ -235,7 +235,7 @@ class TabColumns(urwid.WidgetWrap):
|
||||
column_list.append(('fixed', len(text), w))
|
||||
column_list.append(urwid.Text((attrtitle, title), align='right'))
|
||||
|
||||
self.tab_map = dict(zip(tab_str, tab_wid))
|
||||
self.tab_map = dict(list(zip(tab_str, tab_wid)))
|
||||
self.active_tab = tab_str[0]
|
||||
self.columns = urwid.Columns(column_list, dividechars=1)
|
||||
#walker = urwid.SimpleListWalker([self.columns, tab_wid[0]])
|
||||
@@ -606,7 +606,7 @@ class Dialog2(urwid.WidgetWrap):
|
||||
raise DialogExit(-1)
|
||||
if k:
|
||||
self.unhandled_key(size, k)
|
||||
except DialogExit, e:
|
||||
except DialogExit as e:
|
||||
return self.on_exit(e.args[0])
|
||||
|
||||
def on_exit(self, exitcode):
|
||||
|
||||
@@ -402,7 +402,7 @@ class WiredSettingsDialog(AdvancedSettingsDialog):
|
||||
bool(wired.GetWiredProperty('usedhcphostname'))
|
||||
)
|
||||
self.dhcp_h.set_sensitive(self.use_dhcp_h.get_state())
|
||||
self.dhcp_h.set_edit_text(unicode(dhcphname))
|
||||
self.dhcp_h.set_edit_text(str(dhcphname))
|
||||
|
||||
def save_settings(self):
|
||||
""" Save settings to disk. """
|
||||
@@ -415,7 +415,7 @@ class WiredSettingsDialog(AdvancedSettingsDialog):
|
||||
encrypt_methods[self.encryption_combo.get_focus()[1]]['type'])
|
||||
self.set_net_prop("encryption_enabled", True)
|
||||
# Make sure all required fields are filled in.
|
||||
for entry_info in encrypt_info.itervalues():
|
||||
for entry_info in encrypt_info.values():
|
||||
if entry_info[0].get_edit_text() == "" \
|
||||
and entry_info[1] == 'required':
|
||||
error(
|
||||
@@ -428,7 +428,7 @@ class WiredSettingsDialog(AdvancedSettingsDialog):
|
||||
)
|
||||
return False
|
||||
|
||||
for entry_key, entry_info in encrypt_info.iteritems():
|
||||
for entry_key, entry_info in encrypt_info.items():
|
||||
self.set_net_prop(entry_key, noneToString(entry_info[0].
|
||||
get_edit_text()))
|
||||
else:
|
||||
@@ -584,7 +584,7 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
|
||||
bool(wireless.GetWirelessProperty(networkID, 'usedhcphostname'))
|
||||
)
|
||||
self.dhcp_h.set_sensitive(self.use_dhcp_h.get_state())
|
||||
self.dhcp_h.set_edit_text(unicode(dhcphname))
|
||||
self.dhcp_h.set_edit_text(str(dhcphname))
|
||||
|
||||
def set_net_prop(self, option, value):
|
||||
""" Sets the given option to the given value for this network. """
|
||||
@@ -606,7 +606,7 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
|
||||
encrypt_methods[self.encryption_combo.get_focus()[1]]['type']
|
||||
)
|
||||
# Make sure all required fields are filled in.
|
||||
for entry_info in encrypt_info.itervalues():
|
||||
for entry_info in encrypt_info.values():
|
||||
if entry_info[0].get_edit_text() == "" \
|
||||
and entry_info[1] == 'required':
|
||||
error(
|
||||
@@ -619,7 +619,7 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
|
||||
)
|
||||
return False
|
||||
|
||||
for entry_key, entry_info in encrypt_info.iteritems():
|
||||
for entry_key, entry_info in encrypt_info.items():
|
||||
self.set_net_prop(entry_key, noneToString(entry_info[0].
|
||||
get_edit_text()))
|
||||
elif not self.encryption_chkbox.get_state() and \
|
||||
|
||||
@@ -267,8 +267,8 @@ class PrefsDialog(urwid.WidgetWrap):
|
||||
""" Load settings to be used in the dialog. """
|
||||
### General Settings
|
||||
# ComboBox does not like dbus.Strings as text markups. My fault. :/
|
||||
wless_iface = unicode(daemon.GetWirelessInterface())
|
||||
wired_iface = unicode(daemon.GetWiredInterface())
|
||||
wless_iface = str(daemon.GetWirelessInterface())
|
||||
wired_iface = str(daemon.GetWiredInterface())
|
||||
self.wless_edit.set_edit_text(wless_iface)
|
||||
self.wired_edit.set_edit_text(wired_iface)
|
||||
|
||||
@@ -312,7 +312,7 @@ class PrefsDialog(urwid.WidgetWrap):
|
||||
self.wpadrivers.append("ralink_legacy")
|
||||
self.wpadrivers.append('none')
|
||||
# Same as above with the dbus.String
|
||||
self.thedrivers = [unicode(w) for w in self.wpadrivers]
|
||||
self.thedrivers = [str(w) for w in self.wpadrivers]
|
||||
self.wpa_cbox.set_list(self.thedrivers)
|
||||
|
||||
# Pick where to begin first:
|
||||
@@ -323,7 +323,7 @@ class PrefsDialog(urwid.WidgetWrap):
|
||||
pass # It defaults to 0 anyway (I hope)
|
||||
|
||||
self.backends = daemon.GetBackendList()
|
||||
self.thebackends = [unicode(w) for w in self.backends]
|
||||
self.thebackends = [str(w) for w in self.backends]
|
||||
self.backend_cbox.set_list(self.thebackends)
|
||||
cur_backend = daemon.GetSavedBackend()
|
||||
try:
|
||||
|
||||
@@ -99,15 +99,15 @@ def wrap_exceptions(func):
|
||||
#gobject.source_remove(redraw_tag)
|
||||
loop.quit()
|
||||
ui.stop()
|
||||
print >> sys.stderr, "\n" + _('Terminated by user')
|
||||
print("\n" + _('Terminated by user'), file=sys.stderr)
|
||||
#raise
|
||||
except DBusException:
|
||||
loop.quit()
|
||||
ui.stop()
|
||||
print >> sys.stderr, "\n" + _('DBus failure! '
|
||||
print("\n" + _('DBus failure! '
|
||||
'This is most likely caused by the wicd daemon '
|
||||
'stopping while wicd-curses is running. '
|
||||
'Please restart the daemon, and then restart wicd-curses.')
|
||||
'Please restart the daemon, and then restart wicd-curses.'), file=sys.stderr)
|
||||
raise
|
||||
except:
|
||||
# Quit the loop
|
||||
@@ -231,7 +231,7 @@ def help_dialog(body):
|
||||
textT = urwid.Text(('header', _('wicd-curses help')), 'right')
|
||||
textSH = urwid.Text([
|
||||
'This is ', ('blue', 'wicd-curses-' + CURSES_REV),
|
||||
' using wicd ', unicode(daemon.Hello()), '\n'
|
||||
' using wicd ', str(daemon.Hello()), '\n'
|
||||
])
|
||||
|
||||
textH = urwid.Text([
|
||||
@@ -517,7 +517,7 @@ class WiredComboBox(ComboBox):
|
||||
dialog = InputDialog(
|
||||
('header', _('Rename wired profile')),
|
||||
7, 30,
|
||||
edit_text=unicode(self.get_selected_profile())
|
||||
edit_text=str(self.get_selected_profile())
|
||||
)
|
||||
exitcode, name = dialog.run(ui, self.parent)
|
||||
if exitcode == 0:
|
||||
@@ -1259,8 +1259,7 @@ def setup_dbus(force=True):
|
||||
try:
|
||||
dbusmanager.connect_to_dbus()
|
||||
except DBusException:
|
||||
print >> sys.stderr, \
|
||||
_("Can't connect to the daemon, trying to start it automatically...")
|
||||
print(_("Can't connect to the daemon, trying to start it automatically..."), file=sys.stderr)
|
||||
|
||||
try:
|
||||
bus = dbusmanager.get_bus()
|
||||
@@ -1269,12 +1268,11 @@ def setup_dbus(force=True):
|
||||
wireless = dbus_ifaces['wireless']
|
||||
wired = dbus_ifaces['wired']
|
||||
except DBusException:
|
||||
print >> sys.stderr, \
|
||||
_("Can't automatically start the daemon, this error is fatal...")
|
||||
print(_("Can't automatically start the daemon, this error is fatal..."), file=sys.stderr)
|
||||
|
||||
if not daemon:
|
||||
print 'Error connecting to wicd via D-Bus. ' \
|
||||
'Please make sure the wicd service is running.'
|
||||
print('Error connecting to wicd via D-Bus. ' \
|
||||
'Please make sure the wicd service is running.')
|
||||
sys.exit(3)
|
||||
|
||||
netentry_curses.dbus_init(dbus_ifaces)
|
||||
@@ -1292,11 +1290,11 @@ if __name__ == '__main__':
|
||||
(CURSES_REV, daemon.Hello()),
|
||||
prog="wicd-curses"
|
||||
)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if "DBus.Error.AccessDenied" in e.get_dbus_name():
|
||||
print _('ERROR: wicd-curses was denied access to the wicd daemon: '
|
||||
print(_('ERROR: wicd-curses was denied access to the wicd daemon: '
|
||||
'please check that your user is in the "$A" group.'). \
|
||||
replace('$A', '\033[1;34m' + wpath.wicd_group + '\033[0m')
|
||||
replace('$A', '\033[1;34m' + wpath.wicd_group + '\033[0m'))
|
||||
sys.exit(1)
|
||||
else:
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user