mirror of
https://github.com/gryf/wicd.git
synced 2026-03-04 15:45:46 +01:00
Make use of config module
This commit is contained in:
@@ -39,18 +39,20 @@ from optparse import OptionParser
|
|||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
import os
|
||||||
|
|
||||||
import urwid
|
import urwid
|
||||||
from dbus import DBusException
|
from dbus import DBusException
|
||||||
# It took me a while to figure out that I have to use this.
|
# It took me a while to figure out that I have to use this.
|
||||||
from gi.repository import GLib as gobject
|
from gi.repository import GLib as gobject
|
||||||
|
|
||||||
from wicd import wpath
|
from wicd.config import CFG
|
||||||
from wicd import misc
|
from wicd import misc
|
||||||
from wicd import dbusmanager
|
from wicd import dbusmanager
|
||||||
from wicd.translations import _
|
from wicd.translations import _
|
||||||
|
|
||||||
# Curses UIs for other stuff
|
# Curses UIs for other stuff
|
||||||
|
import wicd.curses
|
||||||
from wicd.curses.curses_misc import OptCols
|
from wicd.curses.curses_misc import OptCols
|
||||||
from wicd.curses.curses_misc import SelText
|
from wicd.curses.curses_misc import SelText
|
||||||
from wicd.curses.curses_misc import NSelListBox
|
from wicd.curses.curses_misc import NSelListBox
|
||||||
@@ -66,6 +68,7 @@ from wicd.curses import netentry_curses
|
|||||||
from wicd.curses.netentry_curses import WirelessSettingsDialog
|
from wicd.curses.netentry_curses import WirelessSettingsDialog
|
||||||
from wicd.curses.netentry_curses import WiredSettingsDialog
|
from wicd.curses.netentry_curses import WiredSettingsDialog
|
||||||
|
|
||||||
|
|
||||||
# Stuff about getting the script configurer running
|
# Stuff about getting the script configurer running
|
||||||
# from grp import getgrgid
|
# from grp import getgrgid
|
||||||
# from os import getgroups, system
|
# from os import getgroups, system
|
||||||
@@ -73,7 +76,7 @@ from wicd.curses.netentry_curses import WiredSettingsDialog
|
|||||||
# import logging
|
# import logging
|
||||||
# import logging.handler
|
# import logging.handler
|
||||||
|
|
||||||
CURSES_REV = wpath.curses_revision
|
CURSES_REV = wicd.curses.__version__
|
||||||
|
|
||||||
# Fix strings in wicd-curses
|
# Fix strings in wicd-curses
|
||||||
# from wicd.translations import language
|
# from wicd.translations import language
|
||||||
@@ -298,7 +301,7 @@ def help_dialog(body):
|
|||||||
|
|
||||||
def run_configscript(parent, netname, nettype):
|
def run_configscript(parent, netname, nettype):
|
||||||
"""Run configuration script."""
|
"""Run configuration script."""
|
||||||
configfile = wpath.etc + netname + '-settings.conf'
|
configfile = os.path.join(CFG.etc, netname + '-settings.conf')
|
||||||
if nettype != 'wired':
|
if nettype != 'wired':
|
||||||
header = 'profile'
|
header = 'profile'
|
||||||
else:
|
else:
|
||||||
@@ -1291,7 +1294,7 @@ def main():
|
|||||||
if "DBus.Error.AccessDenied" in e.get_dbus_name():
|
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.')
|
'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' + CFG.wicd_group + '\033[0m'))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|||||||
16
wicd/misc.py
16
wicd/misc.py
@@ -40,7 +40,7 @@ from gi.repository import GLib as gobject
|
|||||||
from wicd.translations import _
|
from wicd.translations import _
|
||||||
|
|
||||||
# wicd imports
|
# wicd imports
|
||||||
from wicd import wpath
|
from wicd.config import CFG
|
||||||
|
|
||||||
# Connection state constants
|
# Connection state constants
|
||||||
NOT_CONNECTED = 0
|
NOT_CONNECTED = 0
|
||||||
@@ -212,7 +212,7 @@ def IsValidIPv6(ip):
|
|||||||
|
|
||||||
def PromptToStartDaemon():
|
def PromptToStartDaemon():
|
||||||
"""Prompt the user to start the daemon"""
|
"""Prompt the user to start the daemon"""
|
||||||
daemonloc = wpath.sbin + 'wicd'
|
daemonloc = os.path.join(CFG.sbin, 'wicd')
|
||||||
sudo_prog = choose_sudo_prog()
|
sudo_prog = choose_sudo_prog()
|
||||||
if not sudo_prog:
|
if not sudo_prog:
|
||||||
return False
|
return False
|
||||||
@@ -307,8 +307,9 @@ def ParseEncryption(network):
|
|||||||
and creating a config file for it
|
and creating a config file for it
|
||||||
|
|
||||||
"""
|
"""
|
||||||
enctemplate = open(wpath.encryption + network["enctype"])
|
with open(os.path.join(CFG.encryption, network["enctype"])) as fobj:
|
||||||
template = enctemplate.readlines()
|
template = fobj.readlines()
|
||||||
|
|
||||||
if network.get('essid'):
|
if network.get('essid'):
|
||||||
config_file = "ap_scan=1\n"
|
config_file = "ap_scan=1\n"
|
||||||
else:
|
else:
|
||||||
@@ -348,7 +349,7 @@ def ParseEncryption(network):
|
|||||||
file_name = network['bssid'].replace(":", "").lower()
|
file_name = network['bssid'].replace(":", "").lower()
|
||||||
else:
|
else:
|
||||||
file_name = 'wired'
|
file_name = 'wired'
|
||||||
file_loc = os.path.join(wpath.networks, file_name)
|
file_loc = os.path.join(CFG.networks, file_name)
|
||||||
f = open(file_loc, "w")
|
f = open(file_loc, "w")
|
||||||
os.chmod(file_loc, 0o600)
|
os.chmod(file_loc, 0o600)
|
||||||
os.chown(file_loc, 0, 0)
|
os.chown(file_loc, 0, 0)
|
||||||
@@ -371,7 +372,8 @@ def LoadEncryptionMethods(wired=False):
|
|||||||
else:
|
else:
|
||||||
active_fname = "active"
|
active_fname = "active"
|
||||||
try:
|
try:
|
||||||
enctypes = open(wpath.encryption + active_fname, "r").readlines()
|
with open(os.path.join(CFG.encryption, active_fname), "r") as fobj:
|
||||||
|
enctypes = fobj.readlines()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print("Fatal Error: template index file is missing.")
|
print("Fatal Error: template index file is missing.")
|
||||||
raise IOError(e)
|
raise IOError(e)
|
||||||
@@ -405,7 +407,7 @@ def _parse_enc_template(enctype):
|
|||||||
return line.replace(key, "").replace("=", "").strip()
|
return line.replace(key, "").replace("=", "").strip()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
f = open(os.path.join(wpath.encryption, enctype), "r")
|
f = open(os.path.join(CFG.encryption, enctype), "r")
|
||||||
except IOError:
|
except IOError:
|
||||||
print(("Failed to open template file %s" % enctype))
|
print(("Failed to open template file %s" % enctype))
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -48,12 +48,10 @@ from signal import SIGTERM
|
|||||||
from functools import cmp_to_key
|
from functools import cmp_to_key
|
||||||
|
|
||||||
# wicd imports
|
# wicd imports
|
||||||
|
from wicd.config import CFG
|
||||||
from wicd import misc
|
from wicd import misc
|
||||||
from wicd import wpath
|
|
||||||
from wicd.backend import BackendManager
|
from wicd.backend import BackendManager
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
wpath.chdir(__file__)
|
|
||||||
|
|
||||||
BACKEND = None
|
BACKEND = None
|
||||||
BACKEND_MGR = BackendManager()
|
BACKEND_MGR = BackendManager()
|
||||||
@@ -227,7 +225,7 @@ class Controller(object):
|
|||||||
mac = 'X'
|
mac = 'X'
|
||||||
if name in (None, ''):
|
if name in (None, ''):
|
||||||
name = 'X'
|
name = 'X'
|
||||||
misc.ExecuteScripts(wpath.predisconnectscripts, self.debug,
|
misc.ExecuteScripts(CFG.predisconnectscripts, self.debug,
|
||||||
extra_parameters=(nettype, name, mac))
|
extra_parameters=(nettype, name, mac))
|
||||||
if self.pre_disconnect_script:
|
if self.pre_disconnect_script:
|
||||||
print('Running pre-disconnect script')
|
print('Running pre-disconnect script')
|
||||||
@@ -241,7 +239,7 @@ class Controller(object):
|
|||||||
iface.FlushDNS()
|
iface.FlushDNS()
|
||||||
iface.Down()
|
iface.Down()
|
||||||
iface.Up()
|
iface.Up()
|
||||||
misc.ExecuteScripts(wpath.postdisconnectscripts, self.debug,
|
misc.ExecuteScripts(CFG.postdisconnectscripts, self.debug,
|
||||||
extra_parameters=(nettype, name, mac))
|
extra_parameters=(nettype, name, mac))
|
||||||
if self.post_disconnect_script:
|
if self.post_disconnect_script:
|
||||||
print('Running post-disconnect script')
|
print('Running post-disconnect script')
|
||||||
@@ -965,7 +963,7 @@ class WirelessConnectThread(ConnectThread):
|
|||||||
self.is_connecting = True
|
self.is_connecting = True
|
||||||
|
|
||||||
# Run pre-connection script.
|
# Run pre-connection script.
|
||||||
self.run_scripts(wpath.preconnectscripts,
|
self.run_scripts(CFG.preconnectscripts,
|
||||||
extra_parameters=('wireless', self.network['essid'],
|
extra_parameters=('wireless', self.network['essid'],
|
||||||
self.network['bssid']))
|
self.network['bssid']))
|
||||||
self.run_script_if_needed(self.before_script, 'pre-connection',
|
self.run_script_if_needed(self.before_script, 'pre-connection',
|
||||||
@@ -1013,7 +1011,7 @@ class WirelessConnectThread(ConnectThread):
|
|||||||
self.verify_association(wiface)
|
self.verify_association(wiface)
|
||||||
|
|
||||||
# Run post-connection script.
|
# Run post-connection script.
|
||||||
self.run_scripts(wpath.postconnectscripts,
|
self.run_scripts(CFG.postconnectscripts,
|
||||||
extra_parameters=('wireless', self.network['essid'],
|
extra_parameters=('wireless', self.network['essid'],
|
||||||
self.network['bssid']))
|
self.network['bssid']))
|
||||||
self.run_script_if_needed(self.after_script, 'post-connection',
|
self.run_script_if_needed(self.after_script, 'post-connection',
|
||||||
@@ -1235,7 +1233,7 @@ class WiredConnectThread(ConnectThread):
|
|||||||
self.is_connecting = True
|
self.is_connecting = True
|
||||||
|
|
||||||
# Run pre-connection script.
|
# Run pre-connection script.
|
||||||
self.run_scripts(wpath.preconnectscripts,
|
self.run_scripts(CFG.preconnectscripts,
|
||||||
extra_parameters=('wired', 'wired',
|
extra_parameters=('wired', 'wired',
|
||||||
self.network['profilename']))
|
self.network['profilename']))
|
||||||
self.run_script_if_needed(self.before_script, 'pre-connection',
|
self.run_script_if_needed(self.before_script, 'pre-connection',
|
||||||
@@ -1262,7 +1260,7 @@ class WiredConnectThread(ConnectThread):
|
|||||||
self.set_dns_addresses(liface)
|
self.set_dns_addresses(liface)
|
||||||
|
|
||||||
# Run post-connection script.
|
# Run post-connection script.
|
||||||
self.run_scripts(wpath.postconnectscripts,
|
self.run_scripts(CFG.postconnectscripts,
|
||||||
extra_parameters=('wired', 'wired',
|
extra_parameters=('wired', 'wired',
|
||||||
self.network['profilename']))
|
self.network['profilename']))
|
||||||
self.run_script_if_needed(self.after_script, 'post-connection',
|
self.run_script_if_needed(self.after_script, 'post-connection',
|
||||||
|
|||||||
@@ -19,17 +19,18 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
import gettext
|
||||||
import locale
|
import locale
|
||||||
import os
|
import os
|
||||||
from wicd import wpath
|
|
||||||
import gettext
|
from wicd.config import CFG
|
||||||
|
|
||||||
|
|
||||||
def get_gettext():
|
def get_gettext():
|
||||||
"""Set up gettext for translations."""
|
"""Set up gettext for translations."""
|
||||||
# Borrowed from an excellent post on how to do this at
|
# Borrowed from an excellent post on how to do this at
|
||||||
# http://www.learningpython.com/2006/12/03/translating-your-pythonpygtk-application/
|
# http://www.learningpython.com/2006/12/03/translating-your-pythonpygtk-application/
|
||||||
local_path = wpath.translations
|
local_path = CFG.translations
|
||||||
langs = []
|
langs = []
|
||||||
osLanguage = os.environ.get('LANGUAGE', None)
|
osLanguage = os.environ.get('LANGUAGE', None)
|
||||||
if osLanguage:
|
if osLanguage:
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ else:
|
|||||||
DBusGMainLoop(set_as_default=True)
|
DBusGMainLoop(set_as_default=True)
|
||||||
|
|
||||||
# wicd specific libraries
|
# wicd specific libraries
|
||||||
from wicd import wpath
|
import wicd
|
||||||
|
from wicd.config import CFG
|
||||||
from wicd import networking
|
from wicd import networking
|
||||||
from wicd import misc
|
from wicd import misc
|
||||||
from wicd import wnettools
|
from wicd import wnettools
|
||||||
@@ -62,14 +63,12 @@ from wicd.misc import noneToBlankString, _status_dict
|
|||||||
from wicd.logfile import ManagedStdio
|
from wicd.logfile import ManagedStdio
|
||||||
from wicd.configmanager import ConfigManager
|
from wicd.configmanager import ConfigManager
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
wpath.chdir(__file__)
|
|
||||||
|
|
||||||
misc.RenameProcess("wicd")
|
misc.RenameProcess("wicd")
|
||||||
|
|
||||||
wireless_conf = os.path.join(wpath.etc, "wireless-settings.conf")
|
wireless_conf = os.path.join(CFG.etc, "wireless-settings.conf")
|
||||||
wired_conf = os.path.join(wpath.etc, "wired-settings.conf")
|
wired_conf = os.path.join(CFG.etc, "wired-settings.conf")
|
||||||
dhclient_conf = os.path.join(wpath.etc, "dhclient.conf.template")
|
dhclient_conf = os.path.join(CFG.etc, "dhclient.conf.template")
|
||||||
|
|
||||||
|
|
||||||
class WicdDaemon(dbus.service.Object, object):
|
class WicdDaemon(dbus.service.Object, object):
|
||||||
@@ -85,7 +84,7 @@ class WicdDaemon(dbus.service.Object, object):
|
|||||||
"""Initializes the daemon DBus object."""
|
"""Initializes the daemon DBus object."""
|
||||||
dbus.service.Object.__init__(self, bus_name=bus_name,
|
dbus.service.Object.__init__(self, bus_name=bus_name,
|
||||||
object_path=object_path)
|
object_path=object_path)
|
||||||
self.config = ConfigManager(os.path.join(wpath.etc,
|
self.config = ConfigManager(os.path.join(CFG.etc,
|
||||||
"manager-settings.conf"))
|
"manager-settings.conf"))
|
||||||
self._debug_mode = bool(self.config.get("Settings", "debug_mode"))
|
self._debug_mode = bool(self.config.get("Settings", "debug_mode"))
|
||||||
self.wifi = networking.Wireless(debug=self._debug_mode)
|
self.wifi = networking.Wireless(debug=self._debug_mode)
|
||||||
@@ -158,7 +157,7 @@ class WicdDaemon(dbus.service.Object, object):
|
|||||||
anything >= 0. This number is effective starting wicd v1.2.0.
|
anything >= 0. This number is effective starting wicd v1.2.0.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return wpath.version
|
return wicd.__version__
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon')
|
@dbus.service.method('org.wicd.daemon')
|
||||||
def SetWiredInterface(self, interface):
|
def SetWiredInterface(self, interface):
|
||||||
@@ -1720,7 +1719,7 @@ Arguments:
|
|||||||
\t-n\t--no-poll\tDon't monitor network status.
|
\t-n\t--no-poll\tDon't monitor network status.
|
||||||
\t-o\t--no-stdout\tDon't redirect stdout.
|
\t-o\t--no-stdout\tDon't redirect stdout.
|
||||||
\t-h\t--help\t\tPrint this help.
|
\t-h\t--help\t\tPrint this help.
|
||||||
""" % (wpath.version + ' (bzr-r%s)' % wpath.revision))
|
""" % (wicd.__version__ + ' (git-r%s)' % CFG.revision))
|
||||||
|
|
||||||
|
|
||||||
def daemonize():
|
def daemonize():
|
||||||
@@ -1753,10 +1752,10 @@ def daemonize():
|
|||||||
try:
|
try:
|
||||||
pid = os.fork()
|
pid = os.fork()
|
||||||
if pid > 0:
|
if pid > 0:
|
||||||
dirname = os.path.dirname(wpath.pidfile)
|
dirname = os.path.dirname(CFG.pidfile)
|
||||||
if not os.path.exists(dirname):
|
if not os.path.exists(dirname):
|
||||||
os.makedirs(dirname)
|
os.makedirs(dirname)
|
||||||
pidfile = open(wpath.pidfile, 'w')
|
pidfile = open(CFG.pidfile, 'w')
|
||||||
pidfile.write(str(pid) + '\n')
|
pidfile.write(str(pid) + '\n')
|
||||||
pidfile.close()
|
pidfile.close()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
@@ -1799,7 +1798,7 @@ def run(argv):
|
|||||||
"""
|
"""
|
||||||
# back up resolv.conf before we do anything else
|
# back up resolv.conf before we do anything else
|
||||||
try:
|
try:
|
||||||
backup_location = wpath.varlib + 'resolv.conf.orig'
|
backup_location = os.path.join(CFG.varlib, 'resolv.conf.orig')
|
||||||
# Don't back up if the backup already exists, either as a regular file
|
# Don't back up if the backup already exists, either as a regular file
|
||||||
# or a symlink
|
# or a symlink
|
||||||
# The backup file should have been cleaned up by wicd, so perhaps it
|
# The backup file should have been cleaned up by wicd, so perhaps it
|
||||||
@@ -1854,14 +1853,14 @@ def run(argv):
|
|||||||
|
|
||||||
if kill:
|
if kill:
|
||||||
try:
|
try:
|
||||||
f = open(wpath.pidfile)
|
f = open(CFG.pidfile)
|
||||||
except IOError:
|
except IOError:
|
||||||
# print >> sys.stderr, "No wicd instance active, aborting."
|
# print >> sys.stderr, "No wicd instance active, aborting."
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# restore resolv.conf on quit
|
# restore resolv.conf on quit
|
||||||
try:
|
try:
|
||||||
backup_location = wpath.varlib + 'resolv.conf.orig'
|
backup_location = os.path.join(CFG.varlib, 'resolv.conf.orig')
|
||||||
if os.path.islink(backup_location):
|
if os.path.islink(backup_location):
|
||||||
dest = os.readlink(backup_location)
|
dest = os.readlink(backup_location)
|
||||||
os.remove('/etc/resolv.conf')
|
os.remove('/etc/resolv.conf')
|
||||||
@@ -1884,33 +1883,33 @@ def run(argv):
|
|||||||
# quit, this should be the only option specified
|
# quit, this should be the only option specified
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if os.path.exists(wpath.pidfile):
|
if os.path.exists(CFG.pidfile):
|
||||||
print('It seems like the daemon is already running.')
|
print('It seems like the daemon is already running.')
|
||||||
print('If it is not, please remove %s and try again.' % wpath.pidfile)
|
print('If it is not, please remove %s and try again.' % CFG.pidfile)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if not os.path.exists(wpath.networks):
|
if not os.path.exists(CFG.networks):
|
||||||
os.makedirs(wpath.networks)
|
os.makedirs(CFG.networks)
|
||||||
|
|
||||||
if do_daemonize:
|
if do_daemonize:
|
||||||
daemonize()
|
daemonize()
|
||||||
|
|
||||||
if redirect_stderr or redirect_stdout:
|
if redirect_stderr or redirect_stdout:
|
||||||
logpath = os.path.join(wpath.log, 'wicd.log')
|
logpath = os.path.join(CFG.log, 'wicd.log')
|
||||||
if not os.path.exists(wpath.log):
|
if not os.path.exists(CFG.log):
|
||||||
os.makedirs(wpath.log)
|
os.makedirs(CFG.log)
|
||||||
os.chmod(wpath.log, 0o755)
|
os.chmod(CFG.log, 0o755)
|
||||||
output = ManagedStdio(logpath)
|
output = ManagedStdio(logpath)
|
||||||
if os.path.exists(logpath):
|
if os.path.exists(logpath):
|
||||||
try:
|
try:
|
||||||
os.chmod(logpath, int(wpath.log_perms, 8))
|
os.chmod(logpath, int(CFG.log_perms, 8))
|
||||||
except OSError:
|
except OSError:
|
||||||
print('unable to chmod log file to %s' % wpath.log_perms)
|
print('unable to chmod log file to %s' % CFG.log_perms)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if wpath.log_group:
|
if CFG.log_group:
|
||||||
import grp
|
import grp
|
||||||
group = grp.getgrnam(wpath.log_group)
|
group = grp.getgrnam(CFG.log_group)
|
||||||
os.chown(logpath, 0, group[2])
|
os.chown(logpath, 0, group[2])
|
||||||
except OSError:
|
except OSError:
|
||||||
print('unable to chown log file to %s' % group[2])
|
print('unable to chown log file to %s' % group[2])
|
||||||
@@ -1924,7 +1923,7 @@ def run(argv):
|
|||||||
print('wicd initializing...')
|
print('wicd initializing...')
|
||||||
print('---------------------------')
|
print('---------------------------')
|
||||||
|
|
||||||
print('wicd is version', wpath.version, wpath.revision)
|
print('wicd is version', wicd.__version__, CFG.revision)
|
||||||
|
|
||||||
# Open the DBUS session
|
# Open the DBUS session
|
||||||
bus = dbus.SystemBus()
|
bus = dbus.SystemBus()
|
||||||
@@ -1933,8 +1932,8 @@ def run(argv):
|
|||||||
keep_connection=keep_connection)
|
keep_connection=keep_connection)
|
||||||
child_pid = None
|
child_pid = None
|
||||||
if not no_poll:
|
if not no_poll:
|
||||||
child_pid = Popen([wpath.python, "-O",
|
child_pid = Popen([CFG.python, "-O",
|
||||||
os.path.join(wpath.daemon, "monitor.py")],
|
os.path.join(CFG.daemon, "monitor.py")],
|
||||||
shell=False, close_fds=True).pid
|
shell=False, close_fds=True).pid
|
||||||
atexit.register(on_exit, child_pid)
|
atexit.register(on_exit, child_pid)
|
||||||
|
|
||||||
@@ -1956,8 +1955,8 @@ def on_exit(child_pid):
|
|||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
print('Removing PID file...')
|
print('Removing PID file...')
|
||||||
if os.path.exists(wpath.pidfile):
|
if os.path.exists(CFG.pidfile):
|
||||||
os.remove(wpath.pidfile)
|
os.remove(CFG.pidfile)
|
||||||
print('Shutting down...')
|
print('Shutting down...')
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|||||||
@@ -41,10 +41,11 @@ import shutil
|
|||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from wicd import wpath
|
from wicd.config import CFG
|
||||||
from wicd import misc
|
from wicd import misc
|
||||||
from wicd.misc import find_path
|
from wicd.misc import find_path
|
||||||
|
|
||||||
|
|
||||||
# Regular expressions.
|
# Regular expressions.
|
||||||
_re_mode = (re.I | re.M | re.S)
|
_re_mode = (re.I | re.M | re.S)
|
||||||
essid_pattern = re.compile('.*ESSID:"?(.*?)".*\n', _re_mode)
|
essid_pattern = re.compile('.*ESSID:"?(.*?)".*\n', _re_mode)
|
||||||
@@ -342,7 +343,7 @@ class BaseInterface(object):
|
|||||||
return (client, cmd)
|
return (client, cmd)
|
||||||
|
|
||||||
# probably /var/lib/wicd/dhclient.conf with defaults
|
# probably /var/lib/wicd/dhclient.conf with defaults
|
||||||
dhclient_conf_path = os.path.join(wpath.varlib, 'dhclient.conf')
|
dhclient_conf_path = os.path.join(CFG.varlib, 'dhclient.conf')
|
||||||
|
|
||||||
client_dict = {
|
client_dict = {
|
||||||
"dhclient":
|
"dhclient":
|
||||||
@@ -382,7 +383,7 @@ class BaseInterface(object):
|
|||||||
'better')
|
'better')
|
||||||
|
|
||||||
dhclient_template = open(os.path.
|
dhclient_template = open(os.path.
|
||||||
join(wpath.etc,
|
join(CFG.etc,
|
||||||
'dhclient.conf.template'), 'r')
|
'dhclient.conf.template'), 'r')
|
||||||
output_conf = open(dhclient_conf_path, 'w')
|
output_conf = open(dhclient_conf_path, 'w')
|
||||||
|
|
||||||
@@ -394,7 +395,7 @@ class BaseInterface(object):
|
|||||||
output_conf.close()
|
output_conf.close()
|
||||||
dhclient_template.close()
|
dhclient_template.close()
|
||||||
else:
|
else:
|
||||||
shutil.copy(os.path.join(wpath.etc,
|
shutil.copy(os.path.join(CFG.etc,
|
||||||
'dhclient.conf.template'),
|
'dhclient.conf.template'),
|
||||||
dhclient_conf_path)
|
dhclient_conf_path)
|
||||||
|
|
||||||
@@ -1022,7 +1023,7 @@ class BaseWiredInterface(BaseInterface):
|
|||||||
"""Authenticate with wpa_supplicant."""
|
"""Authenticate with wpa_supplicant."""
|
||||||
misc.ParseEncryption(network)
|
misc.ParseEncryption(network)
|
||||||
cmd = ['wpa_supplicant', '-B', '-i', self.iface, '-c',
|
cmd = ['wpa_supplicant', '-B', '-i', self.iface, '-c',
|
||||||
os.path.join(wpath.networks, 'wired'),
|
os.path.join(CFG.networks, 'wired'),
|
||||||
'-Dwired']
|
'-Dwired']
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print(cmd)
|
print(cmd)
|
||||||
@@ -1316,7 +1317,7 @@ class BaseWirelessInterface(BaseInterface):
|
|||||||
else:
|
else:
|
||||||
driver = '-D' + self.wpa_driver
|
driver = '-D' + self.wpa_driver
|
||||||
cmd = ['wpa_supplicant', '-B', '-i', self.iface, '-c',
|
cmd = ['wpa_supplicant', '-B', '-i', self.iface, '-c',
|
||||||
os.path.join(wpath.networks,
|
os.path.join(CFG.networks,
|
||||||
network['bssid'].replace(':', '').lower()),
|
network['bssid'].replace(':', '').lower()),
|
||||||
driver]
|
driver]
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
|
|||||||
Reference in New Issue
Block a user