1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-19 20:38:00 +01:00

Don't provide separate options for pre/post/disconnect scripts. Just a parent scripts directory.

This commit is contained in:
Dan O'Reilly
2009-03-01 22:43:28 -05:00
parent f66ec767fe
commit 5f6807732a
2 changed files with 46 additions and 44 deletions

View File

@@ -27,9 +27,9 @@ lib = '%LIB%'
share = '%SHARE%' share = '%SHARE%'
etc = '%ETC%' etc = '%ETC%'
scripts = '%SCRIPTS%' scripts = '%SCRIPTS%'
disconnectscripts = '%DISCONNECTSCRIPTS%' disconnectscripts = '%SCRIPTS%disconnect'
preconnectscripts = '%PRECONNECTSCRIPTS%' preconnectscripts = '%SCRIPTS%preconnect'
postconnectscripts = '%POSTCONNECTSCRIPTS%' postconnectscripts = '%SCRIPTS%postconnect'
images = '%IMAGES%' images = '%IMAGES%'
encryption = '%ENCRYPTION%' encryption = '%ENCRYPTION%'
bin = '%BIN%' bin = '%BIN%'

View File

@@ -42,6 +42,7 @@ except Exception, e:
print 'failed to find revision number:' print 'failed to find revision number:'
print e print e
class configure(Command): class configure(Command):
description = "configure the paths that Wicd will be installed to" description = "configure the paths that Wicd will be installed to"
@@ -52,9 +53,6 @@ class configure(Command):
('share=', None, 'set the share directory'), ('share=', None, 'set the share directory'),
('etc=', None, 'set the etc directory'), ('etc=', None, 'set the etc directory'),
('scripts=', None, 'set the global scripts directory'), ('scripts=', None, 'set the global scripts directory'),
('disconnectscripts=', None, 'set the global disconnect scripts directory'),
('preconnectscripts=', None, 'set the global preconnect scripts directory'),
('postconnectscripts=', None, 'set the global postconnect scripts directory'),
('images=', None, 'set the image directory'), ('images=', None, 'set the image directory'),
('encryption=', None, 'set the encryption template directory'), ('encryption=', None, 'set the encryption template directory'),
('bin=', None, 'set the bin directory'), ('bin=', None, 'set the bin directory'),
@@ -95,15 +93,11 @@ class configure(Command):
('no-install-ncurses', None, 'do not install the ncurses client') ('no-install-ncurses', None, 'do not install the ncurses client')
] ]
def initialize_options(self): def initialize_options(self):
self.lib = '/usr/lib/wicd/' self.lib = '/usr/lib/wicd/'
self.share = '/usr/share/wicd/' self.share = '/usr/share/wicd/'
self.etc = '/etc/wicd/' self.etc = '/etc/wicd/'
self.scripts = self.etc + "scripts/" self.scripts = self.etc + "scripts/"
self.preconnectscripts = self.scripts + "preconnect/"
self.postconnectscripts = self.scripts + "postconnect/"
self.disconnectscripts = self.scripts + "disconnect/"
self.icons = '/usr/share/icons/hicolor/' self.icons = '/usr/share/icons/hicolor/'
self.images = '/usr/share/pixmaps/wicd/' self.images = '/usr/share/pixmaps/wicd/'
self.encryption = self.etc + 'encryption/templates/' self.encryption = self.etc + 'encryption/templates/'
@@ -210,7 +204,8 @@ class configure(Command):
kde4temp = subprocess.Popen(["kde4-config","--prefix"], stdout=subprocess.PIPE) kde4temp = subprocess.Popen(["kde4-config","--prefix"], stdout=subprocess.PIPE)
returncode = kde4temp.wait() # let it finish, and get the exit code returncode = kde4temp.wait() # let it finish, and get the exit code
kde4dir_candidate = kde4temp.stdout.readline().strip() # read stdout kde4dir_candidate = kde4temp.stdout.readline().strip() # read stdout
if len(kde4dir_candidate) == 0 or returncode != 0 or not os.path.isabs(kde4dir_candidate): if len(kde4dir_candidate) == 0 or returncode != 0 or \
not os.path.isabs(kde4dir_candidate):
raise ValueError raise ValueError
else: else:
self.kdedir = kde4dir_candidate + '/share/autostart' self.kdedir = kde4dir_candidate + '/share/autostart'
@@ -227,14 +222,12 @@ class configure(Command):
self.initfilename = os.path.basename(self.initfile) self.initfilename = os.path.basename(self.initfile)
self.wicdgroup = 'users' self.wicdgroup = 'users'
def finalize_options(self): def finalize_options(self):
if self.distro_detect_failed and not self.no_install_init and \ if self.distro_detect_failed and not self.no_install_init and \
'FAIL' in [self.init, self.initfile]: 'FAIL' in [self.init, self.initfile]:
print 'ERROR: Failed to detect distro. Configure cannot continue. ' + \ print 'ERROR: Failed to detect distro. Configure cannot continue. ' + \
'Please specify --init and --initfile to continue with configuration.' 'Please specify --init and --initfile to continue with configuration.'
# loop through the argument definitions in user_options # loop through the argument definitions in user_options
for argument in self.user_options: for argument in self.user_options:
# argument name is the first item in the user_options list # argument name is the first item in the user_options list
@@ -257,12 +250,15 @@ class configure(Command):
values = list() values = list()
for argument in self.user_options: for argument in self.user_options:
if argument[0].endswith('='): if argument[0].endswith('='):
print argument[0][:-1],'is', cur_arg = argument[0][:-1]
print getattr(self, argument[0][:-1]) cur_arg_value = getattr(self, cur_arg)
values.append((argument[0][:-1], getattr(self, argument[0][:-1].replace('-','_')))) print "%s is %s" % (cur_arg, cur_arg_value)
values.append((cur_arg, cur_arg_value.replace('-', '_')))
else: else:
print "Found switch",argument,getattr(self, argument[0].replace('-','_')) cur_arg = argument[0]
values.append((argument[0], bool(getattr(self, argument[0].replace('-','_'))))) cur_arg_value = getattr(self, cur_arg.replace('-', '_'))
print "Found switch %s %s" % (argument, cur_arg_value)
values.append((cur_arg, bool(cur_arg_value)))
print 'Replacing values in template files...' print 'Replacing values in template files...'
for item in os.listdir('in'): for item in os.listdir('in'):
@@ -275,7 +271,8 @@ class configure(Command):
item_out = open(final_name, 'w') item_out = open(final_name, 'w')
for line in item_in.readlines(): for line in item_in.readlines():
for item, value in values: for item, value in values:
line = line.replace('%' + str(item.upper().replace('-','_')) + '%', str(value)) line = line.replace('%' + str(item.upper().replace('-','_')) + \
'%', str(value))
# other things to replace that aren't arguments # other things to replace that aren't arguments
line = line.replace('%VERSION%', str(VERSION_NUM)) line = line.replace('%VERSION%', str(VERSION_NUM))
@@ -363,7 +360,8 @@ class get_translations(Command):
shutil.move(pofile, lang_identifier+'.po') shutil.move(pofile, lang_identifier+'.po')
print 'Got',lang_identifier print 'Got',lang_identifier
os.makedirs('translations/'+lang_identifier+'/LC_MESSAGES') os.makedirs('translations/'+lang_identifier+'/LC_MESSAGES')
os.system('msgfmt --output-file=translations/'+lang_identifier+'/LC_MESSAGES/wicd.mo '+lang_identifier+'.po') os.system('msgfmt --output-file=translations/' + lang_identifier +
'/LC_MESSAGES/wicd.mo ' + lang_identifier + '.po')
os.remove(lang_identifier+'.po') os.remove(lang_identifier+'.po')
@@ -383,7 +381,7 @@ class uninstall(Command):
try: try:
import wpath import wpath
except: except ImportError:
print '''Error importing wpath.py. You can safely ignore this print '''Error importing wpath.py. You can safely ignore this
message. It is probably because you haven't run python setup.py message. It is probably because you haven't run python setup.py
configure yet or you are running it for the first time.''' configure yet or you are running it for the first time.'''
@@ -410,12 +408,15 @@ try:
(wpath.icons + '22x22/apps/', ['icons/22px/wicd-client.png']), (wpath.icons + '22x22/apps/', ['icons/22px/wicd-client.png']),
(wpath.icons + '16x16/apps/', ['icons/16px/wicd-client.png']), (wpath.icons + '16x16/apps/', ['icons/16px/wicd-client.png']),
(wpath.images, [('images/' + b) for b in os.listdir('images') if not b.startswith('.')]), (wpath.images, [('images/' + b) for b in os.listdir('images') if not b.startswith('.')]),
(wpath.encryption, [('encryption/templates/' + b) for b in os.listdir('encryption/templates') if not b.startswith('.')]), (wpath.encryption, [('encryption/templates/' + b) for b in
os.listdir('encryption/templates') if not b.startswith('.')]),
(wpath.networks, []), (wpath.networks, []),
(wpath.bin, ['scripts/wicd-client', ]), (wpath.bin, ['scripts/wicd-client', ]),
(wpath.sbin, ['scripts/wicd', ]), (wpath.sbin, ['scripts/wicd', ]),
(wpath.share, ['data/wicd.glade', ]), (wpath.share, ['data/wicd.glade', ]),
(wpath.lib, ['wicd/wicd-client.py', 'wicd/monitor.py', 'wicd/wicd-daemon.py', 'wicd/configscript.py', 'wicd/suspend.py', 'wicd/autoconnect.py']), #'wicd/wicd-gui.py', (wpath.lib, ['wicd/wicd-client.py', 'wicd/monitor.py',
'wicd/wicd-daemon.py', 'wicd/configscript.py',
'wicd/suspend.py', 'wicd/autoconnect.py']),
(wpath.backends, ['wicd/backends/be-external.py', 'wicd/backends/be-ioctl.py']), (wpath.backends, ['wicd/backends/be-external.py', 'wicd/backends/be-ioctl.py']),
(wpath.autostart, ['other/wicd-tray.desktop', ]), (wpath.autostart, ['other/wicd-tray.desktop', ]),
(wpath.scripts, []), (wpath.scripts, []),
@@ -424,12 +425,12 @@ try:
(wpath.postconnectscripts, []), (wpath.postconnectscripts, []),
] ]
if not wpath.no_install_ncurses: if not wpath.no_install_ncurses:
data.append(( wpath.lib, ['curses/curses_misc.py'])) data.append((wpath.lib, ['curses/curses_misc.py']))
data.append(( wpath.lib, ['curses/prefs_curses.py'])) data.append((wpath.lib, ['curses/prefs_curses.py']))
data.append(( wpath.lib, ['curses/wicd-curses.py'])) data.append((wpath.lib, ['curses/wicd-curses.py']))
data.append(( wpath.lib, ['curses/netentry_curses.py'])) data.append((wpath.lib, ['curses/netentry_curses.py']))
data.append(( wpath.lib, ['curses/configscript_curses.py'])) data.append((wpath.lib, ['curses/configscript_curses.py']))
data.append(( wpath.bin, ['scripts/wicd-curses'])) data.append((wpath.bin, ['scripts/wicd-curses']))
if not wpath.no_install_man: if not wpath.no_install_man:
data.append(( wpath.mandir + 'man8/', ['man/wicd-curses.8'])) data.append(( wpath.mandir + 'man8/', ['man/wicd-curses.8']))
piddir = os.path.dirname(wpath.pidfile) piddir = os.path.dirname(wpath.pidfile)
@@ -437,22 +438,23 @@ try:
piddir += '/' piddir += '/'
data.append (( piddir, [] )) data.append (( piddir, [] ))
if not wpath.no_install_docs: if not wpath.no_install_docs:
data.append(( wpath.docdir, [ 'INSTALL', 'LICENSE', 'AUTHORS', 'README', 'CHANGES','other/WHEREAREMYFILES' ])) data.append((wpath.docdir, ['INSTALL', 'LICENSE', 'AUTHORS',
'README', 'CHANGES', 'other/WHEREAREMYFILES']))
if not wpath.no_install_kde: if not wpath.no_install_kde:
data.append(( wpath.kdedir, [ 'other/wicd-tray.desktop' ])) data.append((wpath.kdedir, ['other/wicd-tray.desktop']))
if not wpath.no_install_init: if not wpath.no_install_init:
data.append(( wpath.init, [ wpath.initfile ])) data.append((wpath.init, [ wpath.initfile ]))
if not wpath.no_install_man: if not wpath.no_install_man:
data.append(( wpath.mandir + 'man8/', [ 'man/wicd.8' ])) data.append((wpath.mandir + 'man8/', [ 'man/wicd.8' ]))
data.append(( wpath.mandir + 'man5/', [ 'man/wicd-manager-settings.conf.5' ])) data.append((wpath.mandir + 'man5/', [ 'man/wicd-manager-settings.conf.5' ]))
data.append(( wpath.mandir + 'man5/', [ 'man/wicd-wired-settings.conf.5' ])) data.append((wpath.mandir + 'man5/', [ 'man/wicd-wired-settings.conf.5' ]))
data.append(( wpath.mandir + 'man5/', [ 'man/wicd-wireless-settings.conf.5' ])) data.append((wpath.mandir + 'man5/', [ 'man/wicd-wireless-settings.conf.5' ]))
data.append(( wpath.mandir + 'man1/', [ 'man/wicd-client.1' ])) data.append((wpath.mandir + 'man1/', [ 'man/wicd-client.1' ]))
if not wpath.no_install_acpi: if not wpath.no_install_acpi:
data.append(( wpath.resume, ['other/80-wicd-connect.sh' ])) data.append((wpath.resume, ['other/80-wicd-connect.sh' ]))
data.append(( wpath.suspend, ['other/50-wicd-suspend.sh' ])) data.append((wpath.suspend, ['other/50-wicd-suspend.sh' ]))
if not wpath.no_install_pmutils: if not wpath.no_install_pmutils:
data.append(( wpath.pmutils, ['other/55wicd' ])) data.append((wpath.pmutils, ['other/55wicd' ]))
print 'Using pid path', os.path.basename(wpath.pidfile) print 'Using pid path', os.path.basename(wpath.pidfile)
print 'Language support for', print 'Language support for',
for language in os.listdir('translations/'): for language in os.listdir('translations/'):
@@ -462,8 +464,8 @@ try:
if codes[0].lower() == codes[1].lower(): if codes[0].lower() == codes[1].lower():
short_language = codes[0].lower() short_language = codes[0].lower()
print short_language, print short_language,
data.append((wpath.translations + short_language + '/LC_MESSAGES/', ['translations/' + language + '/LC_MESSAGES/wicd.mo'])) data.append((wpath.translations + short_language + '/LC_MESSAGES/',
print ['translations/' + language + '/LC_MESSAGES/wicd.mo']))
except Exception, e: except Exception, e:
print str(e) print str(e)
print '''Error setting up data array. This is normal if print '''Error setting up data array. This is normal if