mirror of
https://github.com/gryf/wicd.git
synced 2026-01-06 22:04:19 +01:00
2to3 transformation
This commit is contained in:
@@ -120,7 +120,7 @@ def write_scripts(network, network_type, script_info):
|
||||
def main (argv):
|
||||
""" Runs the script configuration dialog. """
|
||||
if len(argv) < 2:
|
||||
print 'Network id to configure is missing, aborting.'
|
||||
print('Network id to configure is missing, aborting.')
|
||||
sys.exit(1)
|
||||
|
||||
network = argv[1]
|
||||
@@ -171,6 +171,6 @@ def main (argv):
|
||||
|
||||
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)
|
||||
|
||||
24
gtk/gui.py
24
gtk/gui.py
@@ -56,11 +56,11 @@ def setup_dbus(force=True):
|
||||
dbusmanager.connect_to_dbus()
|
||||
except DBusException:
|
||||
if force:
|
||||
print "Can't connect to the daemon, ' + \
|
||||
'trying to start it automatically..."
|
||||
print("Can't connect to the daemon, ' + \
|
||||
'trying to start it automatically...")
|
||||
if not misc.PromptToStartDaemon():
|
||||
print "Failed to find a graphical sudo program, ' + \
|
||||
'cannot continue."
|
||||
print("Failed to find a graphical sudo program, ' + \
|
||||
'cannot continue.")
|
||||
return False
|
||||
try:
|
||||
dbusmanager.connect_to_dbus()
|
||||
@@ -91,7 +91,7 @@ def handle_no_dbus(from_tray=False):
|
||||
DBUS_AVAIL = False
|
||||
if from_tray:
|
||||
return False
|
||||
print "Wicd daemon is shutting down!"
|
||||
print("Wicd daemon is shutting down!")
|
||||
error(
|
||||
None,
|
||||
_('The wicd daemon has shut down. The UI will not function '
|
||||
@@ -146,14 +146,14 @@ class WiredProfileChooser:
|
||||
wired_net_entry.profile_help.hide()
|
||||
if wired_net_entry.profile_list is not None:
|
||||
wired_profiles.set_active(0)
|
||||
print "wired profiles found"
|
||||
print("wired profiles found")
|
||||
else:
|
||||
print "no wired profiles found"
|
||||
print("no wired profiles found")
|
||||
wired_net_entry.profile_help.show()
|
||||
|
||||
response = dialog.run()
|
||||
if response == 1:
|
||||
print 'reading profile ', wired_profiles.get_active_text()
|
||||
print('reading profile ', wired_profiles.get_active_text())
|
||||
wired.ReadWiredNetworkProfile(wired_profiles.get_active_text())
|
||||
wired.ConnectWired()
|
||||
else:
|
||||
@@ -282,7 +282,7 @@ class appGui(object):
|
||||
|
||||
def create_adhoc_network(self, widget=None):
|
||||
""" Shows a dialog that creates a new adhoc network. """
|
||||
print "Starting the Ad-Hoc Network Creation Process..."
|
||||
print("Starting the Ad-Hoc Network Creation Process...")
|
||||
dialog = gtk.Dialog(
|
||||
title=_('Create an Ad-Hoc Network'),
|
||||
flags=gtk.DIALOG_MODAL,
|
||||
@@ -695,7 +695,7 @@ class appGui(object):
|
||||
wireless.SetHiddenNetworkESSID(noneToString(hidden))
|
||||
self.refresh_clicked()
|
||||
return
|
||||
print "refreshing..."
|
||||
print("refreshing...")
|
||||
self.network_list.set_sensitive(False)
|
||||
self._remove_items_from_vbox(self.network_list)
|
||||
self.wait_for_events()
|
||||
@@ -707,7 +707,7 @@ class appGui(object):
|
||||
if num_networks > 0:
|
||||
skip_never_connect = not daemon.GetShowNeverConnect()
|
||||
instruct_label.show()
|
||||
for x in xrange(0, num_networks):
|
||||
for x in range(0, num_networks):
|
||||
if skip_never_connect and \
|
||||
misc.to_bool(get_wireless_prop(x, 'never')):
|
||||
continue
|
||||
@@ -821,7 +821,7 @@ class appGui(object):
|
||||
# Make sure no entries are left blank
|
||||
if entry.chkbox_encryption.get_active():
|
||||
encryption_info = entry.encryption_info
|
||||
for entry_info in encryption_info.itervalues():
|
||||
for entry_info in encryption_info.values():
|
||||
if entry_info[0].entry.get_text() == "" and \
|
||||
entry_info[1] == 'required':
|
||||
error(
|
||||
|
||||
@@ -25,16 +25,16 @@ HAS_NOTIFY = True
|
||||
try:
|
||||
import pynotify
|
||||
if not pynotify.init("Wicd"):
|
||||
print 'Could not initalize pynotify'
|
||||
print('Could not initalize pynotify')
|
||||
HAS_NOTIFY = False
|
||||
except ImportError:
|
||||
print "Importing pynotify failed, notifications disabled."
|
||||
print("Importing pynotify failed, notifications disabled.")
|
||||
HAS_NOTIFY = False
|
||||
|
||||
print "Has notifications support", HAS_NOTIFY
|
||||
print("Has notifications support", HAS_NOTIFY)
|
||||
|
||||
if wpath.no_use_notifications:
|
||||
print 'Notifications disabled during setup.py configure'
|
||||
print('Notifications disabled during setup.py configure')
|
||||
|
||||
|
||||
def can_use_notify():
|
||||
|
||||
@@ -465,14 +465,14 @@ class WiredSettingsDialog(AdvancedSettingsDialog):
|
||||
self.chkbox_encryption.get_active()
|
||||
)
|
||||
if self.chkbox_encryption.get_active():
|
||||
print "setting encryption info..."
|
||||
print("setting encryption info...")
|
||||
encrypt_methods = self.encrypt_types
|
||||
self.set_net_prop(
|
||||
"enctype",
|
||||
encrypt_methods[self.combo_encryption.get_active()]['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].entry.get_text() == "" and \
|
||||
entry_info[1] == 'required':
|
||||
error(
|
||||
@@ -484,11 +484,11 @@ class WiredSettingsDialog(AdvancedSettingsDialog):
|
||||
)
|
||||
return False
|
||||
# Now save all the entries.
|
||||
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].entry.get_text()))
|
||||
else:
|
||||
print "no encryption specified..."
|
||||
print("no encryption specified...")
|
||||
self.set_net_prop("enctype", "None")
|
||||
AdvancedSettingsDialog.save_settings(self)
|
||||
wired.SaveWiredNetworkProfile(self.prof_name)
|
||||
@@ -682,14 +682,14 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
|
||||
# Check encryption info
|
||||
encrypt_info = self.encryption_info
|
||||
if self.chkbox_encryption.get_active():
|
||||
print "setting encryption info..."
|
||||
print("setting encryption info...")
|
||||
encrypt_methods = self.encrypt_types
|
||||
self.set_net_prop(
|
||||
"enctype",
|
||||
encrypt_methods[self.combo_encryption.get_active()]['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].entry.get_text() == "" and \
|
||||
entry_info[1] == 'required':
|
||||
error(
|
||||
@@ -701,7 +701,7 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
|
||||
)
|
||||
return False
|
||||
# Now save all the entries.
|
||||
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].entry.get_text()))
|
||||
elif not self.chkbox_encryption.get_active() and \
|
||||
@@ -710,7 +710,7 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
|
||||
error(self, _('This network requires encryption to be enabled.'))
|
||||
return False
|
||||
else:
|
||||
print "no encryption specified..."
|
||||
print("no encryption specified...")
|
||||
self.set_net_prop("enctype", "None")
|
||||
AdvancedSettingsDialog.save_settings(self)
|
||||
|
||||
@@ -861,7 +861,7 @@ class WiredNetworkEntry(NetworkEntry):
|
||||
starting_index = x
|
||||
self.combo_profile_names.set_active(starting_index)
|
||||
else:
|
||||
print "no wired profiles found"
|
||||
print("no wired profiles found")
|
||||
self.profile_help.show()
|
||||
|
||||
self.advanced_dialog = \
|
||||
@@ -942,7 +942,7 @@ class WiredNetworkEntry(NetworkEntry):
|
||||
|
||||
def remove_profile(self, widget):
|
||||
""" Remove a profile from the profile list. """
|
||||
print "removing profile"
|
||||
print("removing profile")
|
||||
profile_name = self.combo_profile_names.get_active_text()
|
||||
wired.DeleteWiredNetworkProfile(profile_name)
|
||||
self.combo_profile_names.remove_text(self.combo_profile_names.
|
||||
@@ -1010,7 +1010,7 @@ class WirelessNetworkEntry(NetworkEntry):
|
||||
self.lbl_encryption = GreyLabel()
|
||||
self.lbl_channel = GreyLabel()
|
||||
|
||||
print "ESSID : " + self.essid
|
||||
print("ESSID : " + self.essid)
|
||||
self.chkbox_autoconnect = gtk.CheckButton(
|
||||
_('Automatically connect to this network'))
|
||||
self.chkbox_neverconnect = gtk.CheckButton(
|
||||
|
||||
@@ -80,8 +80,8 @@ if not hasattr(gtk, "StatusIcon"):
|
||||
import egg.trayicon
|
||||
USE_EGG = True
|
||||
except ImportError:
|
||||
print 'Unable to load tray icon: Missing both egg.trayicon and ' + \
|
||||
'gtk.StatusIcon modules.'
|
||||
print('Unable to load tray icon: Missing both egg.trayicon and ' + \
|
||||
'gtk.StatusIcon modules.')
|
||||
ICON_AVAIL = False
|
||||
|
||||
misc.RenameProcess("wicd-client")
|
||||
@@ -101,7 +101,7 @@ def catchdbus(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
try:
|
||||
return func(*args, **kwargs)
|
||||
except DBusException, e:
|
||||
except DBusException as e:
|
||||
if e.get_dbus_name() is not None and \
|
||||
"DBus.Error.AccessDenied" in e.get_dbus_name():
|
||||
error(
|
||||
@@ -114,7 +114,7 @@ def catchdbus(func):
|
||||
#raise
|
||||
raise DBusException(e)
|
||||
else:
|
||||
print "warning: ignoring exception %s" % e
|
||||
print("warning: ignoring exception %s" % e)
|
||||
return None
|
||||
wrapper.__name__ = func.__name__
|
||||
wrapper.__module__ = func.__module__
|
||||
@@ -162,7 +162,7 @@ class TrayIcon(object):
|
||||
self.tr.toggle_wicd_gui()
|
||||
self.icon_info = self.TrayConnectionInfo(self, self.tr, animate)
|
||||
self.tr.icon_info = self.icon_info
|
||||
print 'displaytray %s' % displaytray
|
||||
print('displaytray %s' % displaytray)
|
||||
self.tr.visible(displaytray)
|
||||
|
||||
def is_embedded(self):
|
||||
@@ -263,14 +263,14 @@ class TrayIcon(object):
|
||||
self._last_bubble.clear_hints()
|
||||
self._last_bubble.update(title, details, image)
|
||||
self._last_bubble.show()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if hasattr(e, 'message') and e.message != '':
|
||||
msg = e.message
|
||||
elif hasattr(e, 'args') and len(e.args) > 0:
|
||||
msg = e.args[-1]
|
||||
else:
|
||||
msg = str(e)
|
||||
print "Exception during notification: %s" % msg
|
||||
print("Exception during notification: %s" % msg)
|
||||
|
||||
self.should_notify = False
|
||||
|
||||
@@ -386,7 +386,7 @@ class TrayIcon(object):
|
||||
elif state in (misc.SUSPENDED, misc.NOT_CONNECTED):
|
||||
self.set_not_connected_state(info)
|
||||
else:
|
||||
print 'Invalid state returned!!!'
|
||||
print('Invalid state returned!!!')
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -820,7 +820,7 @@ TX:'''))
|
||||
|
||||
if num_networks > 0:
|
||||
skip_never_connect = not daemon.GetShowNeverConnect()
|
||||
for x in xrange(0, num_networks):
|
||||
for x in range(0, num_networks):
|
||||
if skip_never_connect and \
|
||||
misc.to_bool(get_prop(x,"never")):
|
||||
continue
|
||||
@@ -1046,7 +1046,7 @@ TX:'''))
|
||||
|
||||
def usage():
|
||||
""" Print usage information. """
|
||||
print """
|
||||
print("""
|
||||
wicd %s
|
||||
wireless (and wired) connection daemon front-end.
|
||||
|
||||
@@ -1056,19 +1056,19 @@ Arguments:
|
||||
\t-h\t--help\t\tPrint this help information.
|
||||
\t-a\t--no-animate\tRun the tray without network traffic tray animations.
|
||||
\t-o\t--only-notifications\tDon't display anything except notifications.
|
||||
""" % wpath.version
|
||||
""" % wpath.version)
|
||||
|
||||
|
||||
def setup_dbus(force=True):
|
||||
""" Initialize DBus. """
|
||||
global daemon, wireless, wired, DBUS_AVAIL, lost_dbus_id
|
||||
print "Connecting to daemon..."
|
||||
print("Connecting to daemon...")
|
||||
try:
|
||||
dbusmanager.connect_to_dbus()
|
||||
except DBusException:
|
||||
if force:
|
||||
print "Can't connect to the daemon, trying to start it " + \
|
||||
"automatically..."
|
||||
print("Can't connect to the daemon, trying to start it " + \
|
||||
"automatically...")
|
||||
misc.PromptToStartDaemon()
|
||||
try:
|
||||
dbusmanager.connect_to_dbus()
|
||||
@@ -1089,7 +1089,7 @@ def setup_dbus(force=True):
|
||||
wireless = dbus_ifaces['wireless']
|
||||
wired = dbus_ifaces['wired']
|
||||
DBUS_AVAIL = True
|
||||
print "Connected."
|
||||
print("Connected.")
|
||||
return True
|
||||
|
||||
|
||||
@@ -1107,7 +1107,7 @@ def handle_no_dbus():
|
||||
global DBUS_AVAIL, lost_dbus_id
|
||||
DBUS_AVAIL = False
|
||||
gui.handle_no_dbus(from_tray=True)
|
||||
print "Wicd daemon is shutting down!"
|
||||
print("Wicd daemon is shutting down!")
|
||||
lost_dbus_id = misc.timeout_add(5,
|
||||
lambda: error(None,
|
||||
_('The wicd daemon has shut down. The UI will not function '
|
||||
@@ -1151,14 +1151,14 @@ def main(argv):
|
||||
elif opt in ('-a', '--no-animate'):
|
||||
animate = False
|
||||
elif opt in ('-o', '--only-notifications'):
|
||||
print "only displaying notifications"
|
||||
print("only displaying notifications")
|
||||
use_tray = False
|
||||
display_app = False
|
||||
else:
|
||||
usage()
|
||||
sys.exit(2)
|
||||
|
||||
print 'Loading...'
|
||||
print('Loading...')
|
||||
setup_dbus()
|
||||
atexit.register(on_exit)
|
||||
|
||||
@@ -1195,7 +1195,7 @@ def main(argv):
|
||||
)
|
||||
bus.add_signal_receiver(lambda: setup_dbus(force=False), "DaemonStarting",
|
||||
"org.wicd.daemon")
|
||||
print 'Done loading.'
|
||||
print('Done loading.')
|
||||
mainloop = gobject.MainLoop()
|
||||
mainloop.run()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user