mirror of
https://github.com/gryf/wicd.git
synced 2025-12-19 20:38:00 +01:00
Testing/Experimental:
- Move process renaming code to the misc module, and fix process ranming for 64 bit systems. (Thanks to Helber Maciel) - Move the error gtk method to the gui module. (Thanks to Helber Maciel) - Removed a debugging print statement from monitor.py - Fixed up a few docstrings/comments. Testing: - Fix bug where Connect button would become inactive after disconnecting from a network.
This commit is contained in:
10
daemon.py
10
daemon.py
@@ -57,15 +57,7 @@ import misc
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
wpath.chdir(__file__)
|
wpath.chdir(__file__)
|
||||||
|
|
||||||
if sys.platform == 'linux2':
|
misc.RenameProcess("wicd-daemon")
|
||||||
# Set process name. Only works on Linux >= 2.1.57.
|
|
||||||
try:
|
|
||||||
import dl
|
|
||||||
libc = dl.open('/lib/libc.so.6')
|
|
||||||
libc.call('prctl', 15, 'wicd-daemon\0', 0, 0, 0) # 15 is PR_SET_NAME
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
logging_enabled = True
|
logging_enabled = True
|
||||||
|
|
||||||
|
|||||||
31
gui.py
31
gui.py
@@ -300,6 +300,15 @@ def checkboxTextboxToggle(checkbox, textboxes):
|
|||||||
for textbox in textboxes:
|
for textbox in textboxes:
|
||||||
textbox.set_sensitive(checkbox.get_active())
|
textbox.set_sensitive(checkbox.get_active())
|
||||||
|
|
||||||
|
|
||||||
|
def error(parent, message):
|
||||||
|
""" Shows an error dialog """
|
||||||
|
dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
|
||||||
|
gtk.BUTTONS_OK)
|
||||||
|
dialog.set_markup(message)
|
||||||
|
dialog.run()
|
||||||
|
dialog.destroy()
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
##### NETWORK LIST CLASSES
|
##### NETWORK LIST CLASSES
|
||||||
########################################
|
########################################
|
||||||
@@ -364,7 +373,7 @@ class AdvancedSettingsDialog(gtk.Dialog):
|
|||||||
if stringToNone(netmask.get_text()) is None: # Make sure the netmask is blank
|
if stringToNone(netmask.get_text()) is None: # Make sure the netmask is blank
|
||||||
netmask.set_text('255.255.255.0') # Fill in the most common one
|
netmask.set_text('255.255.255.0') # Fill in the most common one
|
||||||
elif ipAddress != "":
|
elif ipAddress != "":
|
||||||
misc.error(None, "Invalid IP Address Entered.")
|
error(None, "Invalid IP Address Entered.")
|
||||||
|
|
||||||
def reset_static_checkboxes(self):
|
def reset_static_checkboxes(self):
|
||||||
# Enable the right stuff
|
# Enable the right stuff
|
||||||
@@ -1517,7 +1526,7 @@ class appGui:
|
|||||||
enable_item.hide()
|
enable_item.hide()
|
||||||
disable_item.show()
|
disable_item.show()
|
||||||
else:
|
else:
|
||||||
misc.error(self.window, "Failed to enable wireless interface.")
|
error(self.window, "Failed to enable wireless interface.")
|
||||||
|
|
||||||
def on_disable_wireless(self, widget):
|
def on_disable_wireless(self, widget):
|
||||||
""" Called when the Disable Wireless Interface button is clicked. """
|
""" Called when the Disable Wireless Interface button is clicked. """
|
||||||
@@ -1528,7 +1537,7 @@ class appGui:
|
|||||||
enable_item.show()
|
enable_item.show()
|
||||||
disable_item.hide()
|
disable_item.hide()
|
||||||
else:
|
else:
|
||||||
misc.error(self.window, "Failed to disable wireless interface.")
|
error(self.window, "Failed to disable wireless interface.")
|
||||||
|
|
||||||
def on_enable_wired(self, widget):
|
def on_enable_wired(self, widget):
|
||||||
""" Called when the Enable Wired Interface button is clicked. """
|
""" Called when the Enable Wired Interface button is clicked. """
|
||||||
@@ -1539,7 +1548,7 @@ class appGui:
|
|||||||
enable_item.hide()
|
enable_item.hide()
|
||||||
disable_item.show()
|
disable_item.show()
|
||||||
else:
|
else:
|
||||||
misc.error(self.window, "Failed to enable wired interface.")
|
error(self.window, "Failed to enable wired interface.")
|
||||||
|
|
||||||
def on_disable_wired(self, widget):
|
def on_disable_wired(self, widget):
|
||||||
""" Called when the Disable Wired Interface button is clicked. """
|
""" Called when the Disable Wired Interface button is clicked. """
|
||||||
@@ -1550,7 +1559,7 @@ class appGui:
|
|||||||
enable_item.show()
|
enable_item.show()
|
||||||
disable_item.hide()
|
disable_item.hide()
|
||||||
else:
|
else:
|
||||||
misc.error(self.window, "Failed to disable wired interface.")
|
error(self.window, "Failed to disable wired interface.")
|
||||||
|
|
||||||
def cancel_connect(self, widget):
|
def cancel_connect(self, widget):
|
||||||
""" Alerts the daemon to cancel the connection process. """
|
""" Alerts the daemon to cancel the connection process. """
|
||||||
@@ -1773,8 +1782,8 @@ class appGui:
|
|||||||
|
|
||||||
for lblent in entlist:
|
for lblent in entlist:
|
||||||
if not misc.IsValidIP(lblent.get_text()):
|
if not misc.IsValidIP(lblent.get_text()):
|
||||||
misc.error(self.window, language['invalid_address'].
|
error(self.window, language['invalid_address'].
|
||||||
replace('$A', lblent.label.get_label()))
|
replace('$A', lblent.label.get_label()))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Now save the settings.
|
# Now save the settings.
|
||||||
@@ -1833,13 +1842,13 @@ class appGui:
|
|||||||
get_active()][1])
|
get_active()][1])
|
||||||
for x in encryption_info:
|
for x in encryption_info:
|
||||||
if encryption_info[x].get_text() == "":
|
if encryption_info[x].get_text() == "":
|
||||||
misc.error(self.window, language['encrypt_info_missing'])
|
error(self.window, language['encrypt_info_missing'])
|
||||||
return False
|
return False
|
||||||
entry.set_net_prop(x, noneToString(encryption_info[x].
|
entry.set_net_prop(x, noneToString(encryption_info[x].
|
||||||
get_text()))
|
get_text()))
|
||||||
elif not entry.chkbox_encryption.get_active() and \
|
elif not entry.chkbox_encryption.get_active() and \
|
||||||
wireless.GetWirelessProperty(networkid, "encryption"):
|
wireless.GetWirelessProperty(networkid, "encryption"):
|
||||||
misc.error(self.window, language['enable_encryption'])
|
error(self.window, language['enable_encryption'])
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
print 'encryption is ' + str(wireless.GetWirelessProperty(networkid,
|
print 'encryption is ' + str(wireless.GetWirelessProperty(networkid,
|
||||||
@@ -1929,12 +1938,12 @@ class appGui:
|
|||||||
encryption_info = entry.encryption_info
|
encryption_info = entry.encryption_info
|
||||||
for x in encryption_info:
|
for x in encryption_info:
|
||||||
if encryption_info[x].get_text() == "":
|
if encryption_info[x].get_text() == "":
|
||||||
misc.error(self.window, language['encrypt_info_missing'])
|
error(self.window, language['encrypt_info_missing'])
|
||||||
return False
|
return False
|
||||||
# Make sure the checkbox is checked when it should be
|
# Make sure the checkbox is checked when it should be
|
||||||
elif not entry.chkbox_encryption.get_active() and \
|
elif not entry.chkbox_encryption.get_active() and \
|
||||||
wireless.GetWirelessProperty(networkid, "encryption"):
|
wireless.GetWirelessProperty(networkid, "encryption"):
|
||||||
misc.error(self.window, language['enable_encryption'])
|
error(self.window, language['enable_encryption'])
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
23
misc.py
23
misc.py
@@ -23,7 +23,6 @@ import locale
|
|||||||
import gettext
|
import gettext
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
import gtk
|
|
||||||
from subprocess import *
|
from subprocess import *
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@@ -269,11 +268,19 @@ def to_unicode(x):
|
|||||||
ret = x.decode('utf-8', 'replace').encode('utf-8')
|
ret = x.decode('utf-8', 'replace').encode('utf-8')
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def error(parent, message):
|
def RenameProcess(new_name):
|
||||||
""" Shows an error dialog """
|
if sys.platform != 'linux2':
|
||||||
dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
|
print 'Unsupported platform'
|
||||||
gtk.BUTTONS_OK)
|
return False
|
||||||
dialog.set_markup(message)
|
try:
|
||||||
dialog.run()
|
import ctypes
|
||||||
dialog.destroy()
|
is_64 = os.path.exists('/lib64/libc.so.6')
|
||||||
|
if is_64:
|
||||||
|
libc = ctypes.CDLL('/lib64/libc.so.6')
|
||||||
|
else:
|
||||||
|
libc = ctypes.CDLL('/lib/libc.so.6')
|
||||||
|
libc.prctl(15, new_name, 0, 0, 0)
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|||||||
10
monitor.py
10
monitor.py
@@ -34,14 +34,7 @@ from dbus.mainloop.glib import DBusGMainLoop
|
|||||||
import wpath
|
import wpath
|
||||||
import misc
|
import misc
|
||||||
|
|
||||||
if sys.platform == 'linux2':
|
misc.RenameProcess("wicd-monitor")
|
||||||
# Set process name. Only works on Linux >= 2.1.57.
|
|
||||||
try:
|
|
||||||
import dl
|
|
||||||
libc = dl.open('/lib/libc.so.6')
|
|
||||||
libc.call('prctl', 15, 'wicd-monitor\0', 0, 0, 0) # 15 is PR_SET_NAME
|
|
||||||
except:
|
|
||||||
print 'Failed to set the process name'
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
wpath.chdir(__file__)
|
wpath.chdir(__file__)
|
||||||
@@ -248,7 +241,6 @@ class ConnectionStatus():
|
|||||||
self.reconnecting = True
|
self.reconnecting = True
|
||||||
daemon.SetCurrentInterface('')
|
daemon.SetCurrentInterface('')
|
||||||
|
|
||||||
print 'autoreconnect'
|
|
||||||
if daemon.ShouldAutoReconnect():
|
if daemon.ShouldAutoReconnect():
|
||||||
print 'Starting automatic reconnect process'
|
print 'Starting automatic reconnect process'
|
||||||
self.last_reconnect_time = time.time()
|
self.last_reconnect_time = time.time()
|
||||||
|
|||||||
7
setup.py
7
setup.py
@@ -19,9 +19,7 @@ from distutils.core import setup
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
data=[
|
data=[
|
||||||
('/etc/acpi/resume.d', ['other/80-wicd-connect.sh']),
|
|
||||||
('/etc/dbus-1/system.d', ['other/wicd.conf']),
|
('/etc/dbus-1/system.d', ['other/wicd.conf']),
|
||||||
('/etc/acpi/suspend.d', ['other/50-wicd-suspend.sh']),
|
|
||||||
('/usr/share/applications', ['other/hammer-00186ddbac.desktop']),
|
('/usr/share/applications', ['other/hammer-00186ddbac.desktop']),
|
||||||
('', ['launchdaemon.sh']),
|
('', ['launchdaemon.sh']),
|
||||||
('/usr/share/pixmaps', ['other/wicd.png']),
|
('/usr/share/pixmaps', ['other/wicd.png']),
|
||||||
@@ -60,6 +58,11 @@ elif os.access('/etc/arch-release', os.F_OK):
|
|||||||
elif os.access('/etc/slackware-version', os.F_OK):
|
elif os.access('/etc/slackware-version', os.F_OK):
|
||||||
data.append(('/etc/rc.d', ['other/initscripts/slackware/wicd']))
|
data.append(('/etc/rc.d', ['other/initscripts/slackware/wicd']))
|
||||||
|
|
||||||
|
# pm-utils and acpi stuff
|
||||||
|
if os.access('/etc/acpi/', os.F_OK):
|
||||||
|
data.append(('/etc/acpi/resume.d', ['other/80-wicd-connect.sh']))
|
||||||
|
data.append(('/etc/acpi/suspend.d', ['other/50-wicd-suspend.sh']))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setup(name="Wicd",
|
setup(name="Wicd",
|
||||||
|
|||||||
@@ -1027,7 +1027,7 @@ class WirelessInterface(Interface):
|
|||||||
process was successful.
|
process was successful.
|
||||||
|
|
||||||
NOTE: It's possible this could return False,
|
NOTE: It's possible this could return False,
|
||||||
even though in actuality wpa_supplicant just isn't
|
though in reality wpa_supplicant just isn't
|
||||||
finished yet.
|
finished yet.
|
||||||
|
|
||||||
Keyword arguments:
|
Keyword arguments:
|
||||||
|
|||||||
Reference in New Issue
Block a user