mirror of
https://github.com/gryf/wicd.git
synced 2025-12-20 04:48:00 +01:00
Centralise path configuration into a single file.
Path configuration was distributed throughout wicd, making it difficult to move around project files. Centralise the configuration into wpath.py.
This commit is contained in:
14
daemon.py
14
daemon.py
@@ -6,9 +6,11 @@
|
||||
############
|
||||
|
||||
#change to the directory that the file lives in
|
||||
import os,sys
|
||||
import os
|
||||
import sys
|
||||
import wpath
|
||||
if __name__ == '__main__':
|
||||
os.chdir(os.path.dirname(os.path.normpath(os.path.join(os.getcwd(),sys.argv[0]))))
|
||||
wpath.chdir(__file__)
|
||||
#import the dbus stuff
|
||||
import gobject
|
||||
import dbus
|
||||
@@ -58,7 +60,7 @@ logging_enabled = True
|
||||
class FlushWriter:
|
||||
def __init__(self):
|
||||
print os.getcwd()
|
||||
self.file = open('data/wicd.log','w')
|
||||
self.file = open(wpath.log + 'wicd.log','w')
|
||||
self.file.write(self.__getPrettyTime() + ' :: ')
|
||||
|
||||
def write(self,data):
|
||||
@@ -104,9 +106,9 @@ class ConnectionWizard(dbus.service.Object):
|
||||
dbus.service.Object.__init__(self, bus_name, object_path)
|
||||
|
||||
#set variables needed to run - these probably won't be changed too often
|
||||
self.app_conf = "data/manager-settings.conf"
|
||||
self.wireless_conf = "data/wireless-settings.conf"
|
||||
self.wired_conf = "data/wired-settings.conf"
|
||||
self.app_conf = wpath.etc + 'manager-settings.conf'
|
||||
self.wireless_conf = wpath.etc + 'wireless-settings.conf'
|
||||
self.wired_conf = wpath.etc + 'wired-settings.conf'
|
||||
self.hidden_essid = None
|
||||
self.wifi = networking.Wireless()
|
||||
self.wired = networking.Wired()
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
## USE TRAY.PY INSTEAD
|
||||
## nothing bad will happen if you do
|
||||
## but that is not the preferred method
|
||||
import os,sys
|
||||
import os
|
||||
import sys
|
||||
import wpath
|
||||
if __name__ == '__main__':
|
||||
os.chdir(os.path.dirname(os.path.normpath(os.path.join(os.getcwd(),sys.argv[0]))))
|
||||
wpath.chdir(__file__)
|
||||
import gtk,locale,gettext,signal
|
||||
import egg.trayicon
|
||||
import gobject, dbus, dbus.service
|
||||
|
||||
6
edgy.py
6
edgy.py
@@ -14,9 +14,11 @@
|
||||
##this will only work in Edgy and above because of gtk requirements
|
||||
##to run the tray icon
|
||||
########
|
||||
import os,sys
|
||||
import os
|
||||
import sys
|
||||
import wpath
|
||||
if __name__ == '__main__':
|
||||
os.chdir(os.path.dirname(os.path.normpath(os.path.join(os.getcwd(),sys.argv[0]))))
|
||||
wpath.chdir(__file__)
|
||||
import gtk, gobject, dbus, dbus.service, os, sys, locale, gettext, signal, time
|
||||
if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
|
||||
import dbus.glib
|
||||
|
||||
22
gui.py
22
gui.py
@@ -1,7 +1,9 @@
|
||||
#!/usr/bin/python
|
||||
import os,sys
|
||||
import os
|
||||
import sys
|
||||
import wpath
|
||||
if __name__ == '__main__':
|
||||
os.chdir(os.path.dirname(os.path.normpath(os.path.join(os.getcwd(),sys.argv[0]))))
|
||||
wpath.chdir(__file__)
|
||||
try:
|
||||
import pygtk
|
||||
pygtk.require("2.0")
|
||||
@@ -337,22 +339,22 @@ class PrettyWirelessNetworkEntry(PrettyNetworkEntry):
|
||||
strength = int(strength)
|
||||
if daemon.GetWPADriver() == 'ralink legacy':
|
||||
if strength <= 60:
|
||||
self.image.set_from_file("images/signal-100.png")
|
||||
self.image.set_from_file(wpath.images + 'signal-100.png')
|
||||
elif strength <= 70:
|
||||
self.image.set_from_file("images/signal-75.png")
|
||||
self.image.set_from_file(wpath.images + 'signal-75.png')
|
||||
elif strength <= 80:
|
||||
self.image.set_from_file("images/signal-50.png")
|
||||
self.image.set_from_file(wpath.images + 'signal-50.png')
|
||||
else:
|
||||
self.image.set_from_file("images/signal-25.png")
|
||||
self.image.set_from_file(wpath.images + 'signal-25.png')
|
||||
else:
|
||||
if strength > 75:
|
||||
self.image.set_from_file("images/signal-100.png")
|
||||
self.image.set_from_file(wpath.images + 'signal-100.png')
|
||||
elif strength > 50:
|
||||
self.image.set_from_file("images/signal-75.png")
|
||||
self.image.set_from_file(wpath.images + 'signal-75.png')
|
||||
elif strength > 25:
|
||||
self.image.set_from_file("images/signal-50.png")
|
||||
self.image.set_from_file(wpath.images + 'signal-50.png')
|
||||
else:
|
||||
self.image.set_from_file("images/signal-25.png")
|
||||
self.image.set_from_file(wpath.images + 'signal-25.png')
|
||||
self.expander.setSignalStrength(strength)
|
||||
|
||||
def setMACAddress(self,address):
|
||||
|
||||
12
misc.py
12
misc.py
@@ -10,9 +10,11 @@
|
||||
# Copyright (C) 2007 Adam Blackburn
|
||||
#
|
||||
|
||||
import os,sys
|
||||
import os
|
||||
import sys
|
||||
import wpath
|
||||
if __name__ == '__main__':
|
||||
os.chdir(os.path.dirname(os.path.normpath(os.path.join(os.getcwd(),sys.argv[0]))))
|
||||
wpath.chdir(__file__)
|
||||
import re
|
||||
def Run(cmd,include_std_error=False):
|
||||
if not include_std_error:
|
||||
@@ -91,9 +93,9 @@ def ParseEncryption(network):
|
||||
y+=1
|
||||
#write the data to the files
|
||||
#then chmod them so they can't be read by evil little munchkins
|
||||
fileness = open("encryption/configurations/" + network["bssid"].replace(":","").lower(),"w")
|
||||
os.chmod("encryption/configurations/" + network["bssid"].replace(":","").lower(),0600)
|
||||
os.chown("encryption/configurations/" + network["bssid"].replace(":","").lower(), 0, 0)
|
||||
fileness = open(wpath.networks + network["bssid"].replace(":","").lower(),"w")
|
||||
os.chmod(wpath.networks + network["bssid"].replace(":","").lower(),0600)
|
||||
os.chown(wpath.networks + 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
|
||||
fileness.write(z)
|
||||
fileness.close()
|
||||
|
||||
@@ -6,9 +6,11 @@
|
||||
## MUST BE IMPORTED VIA import networking
|
||||
## TO ANOTHER PROJECT IF YOU WISH TO USE IT
|
||||
|
||||
import os,sys
|
||||
import os
|
||||
import sys
|
||||
import wpath
|
||||
if __name__ == '__main__':
|
||||
os.chdir(os.path.dirname(os.path.normpath(os.path.join(os.getcwd(),sys.argv[0]))))
|
||||
wpath.chdir(__file__)
|
||||
|
||||
#import the library of random functions that we need here
|
||||
#this is also written by me, for this purpose
|
||||
@@ -351,8 +353,8 @@ class Wireless:
|
||||
|
||||
print "generating wpa_supplicant configuration file..."
|
||||
misc.ParseEncryption(network)
|
||||
print "wpa_supplicant -B -i " + self.wireless_interface + " -c \"encryption/configurations/" + network["bssid"].replace(":","").lower() + "\" -D " + self.wpa_driver
|
||||
misc.Run("wpa_supplicant -B -i " + self.wireless_interface + " -c \"encryption/configurations/" + network["bssid"].replace(":","").lower() + "\" -D " + self.wpa_driver)
|
||||
print 'wpa_supplicant -B -i ' + self.wireless_interface + ' -c "' + wpath.networks + network["bssid"].replace(":","").lower() + '" -D ' + self.wpa_driver
|
||||
misc.Run('wpa_supplicant -B -i ' + self.wireless_interface + ' -c "' + wpath.networks + network["bssid"].replace(":","").lower() + '" -D ' + self.wpa_driver)
|
||||
|
||||
print "flushing the routing table..."
|
||||
self.lock.acquire()
|
||||
|
||||
6
tray.py
6
tray.py
@@ -1,7 +1,9 @@
|
||||
#!/usr/bin/python
|
||||
import os,sys
|
||||
import os
|
||||
import sys
|
||||
import wpath
|
||||
if __name__ == '__main__':
|
||||
os.chdir(os.path.dirname(os.path.normpath(os.path.join(os.getcwd(),sys.argv[0]))))
|
||||
wpath.chdir(__file__)
|
||||
import gtk
|
||||
if gtk.gtk_version[0] >= 2 and gtk.gtk_version[1] >= 10:
|
||||
import edgy
|
||||
|
||||
31
wpath.py
Normal file
31
wpath.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""Path configuration and functions for the wicd daemon and gui clients.
|
||||
|
||||
chdir() -- Change directory to the location of the current file.
|
||||
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
# The path containing the wpath.py file.
|
||||
current = os.path.dirname(os.path.realpath(__file__)) + '/'
|
||||
|
||||
# These paths can easily be modified to handle system wide installs, or
|
||||
# they can be left as is if all files remain with the source directory
|
||||
# layout.
|
||||
lib = current
|
||||
images = lib + 'images/'
|
||||
encryption = lib + 'encryption/templates/'
|
||||
bin = current
|
||||
etc = current + 'data/'
|
||||
networks = lib + 'encryption/configurations/'
|
||||
log = current + 'data/'
|
||||
|
||||
def chdir(file):
|
||||
"""Change directory to the location of the specified file.
|
||||
|
||||
Keyword arguments:
|
||||
file -- the file to switch to (usually __file__)
|
||||
|
||||
"""
|
||||
os.chdir(os.path.dirname(os.path.realpath(file)))
|
||||
|
||||
Reference in New Issue
Block a user