From 0bc662a176b7044fd6faba7fabb68f7abe9a2049 Mon Sep 17 00:00:00 2001 From: Sérgio Almeida Date: Mon, 17 Aug 2009 16:45:58 +0100 Subject: Added -global when root. Fixed broken global lynking --- uio.py | 9 +++++++-- umodule.py | 26 +++++++++++--------------- uselect.py | 6 ++++-- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/uio.py b/uio.py index f0d9423..4f1a85c 100644 --- a/uio.py +++ b/uio.py @@ -20,6 +20,7 @@ bold = lime = red = reset = yellow = notice = '' error = warning = bullet = ok = highlight = '' verbose = False + class Counter: def __init__(self): @@ -31,6 +32,7 @@ class FileSystem: def __init__(self): """ FileSystem Contructor """ self.home = os.getenv('HOME') + self.set_global = False self.uid = pwd.getpwuid(os.getuid())[0] self.environment = self.home + '/.uselect/' @@ -309,10 +311,13 @@ class PrintSystem: def print_options(self): self.print_line(highlight + space + 'Options:' + reset) - self.print_table([ \ + table = [\ [bold + '-v', bullet + space + 'Verbose Mode'], \ [bold + '-nc', bullet + space + 'No Colors'], \ - [bold + '-version', bullet + space + 'Version Information']]) + [bold + '-version', bullet + space + 'Version Information']] + if filesystem.uid == 'root': + table.append([bold + '-global', bullet + space + 'Set Globally']) + self.print_table(table) class ProfilePrintSystem(PrintSystem): diff --git a/umodule.py b/umodule.py index 26ab137..7014c82 100644 --- a/umodule.py +++ b/umodule.py @@ -13,9 +13,6 @@ from uio import Counter from uio import filesystem from uio import printsystem - - - modules_dir = '/usr/share/uselect/modules/' class Action: @@ -34,10 +31,10 @@ class Action: elif type == 'env': self.__class__ = Env elif type == 'sym': - if filesystem.uid != 'root': - self.__class__ = Path - else: + if filesystem.set_global: self.__class__ = Sym + else: + self.__class__ = Path elif type == 'profile': self.__class__ = ProfileAction else: @@ -268,16 +265,15 @@ class Sym(Action): """ i = target[2] link = target[1] - if clear: - filesystem.delete_file(link.destination) - self.output.append('Unsetting ' + link.destination\ - + ' success!') + if link.target == None: + target = link.targets[i].split('/').pop() else: - - filesystem.create_symlink(link.targets[i], \ - link.destination) - self.output.append('Setting ' + link.targets[i]\ - + ' success!') + target = link.target + filesystem.create_symlink(link.targets[i], \ + '/' + link.target_dir + target) + + self.output.append('Setting ' + link.targets[i]\ + + ' success!') def add_link(self, link = None): """ diff --git a/uselect.py b/uselect.py index e81b470..d8c76d9 100755 --- a/uselect.py +++ b/uselect.py @@ -43,8 +43,7 @@ class UniversalSelectTool: __import__(modpath) module = eval(modpath + '.module') self.modules.append(module) - - + def get_module(self, name): import modules modname = name @@ -64,6 +63,9 @@ class UniversalSelectTool: verbose = True printsystem.verbose() args = args[1:] + elif arg == '-global': + filesystem.set_global = True + args = args[1:] elif arg == '-nc': printsystem.use_colors(False) args = args[1:] -- cgit v1.2.3-65-gdbad