mirror of
https://github.com/gryf/wicd.git
synced 2025-12-20 12:58:07 +01:00
fixed a screw up in my indentation in edgy.py, changed tabs to 4 spaces everywhere it wasn't already
This commit is contained in:
@@ -4,7 +4,7 @@ import gobject
|
|||||||
import dbus
|
import dbus
|
||||||
import dbus.service
|
import dbus.service
|
||||||
if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
|
if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
|
||||||
import dbus.glib
|
import dbus.glib
|
||||||
|
|
||||||
#############
|
#############
|
||||||
#declare our connections to our daemon.
|
#declare our connections to our daemon.
|
||||||
@@ -21,4 +21,4 @@ wired = dbus.Interface(proxy_obj, 'org.wicd.daemon.wired')
|
|||||||
|
|
||||||
print daemon.Hello()
|
print daemon.Hello()
|
||||||
if wireless.CheckIfWirelessConnecting() == False and wired.CheckIfWiredConnecting() == False:
|
if wireless.CheckIfWirelessConnecting() == False and wired.CheckIfWiredConnecting() == False:
|
||||||
print wireless.AutoConnect(True)
|
print wireless.AutoConnect(True)
|
||||||
|
|||||||
26
dapper.py
26
dapper.py
@@ -5,30 +5,30 @@
|
|||||||
## but that is not the preferred method
|
## but that is not the preferred method
|
||||||
import os,sys
|
import os,sys
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
os.chdir(os.path.dirname(os.path.normpath(os.path.join(os.getcwd(),sys.argv[0]))))
|
os.chdir(os.path.dirname(os.path.normpath(os.path.join(os.getcwd(),sys.argv[0]))))
|
||||||
import gtk
|
import gtk
|
||||||
import egg.trayicon
|
import egg.trayicon
|
||||||
import gobject, dbus, dbus.service
|
import gobject, dbus, dbus.service
|
||||||
if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
|
if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
|
||||||
import dbus.glib
|
import dbus.glib
|
||||||
#############
|
#############
|
||||||
#declare the connections to our daemon.
|
#declare the connections to our daemon.
|
||||||
#without them nothing useful will happen
|
#without them nothing useful will happen
|
||||||
#the daemon should be running as root
|
#the daemon should be running as root
|
||||||
bus = dbus.SystemBus()
|
bus = dbus.SystemBus()
|
||||||
try:
|
try:
|
||||||
print 'attempting to connect daemon...'
|
print 'attempting to connect daemon...'
|
||||||
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
|
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
|
||||||
print 'success'
|
print 'success'
|
||||||
except:
|
except:
|
||||||
print 'daemon not running, running gksudo ./daemon.py...'
|
print 'daemon not running, running gksudo ./daemon.py...'
|
||||||
import misc,time
|
import misc,time
|
||||||
misc.PromptToStartDaemon()
|
misc.PromptToStartDaemon()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
try:
|
try:
|
||||||
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
|
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
|
||||||
except:
|
except:
|
||||||
print 'daemon still not running, aborting.'
|
print 'daemon still not running, aborting.'
|
||||||
#daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon')
|
#daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon')
|
||||||
wireless = dbus.Interface(proxy_obj, 'org.wicd.daemon.wireless')
|
wireless = dbus.Interface(proxy_obj, 'org.wicd.daemon.wireless')
|
||||||
wired = dbus.Interface(proxy_obj, 'org.wicd.daemon.wired')
|
wired = dbus.Interface(proxy_obj, 'org.wicd.daemon.wired')
|
||||||
|
|||||||
273
edgy.py
273
edgy.py
@@ -16,10 +16,10 @@
|
|||||||
########
|
########
|
||||||
import os,sys
|
import os,sys
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
os.chdir(os.path.dirname(os.path.normpath(os.path.join(os.getcwd(),sys.argv[0]))))
|
os.chdir(os.path.dirname(os.path.normpath(os.path.join(os.getcwd(),sys.argv[0]))))
|
||||||
import gtk, gobject, dbus, dbus.service, os, sys, locale, gettext, signal, time
|
import gtk, gobject, dbus, dbus.service, os, sys, locale, gettext, signal, time
|
||||||
if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
|
if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
|
||||||
import dbus.glib
|
import dbus.glib
|
||||||
|
|
||||||
#############
|
#############
|
||||||
#declare the connections to our daemon.
|
#declare the connections to our daemon.
|
||||||
@@ -28,18 +28,18 @@ if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
|
|||||||
#some connections aren't used so they are commented
|
#some connections aren't used so they are commented
|
||||||
bus = dbus.SystemBus()
|
bus = dbus.SystemBus()
|
||||||
try:
|
try:
|
||||||
print 'attempting to connect daemon...'
|
print 'attempting to connect daemon...'
|
||||||
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
|
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
|
||||||
print 'success'
|
print 'success'
|
||||||
except:
|
except:
|
||||||
print 'daemon not running, running gksudo ./daemon.py...'
|
print 'daemon not running, running gksudo ./daemon.py...'
|
||||||
import misc
|
import misc
|
||||||
misc.PromptToStartDaemon()
|
misc.PromptToStartDaemon()
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
try:
|
try:
|
||||||
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
|
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
|
||||||
except:
|
except:
|
||||||
print 'daemon still not running, aborting.'
|
print 'daemon still not running, aborting.'
|
||||||
daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon') # Had to uncomment it
|
daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon') # Had to uncomment it
|
||||||
wireless = dbus.Interface(proxy_obj, 'org.wicd.daemon.wireless')
|
wireless = dbus.Interface(proxy_obj, 'org.wicd.daemon.wireless')
|
||||||
wired = dbus.Interface(proxy_obj, 'org.wicd.daemon.wired')
|
wired = dbus.Interface(proxy_obj, 'org.wicd.daemon.wired')
|
||||||
@@ -50,10 +50,10 @@ local_path = os.path.realpath(os.path.dirname(sys.argv[0])) + '/translations'
|
|||||||
langs = []
|
langs = []
|
||||||
lc, encoding = locale.getdefaultlocale()
|
lc, encoding = locale.getdefaultlocale()
|
||||||
if (lc):
|
if (lc):
|
||||||
langs = [lc]
|
langs = [lc]
|
||||||
osLanguage = os.environ.get('LANGUAGE', None)
|
osLanguage = os.environ.get('LANGUAGE', None)
|
||||||
if (osLanguage):
|
if (osLanguage):
|
||||||
langs += osLanguage.split(":")
|
langs += osLanguage.split(":")
|
||||||
langs += ["en_US"]
|
langs += ["en_US"]
|
||||||
lang = gettext.translation('wicd', local_path, languages=langs, fallback = True)
|
lang = gettext.translation('wicd', local_path, languages=langs, fallback = True)
|
||||||
_ = lang.gettext
|
_ = lang.gettext
|
||||||
@@ -68,146 +68,143 @@ pic=None
|
|||||||
lastWinId = 0
|
lastWinId = 0
|
||||||
|
|
||||||
def open_wicd_gui():
|
def open_wicd_gui():
|
||||||
global lastWinId
|
global lastWinId
|
||||||
ret = 0
|
ret = 0
|
||||||
if lastWinId != 0:
|
if lastWinId != 0:
|
||||||
os.kill(lastWinId,signal.SIGQUIT)
|
os.kill(lastWinId,signal.SIGQUIT)
|
||||||
ret = os.waitpid(lastWinId,0)[1]
|
ret = os.waitpid(lastWinId,0)[1]
|
||||||
lastWinId = 0
|
lastWinId = 0
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
lastWinId = os.spawnlpe(os.P_NOWAIT, './gui.py', os.environ)
|
lastWinId = os.spawnlpe(os.P_NOWAIT, './gui.py', os.environ)
|
||||||
|
|
||||||
def set_signal_image():
|
def set_signal_image():
|
||||||
global LastStrength
|
global LastStrength
|
||||||
global stillWired #keeps us from resetting the wired info over and over
|
global stillWired #keeps us from resetting the wired info over and over
|
||||||
global network #declared as global so it gets initialized before initial use
|
global network #declared as global so it gets initialized before initial use
|
||||||
|
|
||||||
# Disable logging if debugging isn't on to prevent log spam
|
# Disable logging if debugging isn't on to prevent log spam
|
||||||
if not daemon.GetDebugMode():
|
if not daemon.GetDebugMode():
|
||||||
config.DisableLogging()
|
config.DisableLogging()
|
||||||
|
|
||||||
wired_ip = wired.GetWiredIP()
|
wired_ip = wired.GetWiredIP()
|
||||||
if wired.CheckPluggedIn() == True and wired_ip:
|
if wired.CheckPluggedIn() == True and wired_ip:
|
||||||
if stillWired == False: # Only set image/tooltip if it hasn't been set already
|
if stillWired == False: # Only set image/tooltip if it hasn't been set already
|
||||||
tr.set_from_file("images/wired.png")
|
tr.set_from_file("images/wired.png")
|
||||||
tr.set_tooltip(language['connected_to_wired'].replace('$A',wired_ip))
|
tr.set_tooltip(language['connected_to_wired'].replace('$A',wired_ip))
|
||||||
stillWired = True
|
stillWired = True
|
||||||
lock = ''
|
lock = ''
|
||||||
else:
|
else:
|
||||||
stillWired = False
|
stillWired = False
|
||||||
|
wireless_ip = wireless.GetWirelessIP()
|
||||||
|
#If ip returns as None, we are probably returning from hibernation and need to force signal to 0 to avoid crashing
|
||||||
|
if wireless_ip != None:
|
||||||
|
signal = int(wireless.GetCurrentSignalStrength())
|
||||||
|
else:
|
||||||
|
signal = 0
|
||||||
|
|
||||||
wireless_ip = wireless.GetWirelessIP()
|
#only update if the signal strength has changed because doing I/O calls is expensive,
|
||||||
#If ip returns as None, we are probably returning from hibernation and need to force signal to 0 to avoid crashing
|
#and the icon flickers
|
||||||
if wireless_ip != None:
|
if (signal != LastStrength or network != wireless.GetCurrentNetwork()) and wireless_ip != None:
|
||||||
signal = int(wireless.GetCurrentSignalStrength())
|
LastStrength = signal
|
||||||
else:
|
lock = '' #set the string to '' so that when it is put in "high-signal" + lock + ".png", there will be nothing
|
||||||
signal = 0
|
curNetID = wireless.GetCurrentNetworkID() #the network ID needs to be checked because a negative value here will break the tray
|
||||||
|
if signal > 0 and curNetID > -1 and wireless.GetWirelessProperty(curNetID,"encryption"):
|
||||||
|
lock = '-lock' #set the string to '-lock' so that it will display the lock picture
|
||||||
|
network = str(wireless.GetCurrentNetwork())
|
||||||
|
tr.set_tooltip(language['connected_to_wireless'].replace('$A',network).replace('$B',str(signal)).replace('$C',str(wireless_ip)))
|
||||||
|
if signal > 75:
|
||||||
|
tr.set_from_file("images/high-signal" + lock + ".png")
|
||||||
|
elif signal > 50:
|
||||||
|
tr.set_from_file("images/good-signal" + lock + ".png")
|
||||||
|
elif signal > 25:
|
||||||
|
tr.set_from_file("images/low-signal" + lock + ".png")
|
||||||
|
elif signal > 0:
|
||||||
|
tr.set_from_file("images/bad-signal" + lock + ".png")
|
||||||
|
elif signal == 0:
|
||||||
|
tr.set_from_file("images/no-signal.png")
|
||||||
|
#Auto-reconnect code - not sure how well this works. I know that without the ForcedDisconnect check it reconnects you when
|
||||||
|
#a disconnect is forced. People who have disconnection problems need to test it to determine if it actually works.
|
||||||
|
#First it will attempt to reconnect to the last known wireless network, and if that fails it should run a scan and try to
|
||||||
|
#connect to any network set to autoconnect. It will continuously rescan until a network is found or the user manually reconnects
|
||||||
|
#This behavior could prove to be annoying, so we'll keep it in the experimental build for now
|
||||||
|
if wireless.GetAutoReconnect() == True and wireless.CheckIfWirelessConnecting() == False and wireless.GetForcedDisconnect() == False:
|
||||||
|
curNetID = wireless.GetCurrentNetworkID()
|
||||||
|
if curNetID > -1: #value of -1 is typically caused by hibernation and breaks the tray if passed to daemon
|
||||||
|
wireless.ConnectWireless(wireless.GetCurrentNetworkID())
|
||||||
|
if wireless.GetCurrentSignalStrength() != 0:
|
||||||
|
print "Successfully autoreconnected."
|
||||||
|
else:
|
||||||
|
print "Couldn't reconnect to last used network, scanning for an autoconnect network..."
|
||||||
|
print wireless.AutoConnect(True)
|
||||||
|
|
||||||
#only update if the signal strength has changed because doing I/O calls is expensive,
|
elif wireless_ip == None:
|
||||||
#and the icon flickers
|
tr.set_from_file("images/no-signal.png")
|
||||||
if (signal != LastStrength or network != wireless.GetCurrentNetwork()) and wireless_ip != None:
|
tr.set_tooltip(language['not_connected'])
|
||||||
LastStrength = signal
|
|
||||||
lock = '' #set the string to '' so that when it is put in "high-signal" + lock + ".png", there will be nothing
|
|
||||||
curNetID = wireless.GetCurrentNetworkID() #the network ID needs to be checked because a negative value here will break the tray
|
|
||||||
if signal > 0 and curNetID > -1 and wireless.GetWirelessProperty(curNetID,"encryption"):
|
|
||||||
lock = '-lock' #set the string to '-lock' so that it will display the lock picture
|
|
||||||
network = str(wireless.GetCurrentNetwork())
|
|
||||||
tr.set_tooltip(language['connected_to_wireless'].replace('$A',network).replace('$B',str(signal)).replace('$C',str(wireless_ip)))
|
|
||||||
if signal > 75:
|
|
||||||
tr.set_from_file("images/high-signal" + lock + ".png")
|
|
||||||
elif signal > 50:
|
|
||||||
tr.set_from_file("images/good-signal" + lock + ".png")
|
|
||||||
elif signal > 25:
|
|
||||||
tr.set_from_file("images/low-signal" + lock + ".png")
|
|
||||||
elif signal > 0:
|
|
||||||
tr.set_from_file("images/bad-signal" + lock + ".png")
|
|
||||||
elif signal == 0:
|
|
||||||
tr.set_from_file("images/no-signal.png")
|
|
||||||
elif wireless_ip == None:
|
|
||||||
tr.set_from_file("images/no-signal.png")
|
|
||||||
tr.set_tooltip(language['not_connected'])
|
|
||||||
#Auto-reconnect code - not sure how well this works. I know that without the ForcedDisconnect check it reconnects you when
|
|
||||||
#a disconnect is forced. People who have disconnection problems need to test it to determine if it actually works.
|
|
||||||
#First it will attempt to reconnect to the last known wireless network, and if that fails it should run a scan and try to
|
|
||||||
#connect to any network set to autoconnect. It will continuously rescan until a network is found or the user manually reconnects
|
|
||||||
#This behavior could prove to be annoying, so we'll keep it in the experimental build for now
|
|
||||||
if wireless.GetAutoReconnect() == True and wireless.CheckIfWirelessConnecting() == False and wireless.GetForcedDisconnect() == False:
|
|
||||||
curNetID = wireless.GetCurrentNetworkID()
|
|
||||||
if curNetID > -1: #value of -1 is typically caused by hibernation and breaks the tray if passed to daemon
|
|
||||||
wireless.ConnectWireless(wireless.GetCurrentNetworkID())
|
|
||||||
if wireless.GetCurrentSignalStrength() != 0:
|
|
||||||
print "Successfully autoreconnected."
|
|
||||||
else:
|
|
||||||
print "Couldn't reconnect to last used network, scanning for an autoconnect network..."
|
|
||||||
print wireless.AutoConnect(True)
|
|
||||||
else:
|
|
||||||
print "Scanning for an autoconnect network..."
|
|
||||||
print wireless.AutoConnect(True)
|
|
||||||
|
|
||||||
if not daemon.GetDebugMode():
|
if not daemon.GetDebugMode():
|
||||||
config.EnableLogging()
|
config.EnableLogging()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
class TrackerStatusIcon(gtk.StatusIcon):
|
class TrackerStatusIcon(gtk.StatusIcon):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
gtk.StatusIcon.__init__(self)
|
gtk.StatusIcon.__init__(self)
|
||||||
menu = '''
|
menu = '''
|
||||||
<ui>
|
<ui>
|
||||||
<menubar name="Menubar">
|
<menubar name="Menubar">
|
||||||
<menu action="Menu">
|
<menu action="Menu">
|
||||||
<menuitem action="Connect"/>
|
<menuitem action="Connect"/>
|
||||||
<separator/>
|
<separator/>
|
||||||
<menuitem action="About"/>
|
<menuitem action="About"/>
|
||||||
<menuitem action="Quit"/>
|
<menuitem action="Quit"/>
|
||||||
</menu>
|
</menu>
|
||||||
</menubar>
|
</menubar>
|
||||||
</ui>
|
</ui>
|
||||||
'''
|
'''
|
||||||
actions = [
|
actions = [
|
||||||
('Menu', None, 'Menu'),
|
('Menu', None, 'Menu'),
|
||||||
('Connect', gtk.STOCK_CONNECT, '_Connect...', None, 'Connect to network', self.on_preferences),
|
('Connect', gtk.STOCK_CONNECT, '_Connect...', None, 'Connect to network', self.on_preferences),
|
||||||
('About', gtk.STOCK_ABOUT, '_About...', None, 'About wicd-tray-icon', self.on_about),
|
('About', gtk.STOCK_ABOUT, '_About...', None, 'About wicd-tray-icon', self.on_about),
|
||||||
('Quit',gtk.STOCK_QUIT,'_Quit',None,'Quit wicd-tray-icon', self.on_quit),
|
('Quit',gtk.STOCK_QUIT,'_Quit',None,'Quit wicd-tray-icon', self.on_quit),
|
||||||
|
|
||||||
]
|
]
|
||||||
ag = gtk.ActionGroup('Actions')
|
ag = gtk.ActionGroup('Actions')
|
||||||
ag.add_actions(actions)
|
ag.add_actions(actions)
|
||||||
self.manager = gtk.UIManager()
|
self.manager = gtk.UIManager()
|
||||||
self.manager.insert_action_group(ag, 0)
|
self.manager.insert_action_group(ag, 0)
|
||||||
self.manager.add_ui_from_string(menu)
|
self.manager.add_ui_from_string(menu)
|
||||||
self.menu = self.manager.get_widget('/Menubar/Menu/About').props.parent
|
self.menu = self.manager.get_widget('/Menubar/Menu/About').props.parent
|
||||||
self.current_icon_path = ''
|
self.current_icon_path = ''
|
||||||
self.set_from_file("images/no-signal.png")
|
self.set_from_file("images/no-signal.png")
|
||||||
self.set_visible(True)
|
self.set_visible(True)
|
||||||
self.connect('activate', self.on_activate)
|
self.connect('activate', self.on_activate)
|
||||||
self.connect('popup-menu', self.on_popup_menu)
|
self.connect('popup-menu', self.on_popup_menu)
|
||||||
|
|
||||||
def on_activate(self, data):
|
def on_activate(self, data):
|
||||||
open_wicd_gui()
|
open_wicd_gui()
|
||||||
|
|
||||||
def on_quit(self,widget):
|
def on_quit(self,widget):
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
def on_popup_menu(self, status, button, time):
|
def on_popup_menu(self, status, button, time):
|
||||||
self.menu.popup(None, None, None, button, time)
|
self.menu.popup(None, None, None, button, time)
|
||||||
|
|
||||||
def on_preferences(self, data):
|
def on_preferences(self, data):
|
||||||
open_wicd_gui()
|
open_wicd_gui()
|
||||||
|
|
||||||
def on_about(self, data):
|
def on_about(self, data):
|
||||||
dialog = gtk.AboutDialog()
|
dialog = gtk.AboutDialog()
|
||||||
dialog.set_name('wicd tray icon')
|
dialog.set_name('wicd tray icon')
|
||||||
dialog.set_version('0.2')
|
dialog.set_version('0.2')
|
||||||
dialog.set_comments('an icon that shows your network connectivity')
|
dialog.set_comments('an icon that shows your network connectivity')
|
||||||
dialog.set_website('http://wicd.sourceforge.net')
|
dialog.set_website('http://wicd.sourceforge.net')
|
||||||
dialog.run()
|
dialog.run()
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
|
|
||||||
def set_from_file(self,path):
|
def set_from_file(self,path):
|
||||||
if path != self.current_icon_path:
|
if path != self.current_icon_path:
|
||||||
self.current_icon_path = path
|
self.current_icon_path = path
|
||||||
gtk.StatusIcon.set_from_file(self,path)
|
gtk.StatusIcon.set_from_file(self,path)
|
||||||
|
|
||||||
LastStrength = -2
|
LastStrength = -2
|
||||||
stillWired = False
|
stillWired = False
|
||||||
|
|||||||
220
misc.py
220
misc.py
@@ -2,138 +2,138 @@
|
|||||||
#pretty much useless to anyone else...
|
#pretty much useless to anyone else...
|
||||||
#but if it is useful, feel free to use under the terms of the GPL
|
#but if it is useful, feel free to use under the terms of the GPL
|
||||||
#
|
#
|
||||||
# This is released under the
|
# This is released under the
|
||||||
# GNU General Public License
|
# GNU General Public License
|
||||||
# The terms can be found at
|
# The terms can be found at
|
||||||
# http://www.gnu.org/copyleft/gpl.html
|
# http://www.gnu.org/copyleft/gpl.html
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007 Adam Blackburn
|
# Copyright (C) 2007 Adam Blackburn
|
||||||
#
|
#
|
||||||
|
|
||||||
import os,sys
|
import os,sys
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
os.chdir(os.path.dirname(os.path.normpath(os.path.join(os.getcwd(),sys.argv[0]))))
|
os.chdir(os.path.dirname(os.path.normpath(os.path.join(os.getcwd(),sys.argv[0]))))
|
||||||
import re
|
import re
|
||||||
def Run(cmd,include_std_error=False):
|
def Run(cmd,include_std_error=False):
|
||||||
if not include_std_error:
|
if not include_std_error:
|
||||||
f = os.popen( cmd , "r")
|
f = os.popen( cmd , "r")
|
||||||
return f.read()
|
return f.read()
|
||||||
else:
|
else:
|
||||||
input,out_err = os.popen4( cmd, 'r')
|
input,out_err = os.popen4( cmd, 'r')
|
||||||
return out_err.read()
|
return out_err.read()
|
||||||
|
|
||||||
def IsValidIP(ip):
|
def IsValidIP(ip):
|
||||||
if ip != None: #make sure there is an IP
|
if ip != None: #make sure there is an IP
|
||||||
if ip.count('.') == 3: #make sure the IP can be parsed (or at least it has the proper dots)
|
if ip.count('.') == 3: #make sure the IP can be parsed (or at least it has the proper dots)
|
||||||
ipNumbers = ip.split('.') #split it up
|
ipNumbers = ip.split('.') #split it up
|
||||||
if not '' in ipNumbers: #make sure the IP isn't something like 127..0.1
|
if not '' in ipNumbers: #make sure the IP isn't something like 127..0.1
|
||||||
return ipNumbers
|
return ipNumbers
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def PromptToStartDaemon():
|
def PromptToStartDaemon():
|
||||||
gksudo_args = ['gksudo', '--message', 'Wicd needs to access your computer\'s network cards.','--','./daemon.py']
|
gksudo_args = ['gksudo', '--message', 'Wicd needs to access your computer\'s network cards.','--','./daemon.py']
|
||||||
os.spawnvpe(os.P_NOWAIT, 'gksudo', gksudo_args, os.environ)
|
os.spawnvpe(os.P_NOWAIT, 'gksudo', gksudo_args, os.environ)
|
||||||
|
|
||||||
def RunRegex(regex,string):
|
def RunRegex(regex,string):
|
||||||
m = regex.search( string )
|
m = regex.search( string )
|
||||||
if m:
|
if m:
|
||||||
return m.groups()[0]
|
return m.groups()[0]
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def WriteLine(file,text):
|
def WriteLine(file,text):
|
||||||
file.write(text + "\n")
|
file.write(text + "\n")
|
||||||
|
|
||||||
def ReadFile(filename):
|
def ReadFile(filename):
|
||||||
if not os.path.exists(filename):
|
if not os.path.exists(filename):
|
||||||
return None
|
return None
|
||||||
file = open(filename,'r')
|
file = open(filename,'r')
|
||||||
data = file.read().strip()
|
data = file.read().strip()
|
||||||
file.close()
|
file.close()
|
||||||
return str(data)
|
return str(data)
|
||||||
|
|
||||||
def Noneify(variable):
|
def Noneify(variable):
|
||||||
#set string Nones to real Nones
|
#set string Nones to real Nones
|
||||||
if variable == "None" or variable == "":
|
if variable == "None" or variable == "":
|
||||||
return None
|
return None
|
||||||
if variable == "True": # or variable == "1": # or variable == 1:
|
if variable == "True": # or variable == "1": # or variable == 1:
|
||||||
return True
|
return True
|
||||||
if variable == "False": #or variable == "0": # or variable == 0:
|
if variable == "False": #or variable == "0": # or variable == 0:
|
||||||
return False
|
return False
|
||||||
#if str(variable).isdigit() == True:
|
#if str(variable).isdigit() == True:
|
||||||
# return int(variable)
|
# return int(variable)
|
||||||
if str(variable) == "1":
|
if str(variable) == "1":
|
||||||
return True
|
return True
|
||||||
if str(variable) == "0":
|
if str(variable) == "0":
|
||||||
return False
|
return False
|
||||||
#otherwise...
|
#otherwise...
|
||||||
return variable
|
return variable
|
||||||
|
|
||||||
def ParseEncryption(network):
|
def ParseEncryption(network):
|
||||||
#list = open("encryption/templates/active","r")
|
#list = open("encryption/templates/active","r")
|
||||||
#types = list.readlines()
|
#types = list.readlines()
|
||||||
#for i in types:
|
#for i in types:
|
||||||
enctemplate = open("encryption/templates/" + network["enctype"])
|
enctemplate = open("encryption/templates/" + network["enctype"])
|
||||||
template = enctemplate.readlines()
|
template = enctemplate.readlines()
|
||||||
#set these to nothing so that we can hold them outside the loop
|
#set these to nothing so that we can hold them outside the loop
|
||||||
z = "ap_scan=1\n"
|
z = "ap_scan=1\n"
|
||||||
y = 0
|
y = 0
|
||||||
#loop through the lines in the template, selecting ones to use
|
#loop through the lines in the template, selecting ones to use
|
||||||
for x in template:
|
for x in template:
|
||||||
x = x.strip("\n")
|
x = x.strip("\n")
|
||||||
if y>4:
|
if y>4:
|
||||||
#blah blah replace stuff
|
#blah blah replace stuff
|
||||||
x = x.replace("$_SCAN","0")
|
x = x.replace("$_SCAN","0")
|
||||||
for t in network:
|
for t in network:
|
||||||
if Noneify(network[t]) != None: #don't bother if z's value is None cause it will cause errors
|
if Noneify(network[t]) != None: #don't bother if z's value is None cause it will cause errors
|
||||||
x = x.replace("$_" + str(t).upper(),str(network[t]))
|
x = x.replace("$_" + str(t).upper(),str(network[t]))
|
||||||
z = z + "\n" + x
|
z = z + "\n" + x
|
||||||
y+=1
|
y+=1
|
||||||
#write the data to the files
|
#write the data to the files
|
||||||
#then chmod them so they can't be read by evil little munchkins
|
#then chmod them so they can't be read by evil little munchkins
|
||||||
fileness = open("encryption/configurations/" + network["bssid"].replace(":","").lower(),"w")
|
fileness = open("encryption/configurations/" + network["bssid"].replace(":","").lower(),"w")
|
||||||
os.chmod("encryption/configurations/" + network["bssid"].replace(":","").lower(),0600)
|
os.chmod("encryption/configurations/" + network["bssid"].replace(":","").lower(),0600)
|
||||||
os.chown("encryption/configurations/" + network["bssid"].replace(":","").lower(), 0, 0)
|
os.chown("encryption/configurations/" + network["bssid"].replace(":","").lower(), 0, 0)
|
||||||
#we could do this above, but we'd like to permod (permission mod) them before we write, so that it can't be read
|
#we could do this above, but we'd like to permod (permission mod) them before we write, so that it can't be read
|
||||||
fileness.write(z)
|
fileness.write(z)
|
||||||
fileness.close()
|
fileness.close()
|
||||||
|
|
||||||
def LoadEncryptionMethods():
|
def LoadEncryptionMethods():
|
||||||
encryptionTypes = {}
|
encryptionTypes = {}
|
||||||
types = open("encryption/templates/active","r")
|
types = open("encryption/templates/active","r")
|
||||||
enctypes = types.readlines()
|
enctypes = types.readlines()
|
||||||
for x in enctypes:
|
for x in enctypes:
|
||||||
#skip some lines, we don't care who the author is/was, etc
|
#skip some lines, we don't care who the author is/was, etc
|
||||||
#we don't care about version either
|
#we don't care about version either
|
||||||
x = x.strip("\n")
|
x = x.strip("\n")
|
||||||
current = open("encryption/templates/" + x,"r")
|
current = open("encryption/templates/" + x,"r")
|
||||||
line = current.readlines()
|
line = current.readlines()
|
||||||
typeID = len(encryptionTypes) #this is so we know where in the array to add data
|
typeID = len(encryptionTypes) #this is so we know where in the array to add data
|
||||||
encryptionTypes[typeID] = {}
|
encryptionTypes[typeID] = {}
|
||||||
encryptionTypes[typeID][0] = line[0][7:].strip("\n")
|
encryptionTypes[typeID][0] = line[0][7:].strip("\n")
|
||||||
encryptionTypes[typeID][1] = x
|
encryptionTypes[typeID][1] = x
|
||||||
encryptionTypes[typeID][2] = {}
|
encryptionTypes[typeID][2] = {}
|
||||||
requiredFields = line[3][8:]
|
requiredFields = line[3][8:]
|
||||||
requiredFields = requiredFields.strip("\n")
|
requiredFields = requiredFields.strip("\n")
|
||||||
requiredFields = requiredFields.split(" ")
|
requiredFields = requiredFields.split(" ")
|
||||||
index = -1
|
index = -1
|
||||||
for current in requiredFields:
|
for current in requiredFields:
|
||||||
#the pretty names will start with an * so we can
|
#the pretty names will start with an * so we can
|
||||||
#seperate them with that
|
#seperate them with that
|
||||||
if current[0] == "*":
|
if current[0] == "*":
|
||||||
#make underscores spaces
|
#make underscores spaces
|
||||||
#and remove the *
|
#and remove the *
|
||||||
encryptionTypes[typeID][2][index][0] = current.replace("_"," ").lstrip("*")
|
encryptionTypes[typeID][2][index][0] = current.replace("_"," ").lstrip("*")
|
||||||
else:
|
else:
|
||||||
#add to the list of things that are required
|
#add to the list of things that are required
|
||||||
index = len(encryptionTypes[typeID][2])
|
index = len(encryptionTypes[typeID][2])
|
||||||
encryptionTypes[typeID][2][index] = {}
|
encryptionTypes[typeID][2][index] = {}
|
||||||
encryptionTypes[typeID][2][index][1] = current
|
encryptionTypes[typeID][2][index][1] = current
|
||||||
return encryptionTypes
|
return encryptionTypes
|
||||||
|
|
||||||
def noneToString(text):
|
def noneToString(text):
|
||||||
'''used for putting text in a text box if the value to put in is 'None' the box will be blank'''
|
'''used for putting text in a text box if the value to put in is 'None' the box will be blank'''
|
||||||
if text == None or text == "None" or text == "":
|
if text == None or text == "None" or text == "":
|
||||||
return "None"
|
return "None"
|
||||||
else:
|
else:
|
||||||
return str(text)
|
return str(text)
|
||||||
|
|||||||
6
tray.py
6
tray.py
@@ -1,9 +1,9 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import os,sys
|
import os,sys
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
os.chdir(os.path.dirname(os.path.normpath(os.path.join(os.getcwd(),sys.argv[0]))))
|
os.chdir(os.path.dirname(os.path.normpath(os.path.join(os.getcwd(),sys.argv[0]))))
|
||||||
import gtk
|
import gtk
|
||||||
if gtk.gtk_version[0] >= 2 and gtk.gtk_version[1] >= 10:
|
if gtk.gtk_version[0] >= 2 and gtk.gtk_version[1] >= 10:
|
||||||
import edgy
|
import edgy
|
||||||
else:
|
else:
|
||||||
import dapper
|
import dapper
|
||||||
|
|||||||
Reference in New Issue
Block a user